summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libc/include/thread_private.h66
-rw-r--r--src/lib/libc/net/ether_aton.36
-rw-r--r--src/lib/libc/net/ethers.c4
-rw-r--r--src/lib/libc/net/gai_strerror.36
-rw-r--r--src/lib/libc/net/if_indextoname.312
-rw-r--r--src/lib/libc/net/inet6_opt_init.318
-rw-r--r--src/lib/libc/net/inet6_rth_space.38
-rw-r--r--src/lib/libc/stdlib/exit.311
-rw-r--r--src/lib/libc/stdlib/malloc.328
-rw-r--r--src/lib/libc/stdlib/malloc.c9
-rw-r--r--src/lib/libc/stdlib/mkstemp.c5
-rw-r--r--src/lib/libc/stdlib/mktemp.342
-rw-r--r--src/lib/libc/stdlib/ptsname.36
-rw-r--r--src/lib/libc/stdlib/rand48.38
-rw-r--r--src/lib/libc/stdlib/realpath.36
-rw-r--r--src/lib/libc/string/memmem.36
-rw-r--r--src/lib/libcrypto/Makefile20
-rw-r--r--src/lib/libcrypto/Symbols.list5
-rw-r--r--src/lib/libcrypto/aes/aes.c258
-rw-r--r--src/lib/libcrypto/aes/aes_amd64.c201
-rw-r--r--src/lib/libcrypto/aes/aes_i386.c201
-rw-r--r--src/lib/libcrypto/aes/aes_ige.c195
-rw-r--r--src/lib/libcrypto/aes/aes_local.h27
-rw-r--r--src/lib/libcrypto/aes/asm/aes-586.pl30
-rwxr-xr-xsrc/lib/libcrypto/aes/asm/aes-x86_64.pl90
-rw-r--r--src/lib/libcrypto/aes/asm/bsaes-x86_64.pl3123
-rw-r--r--src/lib/libcrypto/aes/asm/vpaes-x86.pl911
-rw-r--r--src/lib/libcrypto/aes/asm/vpaes-x86_64.pl1222
-rw-r--r--src/lib/libcrypto/arch/aarch64/Makefile.inc4
-rw-r--r--src/lib/libcrypto/arch/aarch64/crypto_arch.h3
-rw-r--r--src/lib/libcrypto/arch/aarch64/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/alpha/opensslconf.h139
-rw-r--r--src/lib/libcrypto/arch/amd64/Makefile.inc19
-rw-r--r--src/lib/libcrypto/arch/amd64/crypto_arch.h16
-rw-r--r--src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c20
-rw-r--r--src/lib/libcrypto/arch/amd64/opensslconf.h136
-rw-r--r--src/lib/libcrypto/arch/arm/Makefile.inc27
-rw-r--r--src/lib/libcrypto/arch/arm/arm_arch.h59
-rw-r--r--src/lib/libcrypto/arch/arm/armcap.c88
-rw-r--r--src/lib/libcrypto/arch/arm/armv4cpuid.S69
-rw-r--r--src/lib/libcrypto/arch/arm/crypto_arch.h16
-rw-r--r--src/lib/libcrypto/arch/arm/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/hppa/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/i386/Makefile.inc10
-rw-r--r--src/lib/libcrypto/arch/i386/crypto_arch.h21
-rw-r--r--src/lib/libcrypto/arch/i386/crypto_cpu_caps.c24
-rw-r--r--src/lib/libcrypto/arch/i386/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/m88k/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/mips64/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/powerpc/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/powerpc64/opensslconf.h136
-rw-r--r--src/lib/libcrypto/arch/riscv64/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/sh/opensslconf.h141
-rw-r--r--src/lib/libcrypto/arch/sparc64/opensslconf.h141
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c4
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c4
-rw-r--r--src/lib/libcrypto/asn1/a_int.c4
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c4
-rw-r--r--src/lib/libcrypto/asn1/a_object.c4
-rw-r--r--src/lib/libcrypto/asn1/a_pkey.c4
-rw-r--r--src/lib/libcrypto/asn1/a_pubkey.c4
-rw-r--r--src/lib/libcrypto/asn1/a_string.c4
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c3
-rw-r--r--src/lib/libcrypto/asn1/a_time.c3
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c6
-rw-r--r--src/lib/libcrypto/asn1/a_type.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1_gen.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1_item.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1_old.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1_old_lib.c4
-rw-r--r--src/lib/libcrypto/asn1/asn_mime.c9
-rw-r--r--src/lib/libcrypto/asn1/asn_moid.c4
-rw-r--r--src/lib/libcrypto/asn1/bio_ndef.c4
-rw-r--r--src/lib/libcrypto/asn1/p5_pbe.c9
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c14
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c4
-rw-r--r--src/lib/libcrypto/asn1/t_req.c4
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c62
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c7
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c5
-rw-r--r--src/lib/libcrypto/asn1/tasn_utl.c4
-rw-r--r--src/lib/libcrypto/asn1/x_crl.c10
-rw-r--r--src/lib/libcrypto/asn1/x_info.c96
-rw-r--r--src/lib/libcrypto/asn1/x_long.c4
-rw-r--r--src/lib/libcrypto/asn1/x_name.c4
-rw-r--r--src/lib/libcrypto/asn1/x_pkey.c123
-rw-r--r--src/lib/libcrypto/asn1/x_pubkey.c4
-rw-r--r--src/lib/libcrypto/bf/bf_local.h47
-rw-r--r--src/lib/libcrypto/bio/b_dump.c3
-rw-r--r--src/lib/libcrypto/bio/b_sock.c5
-rw-r--r--src/lib/libcrypto/bio/bf_buff.c4
-rw-r--r--src/lib/libcrypto/bio/bio.h27
-rw-r--r--src/lib/libcrypto/bio/bio_cb.c3
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c4
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c13
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c4
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c6
-rw-r--r--src/lib/libcrypto/bio/bss_file.c4
-rw-r--r--src/lib/libcrypto/bio/bss_log.c216
-rw-r--r--src/lib/libcrypto/bio/bss_mem.c11
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_add.S51
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S32
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S28
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_modadd.S112
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_modsub.S99
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_mul.S25
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8.S187
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S8
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12.S223
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12_alt.S199
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16.S273
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S9
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S29
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8.S158
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S8
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12.S227
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12_alt.S210
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16.S311
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S7
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bignum_sub.S47
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.c113
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.h7
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/word_clz.S6
-rw-r--r--src/lib/libcrypto/bn/asm/bn-586.pl3
-rwxr-xr-xsrc/lib/libcrypto/bn/asm/x86-mont.pl3
-rw-r--r--src/lib/libcrypto/bn/bn_add.c76
-rw-r--r--src/lib/libcrypto/bn/bn_add_sub.c178
-rw-r--r--src/lib/libcrypto/bn/bn_convert.c4
-rw-r--r--src/lib/libcrypto/bn/bn_ctx.c4
-rw-r--r--src/lib/libcrypto/bn/bn_div.c4
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c5
-rw-r--r--src/lib/libcrypto/bn/bn_gcd.c11
-rw-r--r--src/lib/libcrypto/bn/bn_internal.h26
-rw-r--r--src/lib/libcrypto/bn/bn_isqrt.c4
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c5
-rw-r--r--src/lib/libcrypto/bn/bn_local.h12
-rw-r--r--src/lib/libcrypto/bn/bn_mod.c5
-rw-r--r--src/lib/libcrypto/bn/bn_mod_sqrt.c5
-rw-r--r--src/lib/libcrypto/bn/bn_mod_words.c114
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c78
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c73
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c5
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c5
-rw-r--r--src/lib/libcrypto/bn/bn_recp.c5
-rw-r--r--src/lib/libcrypto/bn/bn_shift.c4
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c49
-rw-r--r--src/lib/libcrypto/bn/s2n_bignum.h793
-rw-r--r--src/lib/libcrypto/bn/s2n_bignum_internal.h35
-rw-r--r--src/lib/libcrypto/buffer/buffer.c5
-rw-r--r--src/lib/libcrypto/cert.pem340
-rw-r--r--src/lib/libcrypto/cms/cms_dd.c4
-rw-r--r--src/lib/libcrypto/cms/cms_enc.c4
-rw-r--r--src/lib/libcrypto/cms/cms_env.c4
-rw-r--r--src/lib/libcrypto/cms/cms_ess.c4
-rw-r--r--src/lib/libcrypto/cms/cms_io.c4
-rw-r--r--src/lib/libcrypto/cms/cms_kari.c4
-rw-r--r--src/lib/libcrypto/cms/cms_lib.c4
-rw-r--r--src/lib/libcrypto/cms/cms_pwri.c4
-rw-r--r--src/lib/libcrypto/cms/cms_sd.c44
-rw-r--r--src/lib/libcrypto/cms/cms_smime.c4
-rw-r--r--src/lib/libcrypto/conf/README73
-rw-r--r--src/lib/libcrypto/conf/conf_def.c4
-rw-r--r--src/lib/libcrypto/conf/conf_lib.c4
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c5
-rw-r--r--src/lib/libcrypto/crypto_ex_data.c15
-rw-r--r--src/lib/libcrypto/crypto_init.c30
-rw-r--r--src/lib/libcrypto/crypto_internal.h4
-rw-r--r--src/lib/libcrypto/crypto_legacy.c27
-rw-r--r--src/lib/libcrypto/crypto_local.h8
-rw-r--r--src/lib/libcrypto/ct/ct_b64.c4
-rw-r--r--src/lib/libcrypto/ct/ct_log.c4
-rw-r--r--src/lib/libcrypto/ct/ct_oct.c4
-rw-r--r--src/lib/libcrypto/ct/ct_policy.c7
-rw-r--r--src/lib/libcrypto/ct/ct_sct.c4
-rw-r--r--src/lib/libcrypto/ct/ct_sct_ctx.c4
-rw-r--r--src/lib/libcrypto/ct/ct_vfy.c4
-rw-r--r--src/lib/libcrypto/curve25519/curve25519.c243
-rw-r--r--src/lib/libcrypto/des/des.h15
-rw-r--r--src/lib/libcrypto/des/des_enc.c121
-rw-r--r--src/lib/libcrypto/des/des_fcrypt.c34
-rw-r--r--src/lib/libcrypto/dh/dh_ameth.c4
-rw-r--r--src/lib/libcrypto/dh/dh_check.c3
-rw-r--r--src/lib/libcrypto/dh/dh_gen.c4
-rw-r--r--src/lib/libcrypto/dh/dh_key.c4
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c4
-rw-r--r--src/lib/libcrypto/dh/dh_pmeth.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_ameth.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_asn1.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_meth.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_pmeth.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_prn.c5
-rw-r--r--src/lib/libcrypto/ec/ec_ameth.c4
-rw-r--r--src/lib/libcrypto/ec/ec_asn1.c4
-rw-r--r--src/lib/libcrypto/ec/ec_convert.c4
-rw-r--r--src/lib/libcrypto/ec/ec_curve.c316
-rw-r--r--src/lib/libcrypto/ec/ec_field.c202
-rw-r--r--src/lib/libcrypto/ec/ec_internal.h65
-rw-r--r--src/lib/libcrypto/ec/ec_key.c4
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c21
-rw-r--r--src/lib/libcrypto/ec/ec_local.h15
-rw-r--r--src/lib/libcrypto/ec/ec_mult.c4
-rw-r--r--src/lib/libcrypto/ec/ec_pmeth.c4
-rw-r--r--src/lib/libcrypto/ec/eck_prn.c4
-rw-r--r--src/lib/libcrypto/ec/ecp_hp_methods.c943
-rw-r--r--src/lib/libcrypto/ec/ecp_methods.c23
-rw-r--r--src/lib/libcrypto/ec/ecx_methods.c4
-rw-r--r--src/lib/libcrypto/ecdh/ecdh.c4
-rw-r--r--src/lib/libcrypto/ecdsa/ecdsa.c4
-rw-r--r--src/lib/libcrypto/err/err.c34
-rw-r--r--src/lib/libcrypto/err/err.h79
-rw-r--r--src/lib/libcrypto/err/err_local.h30
-rw-r--r--src/lib/libcrypto/evp/e_aes.c1037
-rw-r--r--src/lib/libcrypto/evp/e_bf.c30
-rw-r--r--src/lib/libcrypto/evp/e_camellia.c112
-rw-r--r--src/lib/libcrypto/evp/e_cast.c30
-rw-r--r--src/lib/libcrypto/evp/e_chacha20poly1305.c4
-rw-r--r--src/lib/libcrypto/evp/e_des.c44
-rw-r--r--src/lib/libcrypto/evp/e_des3.c69
-rw-r--r--src/lib/libcrypto/evp/e_idea.c26
-rw-r--r--src/lib/libcrypto/evp/e_rc2.c4
-rw-r--r--src/lib/libcrypto/evp/e_xcbc_d.c8
-rw-r--r--src/lib/libcrypto/evp/evp.h30
-rw-r--r--src/lib/libcrypto/evp/evp_aead.c4
-rw-r--r--src/lib/libcrypto/evp/evp_cipher.c46
-rw-r--r--src/lib/libcrypto/evp/evp_digest.c4
-rw-r--r--src/lib/libcrypto/evp/evp_key.c4
-rw-r--r--src/lib/libcrypto/evp/evp_local.h4
-rw-r--r--src/lib/libcrypto/evp/evp_names.c3
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c4
-rw-r--r--src/lib/libcrypto/evp/evp_pkey.c4
-rw-r--r--src/lib/libcrypto/evp/m_sigver.c4
-rw-r--r--src/lib/libcrypto/evp/p_legacy.c4
-rw-r--r--src/lib/libcrypto/evp/p_lib.c20
-rw-r--r--src/lib/libcrypto/evp/p_sign.c3
-rw-r--r--src/lib/libcrypto/evp/p_verify.c3
-rw-r--r--src/lib/libcrypto/evp/pmeth_fn.c4
-rw-r--r--src/lib/libcrypto/evp/pmeth_gn.c4
-rw-r--r--src/lib/libcrypto/evp/pmeth_lib.c4
-rw-r--r--src/lib/libcrypto/format-pem.pl3
-rw-r--r--src/lib/libcrypto/hidden/crypto_namespace.h6
-rw-r--r--src/lib/libcrypto/hidden/openssl/bio.h3
-rw-r--r--src/lib/libcrypto/hidden/openssl/mlkem.h40
-rw-r--r--src/lib/libcrypto/hidden/openssl/pem.h4
-rw-r--r--src/lib/libcrypto/hidden/openssl/x509.h4
-rw-r--r--src/lib/libcrypto/hkdf/hkdf.c4
-rw-r--r--src/lib/libcrypto/hmac/hmac.c4
-rw-r--r--src/lib/libcrypto/idea/idea.h9
-rw-r--r--src/lib/libcrypto/kdf/hkdf_evp.c8
-rw-r--r--src/lib/libcrypto/kdf/tls1_prf.c7
-rw-r--r--src/lib/libcrypto/lhash/lhash.c8
-rw-r--r--src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.35
-rw-r--r--src/lib/libcrypto/man/AES_encrypt.35
-rw-r--r--src/lib/libcrypto/man/ASIdentifiers_new.35
-rw-r--r--src/lib/libcrypto/man/ASN1_BIT_STRING_set.35
-rw-r--r--src/lib/libcrypto/man/ASN1_INTEGER_get.35
-rw-r--r--src/lib/libcrypto/man/ASN1_NULL_new.35
-rw-r--r--src/lib/libcrypto/man/ASN1_OBJECT_new.35
-rw-r--r--src/lib/libcrypto/man/ASN1_PRINTABLE_type.35
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_TABLE_get.38
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_length.37
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_new.37
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_print_ex.36
-rw-r--r--src/lib/libcrypto/man/ASN1_TIME_set.35
-rw-r--r--src/lib/libcrypto/man/ASN1_TYPE_get.35
-rw-r--r--src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.35
-rw-r--r--src/lib/libcrypto/man/ASN1_generate_nconf.35
-rw-r--r--src/lib/libcrypto/man/ASN1_get_object.35
-rw-r--r--src/lib/libcrypto/man/ASN1_item_d2i.35
-rw-r--r--src/lib/libcrypto/man/ASN1_item_digest.35
-rw-r--r--src/lib/libcrypto/man/ASN1_item_new.35
-rw-r--r--src/lib/libcrypto/man/ASN1_item_pack.35
-rw-r--r--src/lib/libcrypto/man/ASN1_item_sign.35
-rw-r--r--src/lib/libcrypto/man/ASN1_item_verify.35
-rw-r--r--src/lib/libcrypto/man/ASN1_mbstring_copy.35
-rw-r--r--src/lib/libcrypto/man/ASN1_parse_dump.35
-rw-r--r--src/lib/libcrypto/man/ASN1_put_object.35
-rw-r--r--src/lib/libcrypto/man/ASRange_new.311
-rw-r--r--src/lib/libcrypto/man/AUTHORITY_KEYID_new.35
-rw-r--r--src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.35
-rw-r--r--src/lib/libcrypto/man/BF_set_key.35
-rw-r--r--src/lib/libcrypto/man/BIO_accept.35
-rw-r--r--src/lib/libcrypto/man/BIO_ctrl.35
-rw-r--r--src/lib/libcrypto/man/BIO_dump.339
-rw-r--r--src/lib/libcrypto/man/BIO_dup_chain.35
-rw-r--r--src/lib/libcrypto/man/BIO_f_base64.35
-rw-r--r--src/lib/libcrypto/man/BIO_f_buffer.35
-rw-r--r--src/lib/libcrypto/man/BIO_f_cipher.35
-rw-r--r--src/lib/libcrypto/man/BIO_f_md.35
-rw-r--r--src/lib/libcrypto/man/BIO_f_null.35
-rw-r--r--src/lib/libcrypto/man/BIO_find_type.35
-rw-r--r--src/lib/libcrypto/man/BIO_get_data.35
-rw-r--r--src/lib/libcrypto/man/BIO_get_ex_new_index.35
-rw-r--r--src/lib/libcrypto/man/BIO_meth_new.35
-rw-r--r--src/lib/libcrypto/man/BIO_new.35
-rw-r--r--src/lib/libcrypto/man/BIO_new_CMS.35
-rw-r--r--src/lib/libcrypto/man/BIO_printf.35
-rw-r--r--src/lib/libcrypto/man/BIO_push.35
-rw-r--r--src/lib/libcrypto/man/BIO_read.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_accept.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_bio.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_connect.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_datagram.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_fd.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_file.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_mem.35
-rw-r--r--src/lib/libcrypto/man/BIO_s_null.36
-rw-r--r--src/lib/libcrypto/man/BIO_s_socket.35
-rw-r--r--src/lib/libcrypto/man/BIO_set_callback.35
-rw-r--r--src/lib/libcrypto/man/BIO_should_retry.35
-rw-r--r--src/lib/libcrypto/man/BN_CTX_new.35
-rw-r--r--src/lib/libcrypto/man/BN_CTX_start.35
-rw-r--r--src/lib/libcrypto/man/BN_add.38
-rw-r--r--src/lib/libcrypto/man/BN_add_word.35
-rw-r--r--src/lib/libcrypto/man/BN_bn2bin.35
-rw-r--r--src/lib/libcrypto/man/BN_cmp.35
-rw-r--r--src/lib/libcrypto/man/BN_copy.35
-rw-r--r--src/lib/libcrypto/man/BN_generate_prime.35
-rw-r--r--src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.35
-rw-r--r--src/lib/libcrypto/man/BN_kronecker.35
-rw-r--r--src/lib/libcrypto/man/BN_mod_inverse.35
-rw-r--r--src/lib/libcrypto/man/BN_mod_mul_montgomery.35
-rw-r--r--src/lib/libcrypto/man/BN_mod_sqrt.35
-rw-r--r--src/lib/libcrypto/man/BN_new.35
-rw-r--r--src/lib/libcrypto/man/BN_num_bytes.35
-rw-r--r--src/lib/libcrypto/man/BN_rand.35
-rw-r--r--src/lib/libcrypto/man/BN_set_bit.35
-rw-r--r--src/lib/libcrypto/man/BN_set_flags.35
-rw-r--r--src/lib/libcrypto/man/BN_set_negative.35
-rw-r--r--src/lib/libcrypto/man/BN_swap.35
-rw-r--r--src/lib/libcrypto/man/BN_zero.310
-rw-r--r--src/lib/libcrypto/man/BUF_MEM_new.35
-rw-r--r--src/lib/libcrypto/man/CMAC_Init.35
-rw-r--r--src/lib/libcrypto/man/CMS_ContentInfo_new.35
-rw-r--r--src/lib/libcrypto/man/CMS_add0_cert.35
-rw-r--r--src/lib/libcrypto/man/CMS_add1_recipient_cert.35
-rw-r--r--src/lib/libcrypto/man/CMS_add1_signer.35
-rw-r--r--src/lib/libcrypto/man/CMS_compress.35
-rw-r--r--src/lib/libcrypto/man/CMS_decrypt.35
-rw-r--r--src/lib/libcrypto/man/CMS_encrypt.35
-rw-r--r--src/lib/libcrypto/man/CMS_final.35
-rw-r--r--src/lib/libcrypto/man/CMS_get0_RecipientInfos.35
-rw-r--r--src/lib/libcrypto/man/CMS_get0_SignerInfos.35
-rw-r--r--src/lib/libcrypto/man/CMS_get0_type.35
-rw-r--r--src/lib/libcrypto/man/CMS_get1_ReceiptRequest.35
-rw-r--r--src/lib/libcrypto/man/CMS_sign.35
-rw-r--r--src/lib/libcrypto/man/CMS_sign_receipt.35
-rw-r--r--src/lib/libcrypto/man/CMS_signed_add1_attr.317
-rw-r--r--src/lib/libcrypto/man/CMS_uncompress.35
-rw-r--r--src/lib/libcrypto/man/CMS_verify.35
-rw-r--r--src/lib/libcrypto/man/CMS_verify_receipt.35
-rw-r--r--src/lib/libcrypto/man/CONF_modules_free.35
-rw-r--r--src/lib/libcrypto/man/CONF_modules_load_file.315
-rw-r--r--src/lib/libcrypto/man/CRYPTO_lock.35
-rw-r--r--src/lib/libcrypto/man/CRYPTO_memcmp.35
-rw-r--r--src/lib/libcrypto/man/CRYPTO_set_ex_data.35
-rw-r--r--src/lib/libcrypto/man/CRYPTO_set_mem_functions.35
-rw-r--r--src/lib/libcrypto/man/ChaCha.35
-rw-r--r--src/lib/libcrypto/man/DES_set_key.35
-rw-r--r--src/lib/libcrypto/man/DH_generate_key.35
-rw-r--r--src/lib/libcrypto/man/DH_generate_parameters.35
-rw-r--r--src/lib/libcrypto/man/DH_get0_pqg.315
-rw-r--r--src/lib/libcrypto/man/DH_get_ex_new_index.35
-rw-r--r--src/lib/libcrypto/man/DH_new.35
-rw-r--r--src/lib/libcrypto/man/DH_set_method.35
-rw-r--r--src/lib/libcrypto/man/DH_size.35
-rw-r--r--src/lib/libcrypto/man/DIST_POINT_new.35
-rw-r--r--src/lib/libcrypto/man/DSA_SIG_new.35
-rw-r--r--src/lib/libcrypto/man/DSA_do_sign.35
-rw-r--r--src/lib/libcrypto/man/DSA_dup_DH.35
-rw-r--r--src/lib/libcrypto/man/DSA_generate_key.35
-rw-r--r--src/lib/libcrypto/man/DSA_generate_parameters_ex.37
-rw-r--r--src/lib/libcrypto/man/DSA_get0_pqg.315
-rw-r--r--src/lib/libcrypto/man/DSA_get_ex_new_index.35
-rw-r--r--src/lib/libcrypto/man/DSA_meth_new.35
-rw-r--r--src/lib/libcrypto/man/DSA_new.35
-rw-r--r--src/lib/libcrypto/man/DSA_set_method.35
-rw-r--r--src/lib/libcrypto/man/DSA_sign.35
-rw-r--r--src/lib/libcrypto/man/DSA_size.35
-rw-r--r--src/lib/libcrypto/man/ECDH_compute_key.35
-rw-r--r--src/lib/libcrypto/man/ECDSA_SIG_new.315
-rw-r--r--src/lib/libcrypto/man/EC_GROUP_check.323
-rw-r--r--src/lib/libcrypto/man/EC_GROUP_get_curve_name.37
-rw-r--r--src/lib/libcrypto/man/EC_GROUP_new_by_curve_name.39
-rw-r--r--src/lib/libcrypto/man/EC_GROUP_new_curve_GFp.315
-rw-r--r--src/lib/libcrypto/man/EC_KEY_METHOD_new.35
-rw-r--r--src/lib/libcrypto/man/EC_KEY_new.35
-rw-r--r--src/lib/libcrypto/man/EC_POINT_add.35
-rw-r--r--src/lib/libcrypto/man/EC_POINT_get_affine_coordinates.35
-rw-r--r--src/lib/libcrypto/man/EC_POINT_new.323
-rw-r--r--src/lib/libcrypto/man/EC_POINT_point2oct.319
-rw-r--r--src/lib/libcrypto/man/ENGINE_new.35
-rw-r--r--src/lib/libcrypto/man/ERR.35
-rw-r--r--src/lib/libcrypto/man/ERR_GET_LIB.35
-rw-r--r--src/lib/libcrypto/man/ERR_asprintf_error_data.35
-rw-r--r--src/lib/libcrypto/man/ERR_clear_error.35
-rw-r--r--src/lib/libcrypto/man/ERR_error_string.35
-rw-r--r--src/lib/libcrypto/man/ERR_get_error.35
-rw-r--r--src/lib/libcrypto/man/ERR_load_crypto_strings.37
-rw-r--r--src/lib/libcrypto/man/ERR_load_strings.35
-rw-r--r--src/lib/libcrypto/man/ERR_print_errors.35
-rw-r--r--src/lib/libcrypto/man/ERR_put_error.35
-rw-r--r--src/lib/libcrypto/man/ERR_remove_state.35
-rw-r--r--src/lib/libcrypto/man/ERR_set_mark.35
-rw-r--r--src/lib/libcrypto/man/ESS_SIGNING_CERT_new.35
-rw-r--r--src/lib/libcrypto/man/EVP_AEAD_CTX_init.35
-rw-r--r--src/lib/libcrypto/man/EVP_BytesToKey.35
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.35
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.35
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_init.35
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.35
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_do_all.35
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_meth_new.35
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_nid.35
-rw-r--r--src/lib/libcrypto/man/EVP_DigestInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_DigestSignInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_DigestVerifyInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_EncodeInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_EncryptInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_MD_CTX_ctrl.39
-rw-r--r--src/lib/libcrypto/man/EVP_MD_nid.35
-rw-r--r--src/lib/libcrypto/man/EVP_OpenInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKCS82PKEY.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_new.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_cmp.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_decrypt.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_derive.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_encrypt.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_keygen.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_new.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_print_private.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_set1_RSA.325
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_sign.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_size.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_verify.35
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_verify_recover.35
-rw-r--r--src/lib/libcrypto/man/EVP_SealInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_SignInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_VerifyInit.35
-rw-r--r--src/lib/libcrypto/man/EVP_aes_128_cbc.35
-rw-r--r--src/lib/libcrypto/man/EVP_aes_128_ccm.35
-rw-r--r--src/lib/libcrypto/man/EVP_aes_128_gcm.35
-rw-r--r--src/lib/libcrypto/man/EVP_camellia_128_cbc.35
-rw-r--r--src/lib/libcrypto/man/EVP_chacha20.35
-rw-r--r--src/lib/libcrypto/man/EVP_des_cbc.35
-rw-r--r--src/lib/libcrypto/man/EVP_rc2_cbc.35
-rw-r--r--src/lib/libcrypto/man/EVP_rc4.35
-rw-r--r--src/lib/libcrypto/man/EVP_sha1.35
-rw-r--r--src/lib/libcrypto/man/EVP_sha3_224.35
-rw-r--r--src/lib/libcrypto/man/EVP_sm3.35
-rw-r--r--src/lib/libcrypto/man/EVP_sm4_cbc.35
-rw-r--r--src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.35
-rw-r--r--src/lib/libcrypto/man/GENERAL_NAME_new.35
-rw-r--r--src/lib/libcrypto/man/HMAC.35
-rw-r--r--src/lib/libcrypto/man/IPAddressRange_new.313
-rw-r--r--src/lib/libcrypto/man/MD5.35
-rw-r--r--src/lib/libcrypto/man/Makefile9
-rw-r--r--src/lib/libcrypto/man/NAME_CONSTRAINTS_new.35
-rw-r--r--src/lib/libcrypto/man/OBJ_NAME_add.3307
-rw-r--r--src/lib/libcrypto/man/OBJ_create.36
-rw-r--r--src/lib/libcrypto/man/OBJ_find_sigid_algs.36
-rw-r--r--src/lib/libcrypto/man/OBJ_nid2obj.35
-rw-r--r--src/lib/libcrypto/man/OCSP_CRLID_new.35
-rw-r--r--src/lib/libcrypto/man/OCSP_REQUEST_new.35
-rw-r--r--src/lib/libcrypto/man/OCSP_SERVICELOC_new.35
-rw-r--r--src/lib/libcrypto/man/OCSP_cert_to_id.35
-rw-r--r--src/lib/libcrypto/man/OCSP_request_add1_nonce.35
-rw-r--r--src/lib/libcrypto/man/OCSP_resp_find_status.35
-rw-r--r--src/lib/libcrypto/man/OCSP_response_status.35
-rw-r--r--src/lib/libcrypto/man/OCSP_sendreq_new.35
-rw-r--r--src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.35
-rw-r--r--src/lib/libcrypto/man/OPENSSL_cleanse.35
-rw-r--r--src/lib/libcrypto/man/OPENSSL_config.312
-rw-r--r--src/lib/libcrypto/man/OPENSSL_init_crypto.311
-rw-r--r--src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3101
-rw-r--r--src/lib/libcrypto/man/OPENSSL_malloc.35
-rw-r--r--src/lib/libcrypto/man/OPENSSL_sk_new.35
-rw-r--r--src/lib/libcrypto/man/OpenSSL_add_all_algorithms.369
-rw-r--r--src/lib/libcrypto/man/PEM_ASN1_read.37
-rw-r--r--src/lib/libcrypto/man/PEM_X509_INFO_read_bio.3 (renamed from src/lib/libcrypto/man/PEM_X509_INFO_read.3)44
-rw-r--r--src/lib/libcrypto/man/PEM_bytes_read_bio.37
-rw-r--r--src/lib/libcrypto/man/PEM_read.37
-rw-r--r--src/lib/libcrypto/man/PEM_read_bio_PrivateKey.37
-rw-r--r--src/lib/libcrypto/man/PEM_write_bio_CMS_stream.35
-rw-r--r--src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.35
-rw-r--r--src/lib/libcrypto/man/PKCS12_SAFEBAG_new.35
-rw-r--r--src/lib/libcrypto/man/PKCS12_create.35
-rw-r--r--src/lib/libcrypto/man/PKCS12_new.35
-rw-r--r--src/lib/libcrypto/man/PKCS12_newpass.35
-rw-r--r--src/lib/libcrypto/man/PKCS12_parse.35
-rw-r--r--src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_add_attribute.311
-rw-r--r--src/lib/libcrypto/man/PKCS7_dataFinal.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_dataInit.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_decrypt.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_encrypt.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_final.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_get_signer_info.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_new.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_set_content.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_set_type.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_sign.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_sign_add_signer.35
-rw-r--r--src/lib/libcrypto/man/PKCS7_verify.35
-rw-r--r--src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.35
-rw-r--r--src/lib/libcrypto/man/PKCS8_pkey_set0.35
-rw-r--r--src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.35
-rw-r--r--src/lib/libcrypto/man/POLICYINFO_new.35
-rw-r--r--src/lib/libcrypto/man/RAND_add.35
-rw-r--r--src/lib/libcrypto/man/RAND_bytes.35
-rw-r--r--src/lib/libcrypto/man/RAND_load_file.35
-rw-r--r--src/lib/libcrypto/man/RAND_set_rand_method.35
-rw-r--r--src/lib/libcrypto/man/RC2_encrypt.35
-rw-r--r--src/lib/libcrypto/man/RC4.35
-rw-r--r--src/lib/libcrypto/man/RIPEMD160.35
-rw-r--r--src/lib/libcrypto/man/RSA_PSS_PARAMS_new.35
-rw-r--r--src/lib/libcrypto/man/RSA_blinding_on.35
-rw-r--r--src/lib/libcrypto/man/RSA_check_key.35
-rw-r--r--src/lib/libcrypto/man/RSA_generate_key.35
-rw-r--r--src/lib/libcrypto/man/RSA_get0_key.321
-rw-r--r--src/lib/libcrypto/man/RSA_get_ex_new_index.35
-rw-r--r--src/lib/libcrypto/man/RSA_meth_new.35
-rw-r--r--src/lib/libcrypto/man/RSA_new.35
-rw-r--r--src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.35
-rw-r--r--src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.35
-rw-r--r--src/lib/libcrypto/man/RSA_print.35
-rw-r--r--src/lib/libcrypto/man/RSA_private_encrypt.35
-rw-r--r--src/lib/libcrypto/man/RSA_public_encrypt.35
-rw-r--r--src/lib/libcrypto/man/RSA_security_bits.35
-rw-r--r--src/lib/libcrypto/man/RSA_set_method.35
-rw-r--r--src/lib/libcrypto/man/RSA_sign.35
-rw-r--r--src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.35
-rw-r--r--src/lib/libcrypto/man/RSA_size.35
-rw-r--r--src/lib/libcrypto/man/SHA1.35
-rw-r--r--src/lib/libcrypto/man/SMIME_crlf_copy.39
-rw-r--r--src/lib/libcrypto/man/SMIME_read_ASN1.3124
-rw-r--r--src/lib/libcrypto/man/SMIME_read_CMS.310
-rw-r--r--src/lib/libcrypto/man/SMIME_read_PKCS7.310
-rw-r--r--src/lib/libcrypto/man/SMIME_text.310
-rw-r--r--src/lib/libcrypto/man/SMIME_write_ASN1.3163
-rw-r--r--src/lib/libcrypto/man/SMIME_write_CMS.3124
-rw-r--r--src/lib/libcrypto/man/SMIME_write_PKCS7.3152
-rw-r--r--src/lib/libcrypto/man/STACK_OF.35
-rw-r--r--src/lib/libcrypto/man/TS_REQ_new.35
-rw-r--r--src/lib/libcrypto/man/UI_create_method.35
-rw-r--r--src/lib/libcrypto/man/UI_get_string_type.35
-rw-r--r--src/lib/libcrypto/man/UI_new.35
-rw-r--r--src/lib/libcrypto/man/X25519.35
-rw-r--r--src/lib/libcrypto/man/X509V3_EXT_get_nid.35
-rw-r--r--src/lib/libcrypto/man/X509V3_EXT_print.35
-rw-r--r--src/lib/libcrypto/man/X509V3_extensions_print.35
-rw-r--r--src/lib/libcrypto/man/X509V3_get_d2i.35
-rw-r--r--src/lib/libcrypto/man/X509V3_parse_list.35
-rw-r--r--src/lib/libcrypto/man/X509_ALGOR_dup.35
-rw-r--r--src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.35
-rw-r--r--src/lib/libcrypto/man/X509_ATTRIBUTE_new.35
-rw-r--r--src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.35
-rw-r--r--src/lib/libcrypto/man/X509_CINF_new.35
-rw-r--r--src/lib/libcrypto/man/X509_CRL_get0_by_serial.35
-rw-r--r--src/lib/libcrypto/man/X509_CRL_new.35
-rw-r--r--src/lib/libcrypto/man/X509_CRL_print.35
-rw-r--r--src/lib/libcrypto/man/X509_EXTENSION_set_object.35
-rw-r--r--src/lib/libcrypto/man/X509_INFO_new.310
-rw-r--r--src/lib/libcrypto/man/X509_LOOKUP_hash_dir.35
-rw-r--r--src/lib/libcrypto/man/X509_LOOKUP_new.35
-rw-r--r--src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.35
-rw-r--r--src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.35
-rw-r--r--src/lib/libcrypto/man/X509_NAME_get_index_by_NID.35
-rw-r--r--src/lib/libcrypto/man/X509_NAME_hash.35
-rw-r--r--src/lib/libcrypto/man/X509_NAME_new.35
-rw-r--r--src/lib/libcrypto/man/X509_NAME_print_ex.35
-rw-r--r--src/lib/libcrypto/man/X509_OBJECT_get0_X509.35
-rw-r--r--src/lib/libcrypto/man/X509_PKEY_new.392
-rw-r--r--src/lib/libcrypto/man/X509_PUBKEY_new.35
-rw-r--r--src/lib/libcrypto/man/X509_PURPOSE_set.35
-rw-r--r--src/lib/libcrypto/man/X509_REQ_add1_attr.35
-rw-r--r--src/lib/libcrypto/man/X509_REQ_add_extensions.35
-rw-r--r--src/lib/libcrypto/man/X509_REQ_new.35
-rw-r--r--src/lib/libcrypto/man/X509_REQ_print_ex.36
-rw-r--r--src/lib/libcrypto/man/X509_REVOKED_new.35
-rw-r--r--src/lib/libcrypto/man/X509_SIG_get0.35
-rw-r--r--src/lib/libcrypto/man/X509_SIG_new.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_get_error.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_new.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_flags.37
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_verify.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_get_by_subject.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_load_locations.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_new.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_set1_param.35
-rw-r--r--src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.35
-rw-r--r--src/lib/libcrypto/man/X509_VERIFY_PARAM_new.35
-rw-r--r--src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.35
-rw-r--r--src/lib/libcrypto/man/X509_add1_trust_object.35
-rw-r--r--src/lib/libcrypto/man/X509_check_ca.35
-rw-r--r--src/lib/libcrypto/man/X509_check_host.35
-rw-r--r--src/lib/libcrypto/man/X509_check_issued.35
-rw-r--r--src/lib/libcrypto/man/X509_check_private_key.35
-rw-r--r--src/lib/libcrypto/man/X509_check_purpose.35
-rw-r--r--src/lib/libcrypto/man/X509_cmp.38
-rw-r--r--src/lib/libcrypto/man/X509_cmp_time.35
-rw-r--r--src/lib/libcrypto/man/X509_digest.35
-rw-r--r--src/lib/libcrypto/man/X509_find_by_subject.35
-rw-r--r--src/lib/libcrypto/man/X509_get0_notBefore.35
-rw-r--r--src/lib/libcrypto/man/X509_get0_signature.312
-rw-r--r--src/lib/libcrypto/man/X509_get1_email.35
-rw-r--r--src/lib/libcrypto/man/X509_get_extension_flags.35
-rw-r--r--src/lib/libcrypto/man/X509_get_pubkey.35
-rw-r--r--src/lib/libcrypto/man/X509_get_pubkey_parameters.35
-rw-r--r--src/lib/libcrypto/man/X509_get_serialNumber.35
-rw-r--r--src/lib/libcrypto/man/X509_get_subject_name.35
-rw-r--r--src/lib/libcrypto/man/X509_get_version.35
-rw-r--r--src/lib/libcrypto/man/X509_keyid_set1.35
-rw-r--r--src/lib/libcrypto/man/X509_load_cert_file.35
-rw-r--r--src/lib/libcrypto/man/X509_new.36
-rw-r--r--src/lib/libcrypto/man/X509_ocspid_print.35
-rw-r--r--src/lib/libcrypto/man/X509_print_ex.310
-rw-r--r--src/lib/libcrypto/man/X509_sign.317
-rw-r--r--src/lib/libcrypto/man/X509_signature_dump.35
-rw-r--r--src/lib/libcrypto/man/X509_verify_cert.35
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_add_inherit.35
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_get_range.35
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_inherits.35
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_subset.35
-rw-r--r--src/lib/libcrypto/man/X509v3_addr_validate_path.35
-rw-r--r--src/lib/libcrypto/man/X509v3_asid_add_id_or_range.35
-rw-r--r--src/lib/libcrypto/man/X509v3_get_ext_by_NID.35
-rw-r--r--src/lib/libcrypto/man/a2d_ASN1_OBJECT.35
-rw-r--r--src/lib/libcrypto/man/a2i_ipadd.35
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_NULL.35
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_OBJECT.35
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.35
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.35
-rw-r--r--src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.35
-rw-r--r--src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.35
-rw-r--r--src/lib/libcrypto/man/d2i_CMS_ContentInfo.35
-rw-r--r--src/lib/libcrypto/man/d2i_DHparams.35
-rw-r--r--src/lib/libcrypto/man/d2i_DIST_POINT.35
-rw-r--r--src/lib/libcrypto/man/d2i_DSAPublicKey.35
-rw-r--r--src/lib/libcrypto/man/d2i_ECPKParameters.35
-rw-r--r--src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.35
-rw-r--r--src/lib/libcrypto/man/d2i_GENERAL_NAME.35
-rw-r--r--src/lib/libcrypto/man/d2i_OCSP_REQUEST.35
-rw-r--r--src/lib/libcrypto/man/d2i_OCSP_RESPONSE.35
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS12.35
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS7.35
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.35
-rw-r--r--src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.35
-rw-r--r--src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.35
-rw-r--r--src/lib/libcrypto/man/d2i_POLICYINFO.35
-rw-r--r--src/lib/libcrypto/man/d2i_PrivateKey.35
-rw-r--r--src/lib/libcrypto/man/d2i_RSAPublicKey.35
-rw-r--r--src/lib/libcrypto/man/d2i_TS_REQ.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509_ALGOR.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509_CRL.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509_EXTENSION.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509_NAME.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509_REQ.35
-rw-r--r--src/lib/libcrypto/man/d2i_X509_SIG.35
-rw-r--r--src/lib/libcrypto/man/des_read_pw.35
-rw-r--r--src/lib/libcrypto/man/evp.37
-rw-r--r--src/lib/libcrypto/man/i2a_ASN1_STRING.35
-rw-r--r--src/lib/libcrypto/man/i2d_CMS_bio_stream.35
-rw-r--r--src/lib/libcrypto/man/i2d_PKCS7_bio_stream.35
-rw-r--r--src/lib/libcrypto/man/lh_new.35
-rw-r--r--src/lib/libcrypto/man/s2i_ASN1_INTEGER.317
-rw-r--r--src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.35
-rw-r--r--src/lib/libcrypto/mlkem/mlkem.c416
-rw-r--r--src/lib/libcrypto/mlkem/mlkem.h333
-rw-r--r--src/lib/libcrypto/mlkem/mlkem1024.c232
-rw-r--r--src/lib/libcrypto/mlkem/mlkem768.c239
-rw-r--r--src/lib/libcrypto/mlkem/mlkem_internal.h340
-rw-r--r--src/lib/libcrypto/mlkem/mlkem_key.c200
-rw-r--r--src/lib/libcrypto/modes/asm/ghash-x86.pl3
-rw-r--r--src/lib/libcrypto/modes/ccm128.c90
-rw-r--r--src/lib/libcrypto/modes/ctr128.c12
-rw-r--r--src/lib/libcrypto/modes/gcm128.c1065
-rw-r--r--src/lib/libcrypto/modes/gcm128_amd64.c44
-rw-r--r--src/lib/libcrypto/modes/gcm128_i386.c56
-rw-r--r--src/lib/libcrypto/modes/modes_local.h42
-rw-r--r--src/lib/libcrypto/modes/xts128.c40
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c4
-rw-r--r--src/lib/libcrypto/objects/obj_lib.c4
-rw-r--r--src/lib/libcrypto/objects/obj_mac.num3
-rw-r--r--src/lib/libcrypto/objects/objects.txt6
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_cl.c4
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c6
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_lib.c4
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_prn.c3
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_srv.c4
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_vfy.c4
-rw-r--r--src/lib/libcrypto/pem/pem.h6
-rw-r--r--src/lib/libcrypto/pem/pem_info.c177
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c4
-rw-r--r--src/lib/libcrypto/pem/pem_oth.c5
-rw-r--r--src/lib/libcrypto/pem/pem_pk8.c6
-rw-r--r--src/lib/libcrypto/pem/pem_pkey.c4
-rw-r--r--src/lib/libcrypto/pem/pem_sign.c5
-rw-r--r--src/lib/libcrypto/pem/pvkfmt.c8
-rw-r--r--src/lib/libcrypto/pkcs12/p12_add.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crt.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_init.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_kiss.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_mutl.c10
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_p8e.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_sbag.c4
-rw-r--r--src/lib/libcrypto/pkcs12/pkcs12.h4
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_asn1.c8
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_attr.c166
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_doit.c78
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_lib.c4
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_smime.c4
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7.h8
-rw-r--r--src/lib/libcrypto/rc2/rc2.c (renamed from src/lib/libcrypto/rc2/rc2_cbc.c)373
-rw-r--r--src/lib/libcrypto/rc2/rc2.h9
-rw-r--r--src/lib/libcrypto/rc2/rc2_ecb.c91
-rw-r--r--src/lib/libcrypto/rc2/rc2_skey.c142
-rw-r--r--src/lib/libcrypto/rc2/rc2cfb64.c124
-rw-r--r--src/lib/libcrypto/rc2/rc2ofb64.c111
-rw-r--r--src/lib/libcrypto/rc2/rrc2.doc219
-rw-r--r--src/lib/libcrypto/rc2/version22
-rw-r--r--src/lib/libcrypto/rc4/rc4.c269
-rw-r--r--src/lib/libcrypto/rc4/rc4.h9
-rw-r--r--src/lib/libcrypto/rsa/rsa_ameth.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_blinding.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_chk.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_gen.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_meth.c3
-rw-r--r--src/lib/libcrypto/rsa/rsa_none.c5
-rw-r--r--src/lib/libcrypto/rsa/rsa_oaep.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_pk1.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_pmeth.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_prn.c5
-rw-r--r--src/lib/libcrypto/rsa/rsa_pss.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_saos.c5
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c4
-rw-r--r--src/lib/libcrypto/rsa/rsa_x931.c5
-rw-r--r--src/lib/libcrypto/sha/asm/sha1-586.pl8
-rw-r--r--src/lib/libcrypto/sha/asm/sha512-586.pl3
-rw-r--r--src/lib/libcrypto/sha/sha1_aarch64.c34
-rw-r--r--src/lib/libcrypto/sha/sha1_aarch64_ce.S214
-rw-r--r--src/lib/libcrypto/shlib_version2
-rw-r--r--src/lib/libcrypto/sm2/sm2_crypt.c4
-rw-r--r--src/lib/libcrypto/sm2/sm2_pmeth.c4
-rw-r--r--src/lib/libcrypto/sm2/sm2_sign.c4
-rw-r--r--src/lib/libcrypto/ts/ts_asn1.c4
-rw-r--r--src/lib/libcrypto/ts/ts_conf.c3
-rw-r--r--src/lib/libcrypto/ts/ts_req_utils.c4
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_sign.c42
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_utils.c4
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_verify.c4
-rw-r--r--src/lib/libcrypto/ts/ts_verify_ctx.c4
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c4
-rw-r--r--src/lib/libcrypto/x509/by_dir.c4
-rw-r--r--src/lib/libcrypto/x509/by_file.c4
-rw-r--r--src/lib/libcrypto/x509/by_mem.c4
-rw-r--r--src/lib/libcrypto/x509/x509.h23
-rw-r--r--src/lib/libcrypto/x509/x509_addr.c4
-rw-r--r--src/lib/libcrypto/x509/x509_akey.c4
-rw-r--r--src/lib/libcrypto/x509/x509_alt.c4
-rw-r--r--src/lib/libcrypto/x509/x509_asid.c4
-rw-r--r--src/lib/libcrypto/x509/x509_att.c4
-rw-r--r--src/lib/libcrypto/x509/x509_bcons.c4
-rw-r--r--src/lib/libcrypto/x509/x509_bitst.c4
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c4
-rw-r--r--src/lib/libcrypto/x509/x509_conf.c9
-rw-r--r--src/lib/libcrypto/x509/x509_cpols.c4
-rw-r--r--src/lib/libcrypto/x509/x509_crld.c4
-rw-r--r--src/lib/libcrypto/x509/x509_extku.c4
-rw-r--r--src/lib/libcrypto/x509/x509_genn.c4
-rw-r--r--src/lib/libcrypto/x509/x509_ia5.c5
-rw-r--r--src/lib/libcrypto/x509/x509_info.c5
-rw-r--r--src/lib/libcrypto/x509/x509_lib.c4
-rw-r--r--src/lib/libcrypto/x509/x509_lu.c4
-rw-r--r--src/lib/libcrypto/x509/x509_ncons.c4
-rw-r--r--src/lib/libcrypto/x509/x509_ocsp.c4
-rw-r--r--src/lib/libcrypto/x509/x509_pcons.c4
-rw-r--r--src/lib/libcrypto/x509/x509_pmaps.c4
-rw-r--r--src/lib/libcrypto/x509/x509_policy.c7
-rw-r--r--src/lib/libcrypto/x509/x509_prn.c7
-rw-r--r--src/lib/libcrypto/x509/x509_purp.c3
-rw-r--r--src/lib/libcrypto/x509/x509_r2x.c4
-rw-r--r--src/lib/libcrypto/x509/x509_req.c4
-rw-r--r--src/lib/libcrypto/x509/x509_skey.c4
-rw-r--r--src/lib/libcrypto/x509/x509_utl.c4
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c4
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c4
-rw-r--r--src/lib/libcrypto/x509/x509_vpm.c4
-rw-r--r--src/lib/libcrypto/x509/x509name.c4
-rw-r--r--src/lib/libcrypto/x509/x509spki.c5
-rw-r--r--src/lib/libcrypto/x509/x_all.c8
-rw-r--r--src/lib/libssl/LICENSE18
-rw-r--r--src/lib/libssl/bio_ssl.c6
-rw-r--r--src/lib/libssl/hidden/ssl_namespace.h6
-rw-r--r--src/lib/libssl/man/BIO_f_ssl.35
-rw-r--r--src/lib/libssl/man/DTLSv1_listen.35
-rw-r--r--src/lib/libssl/man/OPENSSL_init_ssl.35
-rw-r--r--src/lib/libssl/man/PEM_read_SSL_SESSION.35
-rw-r--r--src/lib/libssl/man/SSL_CIPHER_get_name.37
-rw-r--r--src/lib/libssl/man/SSL_COMP_add_compression_method.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_add1_chain_cert.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_add_session.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_ctrl.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_flush_sessions.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_free.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_get0_certificate.36
-rw-r--r--src/lib/libssl/man/SSL_CTX_get_ex_new_index.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_get_verify_mode.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_load_verify_locations.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_new.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_sess_number.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_sess_set_cache_size.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_sess_set_get_cb.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_sessions.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set1_groups.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_alpn_select_cb.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_cert_store.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_cipher_list.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_client_CA_list.37
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_client_cert_cb.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_generate_session_id.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_info_callback.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_keylog_callback.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_max_cert_list.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_min_proto_version.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_mode.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_msg_callback.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_num_tickets.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_options.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_read_ahead.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_security_level.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_session_cache_mode.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_session_id_context.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_ssl_version.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_timeout.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tlsext_servername_callback.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_verify.35
-rw-r--r--src/lib/libssl/man/SSL_CTX_use_certificate.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_free.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get0_cipher.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get0_peer.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get_compress_id.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get_ex_new_index.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get_id.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get_protocol_version.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_get_time.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_has_ticket.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_is_resumable.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_new.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_print.35
-rw-r--r--src/lib/libssl/man/SSL_SESSION_set1_id_context.35
-rw-r--r--src/lib/libssl/man/SSL_accept.35
-rw-r--r--src/lib/libssl/man/SSL_alert_type_string.35
-rw-r--r--src/lib/libssl/man/SSL_clear.35
-rw-r--r--src/lib/libssl/man/SSL_connect.35
-rw-r--r--src/lib/libssl/man/SSL_copy_session_id.35
-rw-r--r--src/lib/libssl/man/SSL_do_handshake.35
-rw-r--r--src/lib/libssl/man/SSL_dup.35
-rw-r--r--src/lib/libssl/man/SSL_dup_CA_list.36
-rw-r--r--src/lib/libssl/man/SSL_export_keying_material.35
-rw-r--r--src/lib/libssl/man/SSL_free.35
-rw-r--r--src/lib/libssl/man/SSL_get_SSL_CTX.35
-rw-r--r--src/lib/libssl/man/SSL_get_certificate.35
-rw-r--r--src/lib/libssl/man/SSL_get_ciphers.35
-rw-r--r--src/lib/libssl/man/SSL_get_client_CA_list.35
-rw-r--r--src/lib/libssl/man/SSL_get_client_random.35
-rw-r--r--src/lib/libssl/man/SSL_get_current_cipher.37
-rw-r--r--src/lib/libssl/man/SSL_get_default_timeout.35
-rw-r--r--src/lib/libssl/man/SSL_get_error.35
-rw-r--r--src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.35
-rw-r--r--src/lib/libssl/man/SSL_get_ex_new_index.35
-rw-r--r--src/lib/libssl/man/SSL_get_fd.35
-rw-r--r--src/lib/libssl/man/SSL_get_finished.35
-rw-r--r--src/lib/libssl/man/SSL_get_peer_cert_chain.35
-rw-r--r--src/lib/libssl/man/SSL_get_peer_certificate.35
-rw-r--r--src/lib/libssl/man/SSL_get_rbio.35
-rw-r--r--src/lib/libssl/man/SSL_get_server_tmp_key.35
-rw-r--r--src/lib/libssl/man/SSL_get_session.35
-rw-r--r--src/lib/libssl/man/SSL_get_shared_ciphers.35
-rw-r--r--src/lib/libssl/man/SSL_get_state.35
-rw-r--r--src/lib/libssl/man/SSL_get_verify_result.35
-rw-r--r--src/lib/libssl/man/SSL_get_version.311
-rw-r--r--src/lib/libssl/man/SSL_library_init.35
-rw-r--r--src/lib/libssl/man/SSL_load_client_CA_file.35
-rw-r--r--src/lib/libssl/man/SSL_new.35
-rw-r--r--src/lib/libssl/man/SSL_num_renegotiations.35
-rw-r--r--src/lib/libssl/man/SSL_pending.35
-rw-r--r--src/lib/libssl/man/SSL_read.35
-rw-r--r--src/lib/libssl/man/SSL_read_early_data.35
-rw-r--r--src/lib/libssl/man/SSL_renegotiate.35
-rw-r--r--src/lib/libssl/man/SSL_rstate_string.35
-rw-r--r--src/lib/libssl/man/SSL_session_reused.35
-rw-r--r--src/lib/libssl/man/SSL_set1_host.35
-rw-r--r--src/lib/libssl/man/SSL_set1_param.35
-rw-r--r--src/lib/libssl/man/SSL_set_SSL_CTX.35
-rw-r--r--src/lib/libssl/man/SSL_set_bio.35
-rw-r--r--src/lib/libssl/man/SSL_set_connect_state.35
-rw-r--r--src/lib/libssl/man/SSL_set_fd.35
-rw-r--r--src/lib/libssl/man/SSL_set_max_send_fragment.35
-rw-r--r--src/lib/libssl/man/SSL_set_psk_use_session_callback.35
-rw-r--r--src/lib/libssl/man/SSL_set_session.35
-rw-r--r--src/lib/libssl/man/SSL_set_shutdown.35
-rw-r--r--src/lib/libssl/man/SSL_set_tmp_ecdh.35
-rw-r--r--src/lib/libssl/man/SSL_set_verify_result.35
-rw-r--r--src/lib/libssl/man/SSL_shutdown.35
-rw-r--r--src/lib/libssl/man/SSL_state_string.35
-rw-r--r--src/lib/libssl/man/SSL_want.35
-rw-r--r--src/lib/libssl/man/SSL_write.35
-rw-r--r--src/lib/libssl/man/d2i_SSL_SESSION.35
-rw-r--r--src/lib/libssl/pqueue.c6
-rw-r--r--src/lib/libssl/pqueue.h10
-rw-r--r--src/lib/libssl/shlib_version4
-rw-r--r--src/lib/libssl/ssl_err.c7
-rw-r--r--src/lib/libssl/ssl_lib.c9
-rw-r--r--src/lib/libssl/ssl_local.h9
-rw-r--r--src/lib/libssl/ssl_rsa.c2
-rw-r--r--src/lib/libssl/ssl_stat.c69
-rw-r--r--src/lib/libssl/ssl_tlsext.c33
-rw-r--r--src/lib/libssl/t1_lib.c147
-rw-r--r--src/lib/libssl/tls13_lib.c4
-rw-r--r--src/lib/libtls/man/tls_accept_socket.35
-rw-r--r--src/lib/libtls/man/tls_client.35
-rw-r--r--src/lib/libtls/man/tls_config_ocsp_require_stapling.35
-rw-r--r--src/lib/libtls/man/tls_config_set_protocols.36
-rw-r--r--src/lib/libtls/man/tls_config_set_session_id.35
-rw-r--r--src/lib/libtls/man/tls_config_verify.35
-rw-r--r--src/lib/libtls/man/tls_conn_version.35
-rw-r--r--src/lib/libtls/man/tls_connect.35
-rw-r--r--src/lib/libtls/man/tls_init.35
-rw-r--r--src/lib/libtls/man/tls_load_file.35
-rw-r--r--src/lib/libtls/man/tls_ocsp_process_response.35
-rw-r--r--src/lib/libtls/man/tls_read.35
-rw-r--r--src/lib/libtls/shlib_version4
-rw-r--r--src/lib/libtls/tls_server.c4
-rw-r--r--src/regress/lib/libc/Makefile10
-rw-r--r--src/regress/lib/libc/explicit_bzero/explicit_bzero.c4
-rw-r--r--src/regress/lib/libc/hash/hash_test.c6
-rw-r--r--src/regress/lib/libc/illumos/Makefile7
-rw-r--r--src/regress/lib/libc/illumos/Makefile.inc9
-rw-r--r--src/regress/lib/libc/illumos/oclo/Makefile18
-rw-r--r--src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c15
-rw-r--r--src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c4
-rw-r--r--src/regress/lib/libc/stdio/Makefile29
-rw-r--r--src/regress/lib/libc/stdio/test___fpending.c58
-rw-r--r--src/regress/lib/libc/stdio/test___freadahead.c71
-rw-r--r--src/regress/lib/libc/stdio/test___freading.c125
-rw-r--r--src/regress/lib/libc/stdio/test___freadptr.c78
-rw-r--r--src/regress/lib/libc/stdio/test___fseterr.c60
-rw-r--r--src/regress/lib/libc/stdio/test___fwriting.c83
-rw-r--r--src/regress/lib/libc/stdio/test_fflush.c345
-rw-r--r--src/regress/lib/libc/stdio/test_ungetwc.c90
-rw-r--r--src/regress/lib/libc/time/time_conversion/timetest.c158
-rw-r--r--src/regress/lib/libcrypto/aes/aes_test.c303
-rw-r--r--src/regress/lib/libcrypto/asn1/asn1time.c26
-rw-r--r--src/regress/lib/libcrypto/bio/bio_dump.c4
-rw-r--r--src/regress/lib/libcrypto/bn/bn_mul_div.c15
-rw-r--r--src/regress/lib/libcrypto/c2sp/Makefile13
-rw-r--r--src/regress/lib/libcrypto/certs/Makefile19
-rw-r--r--src/regress/lib/libcrypto/ec/Makefile9
-rw-r--r--src/regress/lib/libcrypto/ec/ec_arithmetic.c210
-rw-r--r--src/regress/lib/libcrypto/ec/ec_asn1_test.c321
-rw-r--r--src/regress/lib/libcrypto/ec/ectest.c9
-rw-r--r--src/regress/lib/libcrypto/evp/evp_pkey_cleanup.c4
-rw-r--r--src/regress/lib/libcrypto/evp/evp_test.c82
-rw-r--r--src/regress/lib/libcrypto/gcm128/gcm128test.c32
-rwxr-xr-xsrc/regress/lib/libcrypto/man/check_complete.pl11
-rw-r--r--src/regress/lib/libcrypto/md/Makefile18
-rw-r--r--src/regress/lib/libcrypto/md/md_test.c210
-rw-r--r--src/regress/lib/libcrypto/mlkem/Makefile4
-rw-r--r--src/regress/lib/libcrypto/mlkem/mlkem_iteration_tests.c180
-rw-r--r--src/regress/lib/libcrypto/mlkem/mlkem_tests.c297
-rw-r--r--src/regress/lib/libcrypto/mlkem/mlkem_tests_util.c213
-rw-r--r--src/regress/lib/libcrypto/mlkem/mlkem_tests_util.h63
-rw-r--r--src/regress/lib/libcrypto/mlkem/mlkem_unittest.c318
-rw-r--r--src/regress/lib/libcrypto/mlkem/parse_test_file.c11
-rw-r--r--src/regress/lib/libcrypto/sha/Makefile8
-rw-r--r--src/regress/lib/libcrypto/sha/sha_test.c286
-rw-r--r--src/regress/lib/libcrypto/test/test.c226
-rw-r--r--src/regress/lib/libcrypto/test/test.h137
-rw-r--r--src/regress/lib/libcrypto/test/test_util.c51
-rw-r--r--src/regress/lib/libcrypto/wycheproof/Makefile10
-rw-r--r--src/regress/lib/libcrypto/x509/Makefile10
-rw-r--r--src/regress/lib/libcrypto/x509/bettertls/Makefile8
-rw-r--r--src/regress/lib/libcrypto/x509/x509_name_test.c123
-rw-r--r--src/regress/lib/libcrypto/x509/x509name.c62
-rw-r--r--src/regress/lib/libcrypto/x509/x509name.expected3
-rw-r--r--src/regress/lib/libssl/interop/Makefile4
-rw-r--r--src/regress/lib/libssl/interop/botan/Makefile9
-rw-r--r--src/regress/lib/libssl/interop/cert/Makefile9
-rw-r--r--src/regress/lib/libssl/interop/cipher/Makefile17
-rw-r--r--src/regress/lib/libssl/interop/netcat/Makefile9
-rw-r--r--src/regress/lib/libssl/interop/openssl33/Makefile44
-rw-r--r--src/regress/lib/libssl/interop/openssl34/Makefile44
-rw-r--r--src/regress/lib/libssl/interop/openssl35/Makefile44
-rw-r--r--src/regress/lib/libssl/interop/session/Makefile9
-rw-r--r--src/regress/lib/libssl/interop/version/Makefile12
-rw-r--r--src/regress/lib/libssl/openssl-ruby/Makefile23
-rw-r--r--src/regress/lib/libssl/pqueue/Makefile7
-rw-r--r--src/regress/lib/libssl/pqueue/expected.txt3
-rw-r--r--src/regress/lib/libssl/pqueue/pq_test.c95
-rw-r--r--src/regress/lib/libssl/tlsext/tlsexttest.c41
-rw-r--r--src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py308
-rw-r--r--src/regress/lib/libtls/tls/tlstest.c139
-rw-r--r--src/usr.bin/nc/nc.114
-rw-r--r--src/usr.bin/nc/netcat.c18
-rw-r--r--src/usr.bin/nc/socks.c36
-rw-r--r--src/usr.bin/openssl/certhash.c22
-rw-r--r--src/usr.bin/openssl/cms.c38
-rw-r--r--src/usr.bin/openssl/gendsa.c5
-rw-r--r--src/usr.bin/openssl/genrsa.c5
-rw-r--r--src/usr.bin/openssl/ocsp.c12
-rw-r--r--src/usr.bin/openssl/openssl.127
-rw-r--r--src/usr.bin/openssl/openssl.c5
-rw-r--r--src/usr.bin/openssl/pkcs12.c5
-rw-r--r--src/usr.bin/openssl/pkcs8.c6
-rw-r--r--src/usr.bin/openssl/smime.c16
-rw-r--r--src/usr.bin/openssl/speed.c290
1046 files changed, 15486 insertions, 18435 deletions
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h
index 1ec1071161..3e1dbcdf6e 100644
--- a/src/lib/libc/include/thread_private.h
+++ b/src/lib/libc/include/thread_private.h
@@ -1,10 +1,13 @@
1/* $OpenBSD: thread_private.h,v 1.37 2024/08/18 02:25:51 guenther Exp $ */ 1/* $OpenBSD: thread_private.h,v 1.40 2025/08/04 01:44:33 dlg Exp $ */
2 2
3/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ 3/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
4 4
5#ifndef _THREAD_PRIVATE_H_ 5#ifndef _THREAD_PRIVATE_H_
6#define _THREAD_PRIVATE_H_ 6#define _THREAD_PRIVATE_H_
7 7
8#include <sys/types.h>
9#include <sys/gmon.h>
10
8extern int __isthreaded; 11extern int __isthreaded;
9 12
10#define _MALLOC_MUTEXES 32 13#define _MALLOC_MUTEXES 32
@@ -292,6 +295,12 @@ TAILQ_HEAD(pthread_queue, pthread);
292 295
293#ifdef FUTEX 296#ifdef FUTEX
294 297
298/*
299 * CAS based implementations
300 */
301
302#define __CMTX_CAS
303
295struct pthread_mutex { 304struct pthread_mutex {
296 volatile unsigned int lock; 305 volatile unsigned int lock;
297 int type; 306 int type;
@@ -312,6 +321,10 @@ struct pthread_rwlock {
312 321
313#else 322#else
314 323
324/*
325 * spinlock based implementations
326 */
327
315struct pthread_mutex { 328struct pthread_mutex {
316 _atomic_lock_t lock; 329 _atomic_lock_t lock;
317 struct pthread_queue lockers; 330 struct pthread_queue lockers;
@@ -336,6 +349,46 @@ struct pthread_rwlock {
336}; 349};
337#endif /* FUTEX */ 350#endif /* FUTEX */
338 351
352/* libc mutex */
353
354#define __CMTX_UNLOCKED 0
355#define __CMTX_LOCKED 1
356#define __CMTX_CONTENDED 2
357
358#ifdef __CMTX_CAS
359struct __cmtx {
360 volatile unsigned int lock;
361};
362
363#define __CMTX_INITIALIZER() { \
364 .lock = __CMTX_UNLOCKED, \
365}
366#else /* __CMTX_CAS */
367struct __cmtx {
368 _atomic_lock_t spin;
369 volatile unsigned int lock;
370};
371
372#define __CMTX_INITIALIZER() { \
373 .spin = _SPINLOCK_UNLOCKED, \
374 .lock = __CMTX_UNLOCKED, \
375}
376#endif /* __CMTX_CAS */
377
378/* libc recursive mutex */
379
380struct __rcmtx {
381 volatile pthread_t owner;
382 struct __cmtx mtx;
383 unsigned int depth;
384};
385
386#define __RCMTX_INITIALIZER() { \
387 .owner = NULL, \
388 .mtx = __CMTX_INITIALIZER(), \
389 .depth = 0, \
390}
391
339struct pthread_mutex_attr { 392struct pthread_mutex_attr {
340 int ma_type; 393 int ma_type;
341 int ma_protocol; 394 int ma_protocol;
@@ -390,6 +443,7 @@ struct pthread {
390 443
391 /* cancel received in a delayed cancel block? */ 444 /* cancel received in a delayed cancel block? */
392 int delayed_cancel; 445 int delayed_cancel;
446 struct gmonparam *gmonparam;
393}; 447};
394/* flags in pthread->flags */ 448/* flags in pthread->flags */
395#define THREAD_DONE 0x001 449#define THREAD_DONE 0x001
@@ -410,6 +464,16 @@ void _spinlock(volatile _atomic_lock_t *);
410int _spinlocktry(volatile _atomic_lock_t *); 464int _spinlocktry(volatile _atomic_lock_t *);
411void _spinunlock(volatile _atomic_lock_t *); 465void _spinunlock(volatile _atomic_lock_t *);
412 466
467void __cmtx_init(struct __cmtx *);
468int __cmtx_enter_try(struct __cmtx *);
469void __cmtx_enter(struct __cmtx *);
470void __cmtx_leave(struct __cmtx *);
471
472void __rcmtx_init(struct __rcmtx *);
473int __rcmtx_enter_try(struct __rcmtx *);
474void __rcmtx_enter(struct __rcmtx *);
475void __rcmtx_leave(struct __rcmtx *);
476
413void _rthread_debug(int, const char *, ...) 477void _rthread_debug(int, const char *, ...)
414 __attribute__((__format__ (printf, 2, 3))); 478 __attribute__((__format__ (printf, 2, 3)));
415pid_t _thread_dofork(pid_t (*_sys_fork)(void)); 479pid_t _thread_dofork(pid_t (*_sys_fork)(void));
diff --git a/src/lib/libc/net/ether_aton.3 b/src/lib/libc/net/ether_aton.3
index 98562dc44c..83fe98880c 100644
--- a/src/lib/libc/net/ether_aton.3
+++ b/src/lib/libc/net/ether_aton.3
@@ -1,8 +1,8 @@
1.\" $OpenBSD: ether_aton.3,v 1.3 2022/09/11 06:38:10 jmc Exp $ 1.\" $OpenBSD: ether_aton.3,v 1.4 2025/06/29 00:33:46 dlg Exp $
2.\" 2.\"
3.\" Written by roland@frob.com. Public domain. 3.\" Written by roland@frob.com. Public domain.
4.\" 4.\"
5.Dd $Mdocdate: September 11 2022 $ 5.Dd $Mdocdate: June 29 2025 $
6.Dt ETHER_ATON 3 6.Dt ETHER_ATON 3
7.Os 7.Os
8.Sh NAME 8.Sh NAME
@@ -19,7 +19,7 @@
19.In netinet/in.h 19.In netinet/in.h
20.In netinet/if_ether.h 20.In netinet/if_ether.h
21.Ft char * 21.Ft char *
22.Fn ether_ntoa "struct ether_addr *e" 22.Fn ether_ntoa "const struct ether_addr *e"
23.Ft struct ether_addr * 23.Ft struct ether_addr *
24.Fn ether_aton "const char *s" 24.Fn ether_aton "const char *s"
25.Ft int 25.Ft int
diff --git a/src/lib/libc/net/ethers.c b/src/lib/libc/net/ethers.c
index d62be1ca71..6edad5c5e5 100644
--- a/src/lib/libc/net/ethers.c
+++ b/src/lib/libc/net/ethers.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ethers.c,v 1.27 2019/01/25 00:19:25 millert Exp $ */ 1/* $OpenBSD: ethers.c,v 1.28 2025/06/29 00:33:46 dlg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 Todd C. Miller <millert@openbsd.org> 4 * Copyright (c) 1998 Todd C. Miller <millert@openbsd.org>
@@ -42,7 +42,7 @@
42static char * _ether_aton(const char *, struct ether_addr *); 42static char * _ether_aton(const char *, struct ether_addr *);
43 43
44char * 44char *
45ether_ntoa(struct ether_addr *e) 45ether_ntoa(const struct ether_addr *e)
46{ 46{
47 static char a[] = "xx:xx:xx:xx:xx:xx"; 47 static char a[] = "xx:xx:xx:xx:xx:xx";
48 48
diff --git a/src/lib/libc/net/gai_strerror.3 b/src/lib/libc/net/gai_strerror.3
index d271f492c5..93d11aad09 100644
--- a/src/lib/libc/net/gai_strerror.3
+++ b/src/lib/libc/net/gai_strerror.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: gai_strerror.3,v 1.10 2017/05/03 01:58:33 deraadt Exp $ 1.\" $OpenBSD: gai_strerror.3,v 1.11 2025/06/13 18:34:00 schwarze Exp $
2.\" $KAME: gai_strerror.3,v 1.1 2005/01/05 03:04:47 itojun Exp $ 2.\" $KAME: gai_strerror.3,v 1.1 2005/01/05 03:04:47 itojun Exp $
3.\" 3.\"
4.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 4.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
@@ -16,7 +16,7 @@
16.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17.\" PERFORMANCE OF THIS SOFTWARE. 17.\" PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: May 3 2017 $ 19.Dd $Mdocdate: June 13 2025 $
20.Dt GAI_STRERROR 3 20.Dt GAI_STRERROR 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -26,7 +26,7 @@
26.In sys/types.h 26.In sys/types.h
27.In sys/socket.h 27.In sys/socket.h
28.In netdb.h 28.In netdb.h
29.Ft "const char *" 29.Ft const char *
30.Fn gai_strerror "int ecode" 30.Fn gai_strerror "int ecode"
31.Sh DESCRIPTION 31.Sh DESCRIPTION
32The 32The
diff --git a/src/lib/libc/net/if_indextoname.3 b/src/lib/libc/net/if_indextoname.3
index 25d2a2722f..9d00d66bd5 100644
--- a/src/lib/libc/net/if_indextoname.3
+++ b/src/lib/libc/net/if_indextoname.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: if_indextoname.3,v 1.16 2015/11/21 07:48:10 jmc Exp $ 1.\" $OpenBSD: if_indextoname.3,v 1.17 2025/06/13 18:34:00 schwarze Exp $
2.\" Copyright (c) 1983, 1991, 1993 2.\" Copyright (c) 1983, 1991, 1993
3.\" The Regents of the University of California. All rights reserved. 3.\" The Regents of the University of California. All rights reserved.
4.\" 4.\"
@@ -28,7 +28,7 @@
28.\" 28.\"
29.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 29.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93
30.\" 30.\"
31.Dd $Mdocdate: November 21 2015 $ 31.Dd $Mdocdate: June 13 2025 $
32.Dt IF_NAMETOINDEX 3 32.Dt IF_NAMETOINDEX 3
33.Os 33.Os
34.Sh NAME 34.Sh NAME
@@ -41,13 +41,13 @@
41.In sys/types.h 41.In sys/types.h
42.In sys/socket.h 42.In sys/socket.h
43.In net/if.h 43.In net/if.h
44.Ft "unsigned int" 44.Ft unsigned int
45.Fn if_nametoindex "const char *ifname" 45.Fn if_nametoindex "const char *ifname"
46.Ft "char *" 46.Ft char *
47.Fn if_indextoname "unsigned int ifindex" "char *ifname" 47.Fn if_indextoname "unsigned int ifindex" "char *ifname"
48.Ft "struct if_nameindex *" 48.Ft struct if_nameindex *
49.Fn if_nameindex "void" 49.Fn if_nameindex "void"
50.Ft "void" 50.Ft void
51.Fn if_freenameindex "struct if_nameindex *ptr" 51.Fn if_freenameindex "struct if_nameindex *ptr"
52.Sh DESCRIPTION 52.Sh DESCRIPTION
53These functions map interface indexes to interface names (such as 53These functions map interface indexes to interface names (such as
diff --git a/src/lib/libc/net/inet6_opt_init.3 b/src/lib/libc/net/inet6_opt_init.3
index 41ba842166..87244507a9 100644
--- a/src/lib/libc/net/inet6_opt_init.3
+++ b/src/lib/libc/net/inet6_opt_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: inet6_opt_init.3,v 1.8 2022/03/31 17:27:16 naddy Exp $ 1.\" $OpenBSD: inet6_opt_init.3,v 1.9 2025/06/13 18:34:00 schwarze Exp $
2.\" $KAME: inet6_opt_init.3,v 1.7 2004/12/27 05:08:23 itojun Exp $ 2.\" $KAME: inet6_opt_init.3,v 1.7 2004/12/27 05:08:23 itojun Exp $
3.\" 3.\"
4.\" Copyright (C) 2004 WIDE Project. 4.\" Copyright (C) 2004 WIDE Project.
@@ -28,7 +28,7 @@
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE. 29.\" SUCH DAMAGE.
30.\" 30.\"
31.Dd $Mdocdate: March 31 2022 $ 31.Dd $Mdocdate: June 13 2025 $
32.Dt INET6_OPT_INIT 3 32.Dt INET6_OPT_INIT 3
33.Os 33.Os
34.\" 34.\"
@@ -44,19 +44,19 @@
44.\" 44.\"
45.Sh SYNOPSIS 45.Sh SYNOPSIS
46.In netinet/in.h 46.In netinet/in.h
47.Ft "int" 47.Ft int
48.Fn inet6_opt_init "void *extbuf" "socklen_t extlen" 48.Fn inet6_opt_init "void *extbuf" "socklen_t extlen"
49.Ft "int" 49.Ft int
50.Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t len" "u_int8_t align" "void **databufp" 50.Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t len" "u_int8_t align" "void **databufp"
51.Ft "int" 51.Ft int
52.Fn inet6_opt_finish "void *extbuf" "socklen_t extlen" "int offset" 52.Fn inet6_opt_finish "void *extbuf" "socklen_t extlen" "int offset"
53.Ft "int" 53.Ft int
54.Fn inet6_opt_set_val "void *databuf" "int offset" "void *val" "socklen_t vallen" 54.Fn inet6_opt_set_val "void *databuf" "int offset" "void *val" "socklen_t vallen"
55.Ft "int" 55.Ft int
56.Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t *typep" "socklen_t *lenp" "void **databufp" 56.Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t *typep" "socklen_t *lenp" "void **databufp"
57.Ft "int" 57.Ft int
58.Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t *lenp" "void **databufp" 58.Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t *lenp" "void **databufp"
59.Ft "int" 59.Ft int
60.Fn inet6_opt_get_val "void *databuf" "socklen_t offset" "void *val" "socklen_t vallen" 60.Fn inet6_opt_get_val "void *databuf" "socklen_t offset" "void *val" "socklen_t vallen"
61.\" 61.\"
62.Sh DESCRIPTION 62.Sh DESCRIPTION
diff --git a/src/lib/libc/net/inet6_rth_space.3 b/src/lib/libc/net/inet6_rth_space.3
index c40b45057e..7304266fe1 100644
--- a/src/lib/libc/net/inet6_rth_space.3
+++ b/src/lib/libc/net/inet6_rth_space.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: inet6_rth_space.3,v 1.8 2022/03/31 17:27:16 naddy Exp $ 1.\" $OpenBSD: inet6_rth_space.3,v 1.9 2025/06/13 18:34:00 schwarze Exp $
2.\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $ 2.\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $
3.\" 3.\"
4.\" Copyright (C) 2004 WIDE Project. 4.\" Copyright (C) 2004 WIDE Project.
@@ -28,7 +28,7 @@
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE. 29.\" SUCH DAMAGE.
30.\" 30.\"
31.Dd $Mdocdate: March 31 2022 $ 31.Dd $Mdocdate: June 13 2025 $
32.Dt INET6_RTH_SPACE 3 32.Dt INET6_RTH_SPACE 3
33.Os 33.Os
34.\" 34.\"
@@ -45,7 +45,7 @@
45.In netinet/in.h 45.In netinet/in.h
46.Ft socklen_t 46.Ft socklen_t
47.Fn inet6_rth_space "int" "int" 47.Fn inet6_rth_space "int" "int"
48.Ft "void *" 48.Ft void *
49.Fn inet6_rth_init "void *" "socklen_t" "int" "int" 49.Fn inet6_rth_init "void *" "socklen_t" "int" "int"
50.Ft int 50.Ft int
51.Fn inet6_rth_add "void *" "const struct in6_addr *" 51.Fn inet6_rth_add "void *" "const struct in6_addr *"
@@ -53,7 +53,7 @@
53.Fn inet6_rth_reverse "const void *" "void *" 53.Fn inet6_rth_reverse "const void *" "void *"
54.Ft int 54.Ft int
55.Fn inet6_rth_segments "const void *" 55.Fn inet6_rth_segments "const void *"
56.Ft "struct in6_addr *" 56.Ft struct in6_addr *
57.Fn inet6_rth_getaddr "const void *" "int" 57.Fn inet6_rth_getaddr "const void *" "int"
58.\" 58.\"
59.Sh DESCRIPTION 59.Sh DESCRIPTION
diff --git a/src/lib/libc/stdlib/exit.3 b/src/lib/libc/stdlib/exit.3
index 22acade86c..ccb416ee82 100644
--- a/src/lib/libc/stdlib/exit.3
+++ b/src/lib/libc/stdlib/exit.3
@@ -29,9 +29,9 @@
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" $OpenBSD: exit.3,v 1.18 2024/08/30 03:44:48 guenther Exp $ 32.\" $OpenBSD: exit.3,v 1.19 2025/06/03 14:15:53 yasuoka Exp $
33.\" 33.\"
34.Dd $Mdocdate: August 30 2024 $ 34.Dd $Mdocdate: June 3 2025 $
35.Dt EXIT 3 35.Dt EXIT 3
36.Os 36.Os
37.Sh NAME 37.Sh NAME
@@ -54,9 +54,7 @@ Call the functions registered with the
54.Xr atexit 3 54.Xr atexit 3
55function, in the reverse order of their registration. 55function, in the reverse order of their registration.
56.It 56.It
57Flush all open output streams. 57Flush and close all open streams.
58.It
59Close all open streams.
60.It 58.It
61Unlink all files created with the 59Unlink all files created with the
62.Xr tmpfile 3 60.Xr tmpfile 3
@@ -79,6 +77,7 @@ function never returns.
79.Sh SEE ALSO 77.Sh SEE ALSO
80.Xr _exit 2 , 78.Xr _exit 2 ,
81.Xr atexit 3 , 79.Xr atexit 3 ,
80.Xr fflush 3 ,
82.Xr intro 3 , 81.Xr intro 3 ,
83.Xr sysexits 3 , 82.Xr sysexits 3 ,
84.Xr tmpfile 3 83.Xr tmpfile 3
@@ -86,7 +85,7 @@ function never returns.
86The 85The
87.Fn exit 86.Fn exit
88function conforms to 87function conforms to
89.St -isoC-99 . 88.St -p1003.1-2024 .
90.Sh HISTORY 89.Sh HISTORY
91An 90An
92.Fn exit 91.Fn exit
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
index bea5575bf8..ee13b01bd4 100644
--- a/src/lib/libc/stdlib/malloc.3
+++ b/src/lib/libc/stdlib/malloc.3
@@ -30,9 +30,9 @@
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE. 31.\" SUCH DAMAGE.
32.\" 32.\"
33.\" $OpenBSD: malloc.3,v 1.142 2024/08/03 20:09:24 guenther Exp $ 33.\" $OpenBSD: malloc.3,v 1.147 2025/06/04 00:38:01 yasuoka Exp $
34.\" 34.\"
35.Dd $Mdocdate: August 3 2024 $ 35.Dd $Mdocdate: June 4 2025 $
36.Dt MALLOC 3 36.Dt MALLOC 3
37.Os 37.Os
38.Sh NAME 38.Sh NAME
@@ -69,7 +69,8 @@
69.Fn malloc_conceal "size_t size" 69.Fn malloc_conceal "size_t size"
70.Ft void * 70.Ft void *
71.Fn calloc_conceal "size_t nmemb" "size_t size" 71.Fn calloc_conceal "size_t nmemb" "size_t size"
72.Vt char *malloc_options ; 72.Vt const char * const
73.Va malloc_options ;
73.Sh DESCRIPTION 74.Sh DESCRIPTION
74The standard functions 75The standard functions
75.Fn malloc , 76.Fn malloc ,
@@ -268,7 +269,15 @@ next checks the environment for a variable called
268and finally looks at the global variable 269and finally looks at the global variable
269.Va malloc_options 270.Va malloc_options
270in the program. 271in the program.
271Each is scanned for the flags documented below. 272Since
273.Fn malloc
274might already get called before the beginning of
275.Fn main ,
276either initialize
277.Va malloc_options
278to a string literal at file scope or do not declare it at all.
279.Pp
280Each of the three strings is scanned for the flags documented below.
272Unless otherwise noted uppercase means on, lowercase means off. 281Unless otherwise noted uppercase means on, lowercase means off.
273During initialization, flags occurring later modify the behaviour 282During initialization, flags occurring later modify the behaviour
274that was requested by flags processed earlier. 283that was requested by flags processed earlier.
@@ -363,18 +372,9 @@ Use with
363to get a verbose dump of malloc's internal state. 372to get a verbose dump of malloc's internal state.
364.It Cm X 373.It Cm X
365.Dq xmalloc . 374.Dq xmalloc .
366Rather than return failure, 375Rather than return failure to handle out-of-memory conditions gracefully,
367.Xr abort 3 376.Xr abort 3
368the program with a diagnostic message on stderr. 377the program with a diagnostic message on stderr.
369It is the intention that this option be set at compile time by
370including in the source:
371.Bd -literal -offset indent
372extern char *malloc_options;
373malloc_options = "X";
374.Ed
375.Pp
376Note that this will cause code that is supposed to handle
377out-of-memory conditions gracefully to abort instead.
378.It Cm < 378.It Cm <
379.Dq Halve the cache size . 379.Dq Halve the cache size .
380Decrease the size of the free page cache by a factor of two. 380Decrease the size of the free page cache by a factor of two.
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index cad8e5d6a1..c6261d87c5 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.297 2024/09/20 02:00:46 jsg Exp $ */ 1/* $OpenBSD: malloc.c,v 1.299 2025/06/12 16:07:09 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net>
4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> 4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -31,7 +31,6 @@
31#include <sys/queue.h> 31#include <sys/queue.h>
32#include <sys/mman.h> 32#include <sys/mman.h>
33#include <sys/sysctl.h> 33#include <sys/sysctl.h>
34#include <uvm/uvmexp.h>
35#include <errno.h> 34#include <errno.h>
36#include <stdarg.h> 35#include <stdarg.h>
37#include <stdint.h> 36#include <stdint.h>
@@ -264,7 +263,8 @@ static union {
264 __attribute__((section(".openbsd.mutable"))); 263 __attribute__((section(".openbsd.mutable")));
265#define mopts malloc_readonly.mopts 264#define mopts malloc_readonly.mopts
266 265
267char *malloc_options; /* compile-time options */ 266/* compile-time options */
267const char *const malloc_options __attribute__((weak));
268 268
269static __dead void wrterror(struct dir_info *d, char *msg, ...) 269static __dead void wrterror(struct dir_info *d, char *msg, ...)
270 __attribute__((__format__ (printf, 2, 3))); 270 __attribute__((__format__ (printf, 2, 3)));
@@ -501,7 +501,8 @@ omalloc_parseopt(char opt)
501static void 501static void
502omalloc_init(void) 502omalloc_init(void)
503{ 503{
504 char *p, *q, b[16]; 504 const char *p;
505 char *q, b[16];
505 int i, j; 506 int i, j;
506 const int mib[2] = { CTL_VM, VM_MALLOC_CONF }; 507 const int mib[2] = { CTL_VM, VM_MALLOC_CONF };
507 size_t sb; 508 size_t sb;
diff --git a/src/lib/libc/stdlib/mkstemp.c b/src/lib/libc/stdlib/mkstemp.c
index 75a9d27d1a..760575005f 100644
--- a/src/lib/libc/stdlib/mkstemp.c
+++ b/src/lib/libc/stdlib/mkstemp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mkstemp.c,v 1.1 2024/01/19 19:45:02 millert Exp $ */ 1/* $OpenBSD: mkstemp.c,v 1.2 2025/08/04 04:59:31 guenther Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Todd C. Miller 3 * Copyright (c) 2024 Todd C. Miller
4 * 4 *
@@ -20,7 +20,8 @@
20#include <fcntl.h> 20#include <fcntl.h>
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23#define MKOSTEMP_FLAGS (O_APPEND | O_CLOEXEC | O_DSYNC | O_RSYNC | O_SYNC) 23#define MKOSTEMP_FLAGS \
24 (O_APPEND | O_CLOEXEC | O_CLOFORK | O_DSYNC | O_RSYNC | O_SYNC)
24 25
25static int 26static int
26mkstemp_cb(const char *path, int flags) 27mkstemp_cb(const char *path, int flags)
diff --git a/src/lib/libc/stdlib/mktemp.3 b/src/lib/libc/stdlib/mktemp.3
index 83b7c9eb30..a967358164 100644
--- a/src/lib/libc/stdlib/mktemp.3
+++ b/src/lib/libc/stdlib/mktemp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: mktemp.3,v 1.2 2024/03/01 21:30:40 millert Exp $ 1.\" $OpenBSD: mktemp.3,v 1.4 2025/08/04 14:11:37 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 1989, 1991, 1993 3.\" Copyright (c) 1989, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -27,17 +27,17 @@
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
29.\" 29.\"
30.Dd $Mdocdate: March 1 2024 $ 30.Dd $Mdocdate: August 4 2025 $
31.Dt MKTEMP 3 31.Dt MKTEMP 3
32.Os 32.Os
33.Sh NAME 33.Sh NAME
34.Nm mktemp , 34.Nm mktemp ,
35.Nm mkstemp , 35.Nm mkstemp ,
36.Nm mkostemp ,
37.Nm mkstemps , 36.Nm mkstemps ,
38.Nm mkostemps ,
39.Nm mkdtemp , 37.Nm mkdtemp ,
40.Nm mkdtemps 38.Nm mkdtemps ,
39.Nm mkostemp ,
40.Nm mkostemps
41.Nd make temporary file name (unique) 41.Nd make temporary file name (unique)
42.Sh SYNOPSIS 42.Sh SYNOPSIS
43.In stdlib.h 43.In stdlib.h
@@ -119,6 +119,8 @@ system call:
119Append on each write. 119Append on each write.
120.It Dv O_CLOEXEC 120.It Dv O_CLOEXEC
121Set the close-on-exec flag on the new file descriptor. 121Set the close-on-exec flag on the new file descriptor.
122.It Dv O_CLOFORK
123Set the close-on-fork flag on the new file descriptor.
122.It Dv O_SYNC 124.It Dv O_SYNC
123Perform synchronous I/O operations. 125Perform synchronous I/O operations.
124.El 126.El
@@ -163,8 +165,8 @@ functions return a pointer to the template on success and
163on failure. 165on failure.
164The 166The
165.Fn mkstemp , 167.Fn mkstemp ,
166.Fn mkostemp ,
167.Fn mkstemps , 168.Fn mkstemps ,
169.Fn mkostemp ,
168and 170and
169.Fn mkostemps 171.Fn mkostemps
170functions return \-1 if no suitable file could be created. 172functions return \-1 if no suitable file could be created.
@@ -253,9 +255,9 @@ of
253The 255The
254.Fn mktemp , 256.Fn mktemp ,
255.Fn mkstemp , 257.Fn mkstemp ,
256.Fn mkostemp , 258.Fn mkdtemp ,
257and 259and
258.Fn mkdtemp 260.Fn mkostemp
259functions may set 261functions may set
260.Va errno 262.Va errno
261to one of the following values: 263to one of the following values:
@@ -318,8 +320,8 @@ function.
318.Pp 320.Pp
319The 321The
320.Fn mkstemp , 322.Fn mkstemp ,
321.Fn mkostemp ,
322.Fn mkstemps , 323.Fn mkstemps ,
324.Fn mkostemp ,
323and 325and
324.Fn mkostemps 326.Fn mkostemps
325functions may also set 327functions may also set
@@ -345,18 +347,16 @@ function.
345.Xr tmpnam 3 347.Xr tmpnam 3
346.Sh STANDARDS 348.Sh STANDARDS
347The 349The
348.Fn mkdtemp 350.Fn mkstemp ,
351.Fn mkdtemp ,
349and 352and
350.Fn mkstemp 353.Fn mkostemp
351functions conform to the 354functions conform to the
352.St -p1003.1-2008 355.St -p1003.1-2024
353specification. 356specification.
354The ability to specify more than six 357The ability to specify more than six
355.Em X Ns s 358.Em X Ns s
356is an extension to that standard. 359is an extension to that standard.
357The
358.Fn mkostemp
359function is expected to conform to a future revision of that standard.
360.Pp 360.Pp
361The 361The
362.Fn mktemp 362.Fn mktemp
@@ -368,9 +368,9 @@ it is no longer a part of the standard.
368.Pp 368.Pp
369The 369The
370.Fn mkstemps , 370.Fn mkstemps ,
371.Fn mkostemps , 371.Fn mkdtemps ,
372and 372and
373.Fn mkdtemps 373.Fn mkostemps
374functions are non-standard and should not be used if portability is required. 374functions are non-standard and should not be used if portability is required.
375.Sh HISTORY 375.Sh HISTORY
376A 376A
@@ -378,14 +378,14 @@ A
378function appeared in 378function appeared in
379.At v7 . 379.At v7 .
380The 380The
381.Fn mkdtemp
382function appeared in
383.Ox 2.2 .
384The
385.Fn mkstemp 381.Fn mkstemp
386function appeared in 382function appeared in
387.Bx 4.3 . 383.Bx 4.3 .
388The 384The
385.Fn mkdtemp
386function appeared in
387.Ox 2.2 .
388The
389.Fn mkstemps 389.Fn mkstemps
390function appeared in 390function appeared in
391.Ox 2.3 . 391.Ox 2.3 .
diff --git a/src/lib/libc/stdlib/ptsname.3 b/src/lib/libc/stdlib/ptsname.3
index 98705528f5..eea36a5a02 100644
--- a/src/lib/libc/stdlib/ptsname.3
+++ b/src/lib/libc/stdlib/ptsname.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ptsname.3,v 1.2 2012/12/04 18:42:16 millert Exp $ 1.\" $OpenBSD: ptsname.3,v 1.3 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2002 The FreeBSD Project, Inc. 3.\" Copyright (c) 2002 The FreeBSD Project, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
@@ -32,7 +32,7 @@
32.\" 32.\"
33.\" $FreeBSD: head/lib/libc/stdlib/ptsname.3 240412 2012-09-12 17:54:09Z emaste $ 33.\" $FreeBSD: head/lib/libc/stdlib/ptsname.3 240412 2012-09-12 17:54:09Z emaste $
34.\" 34.\"
35.Dd $Mdocdate: December 4 2012 $ 35.Dd $Mdocdate: June 13 2025 $
36.Dt PTSNAME 3 36.Dt PTSNAME 3
37.Os 37.Os
38.Sh NAME 38.Sh NAME
@@ -44,7 +44,7 @@
44.In stdlib.h 44.In stdlib.h
45.Ft int 45.Ft int
46.Fn grantpt "int fildes" 46.Fn grantpt "int fildes"
47.Ft "char *" 47.Ft char *
48.Fn ptsname "int fildes" 48.Fn ptsname "int fildes"
49.Ft int 49.Ft int
50.Fn unlockpt "int fildes" 50.Fn unlockpt "int fildes"
diff --git a/src/lib/libc/stdlib/rand48.3 b/src/lib/libc/stdlib/rand48.3
index fa7a7179bc..02e1999db9 100644
--- a/src/lib/libc/stdlib/rand48.3
+++ b/src/lib/libc/stdlib/rand48.3
@@ -9,9 +9,9 @@
9.\" of any kind. I shall in no event be liable for anything that happens 9.\" of any kind. I shall in no event be liable for anything that happens
10.\" to anyone/anything when using this software. 10.\" to anyone/anything when using this software.
11.\" 11.\"
12.\" $OpenBSD: rand48.3,v 1.21 2019/12/20 19:16:40 tb Exp $ 12.\" $OpenBSD: rand48.3,v 1.22 2025/06/13 18:34:00 schwarze Exp $
13.\" 13.\"
14.Dd $Mdocdate: December 20 2019 $ 14.Dd $Mdocdate: June 13 2025 $
15.Dt DRAND48 3 15.Dt DRAND48 3
16.Os 16.Os
17.Sh NAME 17.Sh NAME
@@ -46,9 +46,9 @@
46.Fn srand48 "long seed" 46.Fn srand48 "long seed"
47.Ft void 47.Ft void
48.Fn srand48_deterministic "long seed" 48.Fn srand48_deterministic "long seed"
49.Ft "unsigned short *" 49.Ft unsigned short *
50.Fn seed48 "unsigned short xseed[3]" 50.Fn seed48 "unsigned short xseed[3]"
51.Ft "unsigned short *" 51.Ft unsigned short *
52.Fn seed48_deterministic "unsigned short xseed[3]" 52.Fn seed48_deterministic "unsigned short xseed[3]"
53.Ft void 53.Ft void
54.Fn lcong48 "unsigned short p[7]" 54.Fn lcong48 "unsigned short p[7]"
diff --git a/src/lib/libc/stdlib/realpath.3 b/src/lib/libc/stdlib/realpath.3
index 1dec10fef4..1f932e3bb5 100644
--- a/src/lib/libc/stdlib/realpath.3
+++ b/src/lib/libc/stdlib/realpath.3
@@ -28,9 +28,9 @@
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE. 29.\" SUCH DAMAGE.
30.\" 30.\"
31.\" $OpenBSD: realpath.3,v 1.26 2021/10/13 15:04:53 kn Exp $ 31.\" $OpenBSD: realpath.3,v 1.27 2025/06/13 18:34:00 schwarze Exp $
32.\" 32.\"
33.Dd $Mdocdate: October 13 2021 $ 33.Dd $Mdocdate: June 13 2025 $
34.Dt REALPATH 3 34.Dt REALPATH 3
35.Os 35.Os
36.Sh NAME 36.Sh NAME
@@ -39,7 +39,7 @@
39.Sh SYNOPSIS 39.Sh SYNOPSIS
40.In limits.h 40.In limits.h
41.In stdlib.h 41.In stdlib.h
42.Ft "char *" 42.Ft char *
43.Fn realpath "const char *pathname" "char *resolved" 43.Fn realpath "const char *pathname" "char *resolved"
44.Sh DESCRIPTION 44.Sh DESCRIPTION
45The 45The
diff --git a/src/lib/libc/string/memmem.3 b/src/lib/libc/string/memmem.3
index de62d738de..eeb621f8f6 100644
--- a/src/lib/libc/string/memmem.3
+++ b/src/lib/libc/string/memmem.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: memmem.3,v 1.4 2024/08/03 20:13:23 guenther Exp $ 1.\" $OpenBSD: memmem.3,v 1.5 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com> 3.\" Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com>
4.\" 4.\"
@@ -26,7 +26,7 @@
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE. 27.\" SUCH DAMAGE.
28.\" 28.\"
29.Dd $Mdocdate: August 3 2024 $ 29.Dd $Mdocdate: June 13 2025 $
30.Dt MEMMEM 3 30.Dt MEMMEM 3
31.Os 31.Os
32.Sh NAME 32.Sh NAME
@@ -34,7 +34,7 @@
34.Nd locate a byte substring in a byte string 34.Nd locate a byte substring in a byte string
35.Sh SYNOPSIS 35.Sh SYNOPSIS
36.In string.h 36.In string.h
37.Ft "void *" 37.Ft void *
38.Fo memmem 38.Fo memmem
39.Fa "const void *big" "size_t big_len" 39.Fa "const void *big" "size_t big_len"
40.Fa "const void *little" "size_t little_len" 40.Fa "const void *little" "size_t little_len"
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile
index db3bc767d9..459b0c9235 100644
--- a/src/lib/libcrypto/Makefile
+++ b/src/lib/libcrypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.231 2024/12/19 23:56:32 tb Exp $ 1# $OpenBSD: Makefile,v 1.242 2025/08/14 15:48:48 beck Exp $
2 2
3LIB= crypto 3LIB= crypto
4LIBREBUILD=y 4LIBREBUILD=y
@@ -25,6 +25,7 @@ CFLAGS+= -DLIBRESSL_NAMESPACE -DLIBRESSL_CRYPTO_NAMESPACE
25CFLAGS+= -DHAVE_FUNOPEN 25CFLAGS+= -DHAVE_FUNOPEN
26 26
27CFLAGS+= -I${LCRYPTO_SRC} 27CFLAGS+= -I${LCRYPTO_SRC}
28CFLAGS+= -I${LCRYPTO_SRC}/aes
28CFLAGS+= -I${LCRYPTO_SRC}/arch/${MACHINE_CPU} 29CFLAGS+= -I${LCRYPTO_SRC}/arch/${MACHINE_CPU}
29CFLAGS+= -I${LCRYPTO_SRC}/asn1 30CFLAGS+= -I${LCRYPTO_SRC}/asn1
30CFLAGS+= -I${LCRYPTO_SRC}/bio 31CFLAGS+= -I${LCRYPTO_SRC}/bio
@@ -67,7 +68,6 @@ SRCS+= crypto_memory.c
67# aes/ 68# aes/
68SRCS+= aes.c 69SRCS+= aes.c
69SRCS+= aes_core.c 70SRCS+= aes_core.c
70SRCS+= aes_ige.c
71 71
72# asn1/ 72# asn1/
73SRCS+= a_bitstr.c 73SRCS+= a_bitstr.c
@@ -119,10 +119,8 @@ SRCS+= x_attrib.c
119SRCS+= x_bignum.c 119SRCS+= x_bignum.c
120SRCS+= x_crl.c 120SRCS+= x_crl.c
121SRCS+= x_exten.c 121SRCS+= x_exten.c
122SRCS+= x_info.c
123SRCS+= x_long.c 122SRCS+= x_long.c
124SRCS+= x_name.c 123SRCS+= x_name.c
125SRCS+= x_pkey.c
126SRCS+= x_pubkey.c 124SRCS+= x_pubkey.c
127SRCS+= x_req.c 125SRCS+= x_req.c
128SRCS+= x_sig.c 126SRCS+= x_sig.c
@@ -152,13 +150,13 @@ SRCS+= bss_conn.c
152SRCS+= bss_dgram.c 150SRCS+= bss_dgram.c
153SRCS+= bss_fd.c 151SRCS+= bss_fd.c
154SRCS+= bss_file.c 152SRCS+= bss_file.c
155SRCS+= bss_log.c
156SRCS+= bss_mem.c 153SRCS+= bss_mem.c
157SRCS+= bss_null.c 154SRCS+= bss_null.c
158SRCS+= bss_sock.c 155SRCS+= bss_sock.c
159 156
160# bn/ 157# bn/
161SRCS+= bn_add.c 158SRCS+= bn_add.c
159SRCS+= bn_add_sub.c
162SRCS+= bn_bpsw.c 160SRCS+= bn_bpsw.c
163SRCS+= bn_const.c 161SRCS+= bn_const.c
164SRCS+= bn_convert.c 162SRCS+= bn_convert.c
@@ -172,6 +170,7 @@ SRCS+= bn_kron.c
172SRCS+= bn_lib.c 170SRCS+= bn_lib.c
173SRCS+= bn_mod.c 171SRCS+= bn_mod.c
174SRCS+= bn_mod_sqrt.c 172SRCS+= bn_mod_sqrt.c
173SRCS+= bn_mod_words.c
175SRCS+= bn_mont.c 174SRCS+= bn_mont.c
176SRCS+= bn_mul.c 175SRCS+= bn_mul.c
177SRCS+= bn_prime.c 176SRCS+= bn_prime.c
@@ -281,11 +280,13 @@ SRCS+= ec_asn1.c
281SRCS+= ec_convert.c 280SRCS+= ec_convert.c
282SRCS+= ec_curve.c 281SRCS+= ec_curve.c
283SRCS+= ec_err.c 282SRCS+= ec_err.c
283SRCS+= ec_field.c
284SRCS+= ec_key.c 284SRCS+= ec_key.c
285SRCS+= ec_lib.c 285SRCS+= ec_lib.c
286SRCS+= ec_mult.c 286SRCS+= ec_mult.c
287SRCS+= ec_pmeth.c 287SRCS+= ec_pmeth.c
288SRCS+= eck_prn.c 288SRCS+= eck_prn.c
289SRCS+= ecp_hp_methods.c
289SRCS+= ecp_methods.c 290SRCS+= ecp_methods.c
290SRCS+= ecx_methods.c 291SRCS+= ecx_methods.c
291 292
@@ -373,8 +374,10 @@ SRCS+= md4.c
373SRCS+= md5.c 374SRCS+= md5.c
374 375
375# mlkem/ 376# mlkem/
377SRCS+= mlkem.c
376SRCS+= mlkem768.c 378SRCS+= mlkem768.c
377SRCS+= mlkem1024.c 379SRCS+= mlkem1024.c
380SRCS+= mlkem_key.c
378 381
379# modes/ 382# modes/
380SRCS+= cbc128.c 383SRCS+= cbc128.c
@@ -450,11 +453,7 @@ SRCS+= rand_lib.c
450SRCS+= randfile.c 453SRCS+= randfile.c
451 454
452# rc2/ 455# rc2/
453SRCS+= rc2_cbc.c 456SRCS+= rc2.c
454SRCS+= rc2_ecb.c
455SRCS+= rc2_skey.c
456SRCS+= rc2cfb64.c
457SRCS+= rc2ofb64.c
458 457
459# rc4/ 458# rc4/
460SRCS+= rc4.c 459SRCS+= rc4.c
@@ -671,6 +670,7 @@ HDRS=\
671 ${LCRYPTO_SRC}/lhash/lhash.h \ 670 ${LCRYPTO_SRC}/lhash/lhash.h \
672 ${LCRYPTO_SRC}/md4/md4.h \ 671 ${LCRYPTO_SRC}/md4/md4.h \
673 ${LCRYPTO_SRC}/md5/md5.h \ 672 ${LCRYPTO_SRC}/md5/md5.h \
673 ${LCRYPTO_SRC}/mlkem/mlkem.h \
674 ${LCRYPTO_SRC}/modes/modes.h \ 674 ${LCRYPTO_SRC}/modes/modes.h \
675 ${LCRYPTO_SRC}/objects/objects.h \ 675 ${LCRYPTO_SRC}/objects/objects.h \
676 ${LCRYPTO_SRC}/ocsp/ocsp.h \ 676 ${LCRYPTO_SRC}/ocsp/ocsp.h \
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index e259430bbf..2aae617f0a 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -308,7 +308,6 @@ BIO_s_connect
308BIO_s_datagram 308BIO_s_datagram
309BIO_s_fd 309BIO_s_fd
310BIO_s_file 310BIO_s_file
311BIO_s_log
312BIO_s_mem 311BIO_s_mem
313BIO_s_null 312BIO_s_null
314BIO_s_socket 313BIO_s_socket
@@ -1664,9 +1663,7 @@ PEM_ASN1_write_bio
1664PEM_SignFinal 1663PEM_SignFinal
1665PEM_SignInit 1664PEM_SignInit
1666PEM_SignUpdate 1665PEM_SignUpdate
1667PEM_X509_INFO_read
1668PEM_X509_INFO_read_bio 1666PEM_X509_INFO_read_bio
1669PEM_X509_INFO_write_bio
1670PEM_bytes_read_bio 1667PEM_bytes_read_bio
1671PEM_def_callback 1668PEM_def_callback
1672PEM_dek_info 1669PEM_dek_info
@@ -2474,8 +2471,6 @@ X509_OBJECT_idx_by_subject
2474X509_OBJECT_new 2471X509_OBJECT_new
2475X509_OBJECT_retrieve_by_subject 2472X509_OBJECT_retrieve_by_subject
2476X509_OBJECT_retrieve_match 2473X509_OBJECT_retrieve_match
2477X509_PKEY_free
2478X509_PKEY_new
2479X509_PUBKEY_free 2474X509_PUBKEY_free
2480X509_PUBKEY_get 2475X509_PUBKEY_get
2481X509_PUBKEY_get0 2476X509_PUBKEY_get0
diff --git a/src/lib/libcrypto/aes/aes.c b/src/lib/libcrypto/aes/aes.c
index 3dc2c9a458..693badcd66 100644
--- a/src/lib/libcrypto/aes/aes.c
+++ b/src/lib/libcrypto/aes/aes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: aes.c,v 1.5 2025/04/20 09:17:53 jsing Exp $ */ 1/* $OpenBSD: aes.c,v 1.14 2025/07/22 09:13:49 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -52,9 +52,12 @@
52 52
53#include <openssl/aes.h> 53#include <openssl/aes.h>
54#include <openssl/bio.h> 54#include <openssl/bio.h>
55#include <openssl/crypto.h>
55#include <openssl/modes.h> 56#include <openssl/modes.h>
56 57
57#include "crypto_arch.h" 58#include "crypto_arch.h"
59#include "crypto_internal.h"
60#include "modes_local.h"
58 61
59static const unsigned char aes_wrap_default_iv[] = { 62static const unsigned char aes_wrap_default_iv[] = {
60 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 63 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
@@ -97,6 +100,18 @@ AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key)
97} 100}
98LCRYPTO_ALIAS(AES_decrypt); 101LCRYPTO_ALIAS(AES_decrypt);
99 102
103void
104aes_encrypt_block128(const unsigned char *in, unsigned char *out, const void *key)
105{
106 aes_encrypt_internal(in, out, key);
107}
108
109void
110aes_decrypt_block128(const unsigned char *in, unsigned char *out, const void *key)
111{
112 aes_decrypt_internal(in, out, key);
113}
114
100#ifdef HAVE_AES_CBC_ENCRYPT_INTERNAL 115#ifdef HAVE_AES_CBC_ENCRYPT_INTERNAL
101void aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out, 116void aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out,
102 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc); 117 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc);
@@ -108,10 +123,10 @@ aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out,
108{ 123{
109 if (enc) 124 if (enc)
110 CRYPTO_cbc128_encrypt(in, out, len, key, ivec, 125 CRYPTO_cbc128_encrypt(in, out, len, key, ivec,
111 (block128_f)AES_encrypt); 126 aes_encrypt_block128);
112 else 127 else
113 CRYPTO_cbc128_decrypt(in, out, len, key, ivec, 128 CRYPTO_cbc128_decrypt(in, out, len, key, ivec,
114 (block128_f)AES_decrypt); 129 aes_decrypt_block128);
115} 130}
116#endif 131#endif
117 132
@@ -134,7 +149,7 @@ AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
134 const AES_KEY *key, unsigned char *ivec, int *num, const int enc) 149 const AES_KEY *key, unsigned char *ivec, int *num, const int enc)
135{ 150{
136 CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc, 151 CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc,
137 (block128_f)AES_encrypt); 152 aes_encrypt_block128);
138} 153}
139LCRYPTO_ALIAS(AES_cfb128_encrypt); 154LCRYPTO_ALIAS(AES_cfb128_encrypt);
140 155
@@ -144,7 +159,7 @@ AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, size_t length,
144 const AES_KEY *key, unsigned char *ivec, int *num, const int enc) 159 const AES_KEY *key, unsigned char *ivec, int *num, const int enc)
145{ 160{
146 CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc, 161 CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc,
147 (block128_f)AES_encrypt); 162 aes_encrypt_block128);
148} 163}
149LCRYPTO_ALIAS(AES_cfb1_encrypt); 164LCRYPTO_ALIAS(AES_cfb1_encrypt);
150 165
@@ -153,17 +168,134 @@ AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, size_t length,
153 const AES_KEY *key, unsigned char *ivec, int *num, const int enc) 168 const AES_KEY *key, unsigned char *ivec, int *num, const int enc)
154{ 169{
155 CRYPTO_cfb128_8_encrypt(in, out, length, key, ivec, num, enc, 170 CRYPTO_cfb128_8_encrypt(in, out, length, key, ivec, num, enc,
156 (block128_f)AES_encrypt); 171 aes_encrypt_block128);
157} 172}
158LCRYPTO_ALIAS(AES_cfb8_encrypt); 173LCRYPTO_ALIAS(AES_cfb8_encrypt);
159 174
160void 175void
176aes_ccm64_encrypt_generic(const unsigned char *in, unsigned char *out,
177 size_t blocks, const void *key, const unsigned char ivec[16],
178 unsigned char cmac[16], int encrypt)
179{
180 uint8_t iv[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE];
181 uint8_t in_mask;
182 uint64_t ctr;
183 int i;
184
185 in_mask = 0 - (encrypt != 0);
186
187 memcpy(iv, ivec, sizeof(iv));
188
189 ctr = crypto_load_be64toh(&iv[8]);
190
191 while (blocks > 0) {
192 crypto_store_htobe64(&iv[8], ctr);
193 aes_encrypt_internal(iv, buf, key);
194 ctr++;
195
196 for (i = 0; i < 16; i++) {
197 out[i] = in[i] ^ buf[i];
198 cmac[i] ^= (in[i] & in_mask) | (out[i] & ~in_mask);
199 }
200
201 aes_encrypt_internal(cmac, cmac, key);
202
203 in += 16;
204 out += 16;
205 blocks--;
206 }
207
208 explicit_bzero(buf, sizeof(buf));
209 explicit_bzero(iv, sizeof(iv));
210}
211
212#ifdef HAVE_AES_CCM64_ENCRYPT_INTERNAL
213void aes_ccm64_encrypt_internal(const unsigned char *in, unsigned char *out,
214 size_t blocks, const void *key, const unsigned char ivec[16],
215 unsigned char cmac[16], int encrypt);
216
217#else
218static inline void
219aes_ccm64_encrypt_internal(const unsigned char *in, unsigned char *out,
220 size_t blocks, const void *key, const unsigned char ivec[16],
221 unsigned char cmac[16], int encrypt)
222{
223 aes_ccm64_encrypt_generic(in, out, blocks, key, ivec, cmac, encrypt);
224}
225#endif
226
227void
228aes_ccm64_encrypt_ccm128f(const unsigned char *in, unsigned char *out,
229 size_t blocks, const void *key, const unsigned char ivec[16],
230 unsigned char cmac[16])
231{
232 aes_ccm64_encrypt_internal(in, out, blocks, key, ivec, cmac, 1);
233}
234
235void
236aes_ccm64_decrypt_ccm128f(const unsigned char *in, unsigned char *out,
237 size_t blocks, const void *key, const unsigned char ivec[16],
238 unsigned char cmac[16])
239{
240 aes_ccm64_encrypt_internal(in, out, blocks, key, ivec, cmac, 0);
241}
242
243void
244aes_ctr32_encrypt_generic(const unsigned char *in, unsigned char *out,
245 size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE])
246{
247 uint8_t iv[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE];
248 uint32_t ctr;
249 int i;
250
251 memcpy(iv, ivec, sizeof(iv));
252
253 ctr = crypto_load_be32toh(&iv[12]);
254
255 while (blocks > 0) {
256 crypto_store_htobe32(&iv[12], ctr);
257 aes_encrypt_internal(iv, buf, key);
258 ctr++;
259
260 for (i = 0; i < AES_BLOCK_SIZE; i++)
261 out[i] = in[i] ^ buf[i];
262
263 in += 16;
264 out += 16;
265 blocks--;
266 }
267
268 explicit_bzero(buf, sizeof(buf));
269 explicit_bzero(iv, sizeof(iv));
270}
271
272#ifdef HAVE_AES_CTR32_ENCRYPT_INTERNAL
273void aes_ctr32_encrypt_internal(const unsigned char *in, unsigned char *out,
274 size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE]);
275
276#else
277static inline void
278aes_ctr32_encrypt_internal(const unsigned char *in, unsigned char *out,
279 size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE])
280{
281 aes_ctr32_encrypt_generic(in, out, blocks, key, ivec);
282}
283#endif
284
285void
286aes_ctr32_encrypt_ctr128f(const unsigned char *in, unsigned char *out, size_t blocks,
287 const void *key, const unsigned char ivec[AES_BLOCK_SIZE])
288{
289 aes_ctr32_encrypt_internal(in, out, blocks, key, ivec);
290}
291
292void
161AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 293AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
162 size_t length, const AES_KEY *key, unsigned char ivec[AES_BLOCK_SIZE], 294 size_t length, const AES_KEY *key, unsigned char ivec[AES_BLOCK_SIZE],
163 unsigned char ecount_buf[AES_BLOCK_SIZE], unsigned int *num) 295 unsigned char ecount_buf[AES_BLOCK_SIZE], unsigned int *num)
164{ 296{
165 CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num, 297 CRYPTO_ctr128_encrypt_ctr32(in, out, length, key, ivec, ecount_buf,
166 (block128_f)AES_encrypt); 298 num, aes_ctr32_encrypt_ctr128f);
167} 299}
168LCRYPTO_ALIAS(AES_ctr128_encrypt); 300LCRYPTO_ALIAS(AES_ctr128_encrypt);
169 301
@@ -178,15 +310,121 @@ AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
178} 310}
179LCRYPTO_ALIAS(AES_ecb_encrypt); 311LCRYPTO_ALIAS(AES_ecb_encrypt);
180 312
313#ifndef HAVE_AES_ECB_ENCRYPT_INTERNAL
314void
315aes_ecb_encrypt_internal(const unsigned char *in, unsigned char *out,
316 size_t len, const AES_KEY *key, int encrypt)
317{
318 while (len >= AES_BLOCK_SIZE) {
319 AES_ecb_encrypt(in, out, key, encrypt);
320 in += AES_BLOCK_SIZE;
321 out += AES_BLOCK_SIZE;
322 len -= AES_BLOCK_SIZE;
323 }
324}
325#endif
326
327#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long))
328typedef struct {
329 unsigned long data[N_WORDS];
330} aes_block_t;
331
332void
333AES_ige_encrypt(const unsigned char *in, unsigned char *out, size_t length,
334 const AES_KEY *key, unsigned char *ivec, const int enc)
335{
336 aes_block_t tmp, tmp2;
337 aes_block_t iv;
338 aes_block_t iv2;
339 size_t n;
340 size_t len;
341
342 /* N.B. The IV for this mode is _twice_ the block size */
343
344 OPENSSL_assert((length % AES_BLOCK_SIZE) == 0);
345
346 len = length / AES_BLOCK_SIZE;
347
348 memcpy(iv.data, ivec, AES_BLOCK_SIZE);
349 memcpy(iv2.data, ivec + AES_BLOCK_SIZE, AES_BLOCK_SIZE);
350
351 if (AES_ENCRYPT == enc) {
352 while (len) {
353 memcpy(tmp.data, in, AES_BLOCK_SIZE);
354 for (n = 0; n < N_WORDS; ++n)
355 tmp2.data[n] = tmp.data[n] ^ iv.data[n];
356 AES_encrypt((unsigned char *)tmp2.data,
357 (unsigned char *)tmp2.data, key);
358 for (n = 0; n < N_WORDS; ++n)
359 tmp2.data[n] ^= iv2.data[n];
360 memcpy(out, tmp2.data, AES_BLOCK_SIZE);
361 iv = tmp2;
362 iv2 = tmp;
363 --len;
364 in += AES_BLOCK_SIZE;
365 out += AES_BLOCK_SIZE;
366 }
367 } else {
368 while (len) {
369 memcpy(tmp.data, in, AES_BLOCK_SIZE);
370 tmp2 = tmp;
371 for (n = 0; n < N_WORDS; ++n)
372 tmp.data[n] ^= iv2.data[n];
373 AES_decrypt((unsigned char *)tmp.data,
374 (unsigned char *)tmp.data, key);
375 for (n = 0; n < N_WORDS; ++n)
376 tmp.data[n] ^= iv.data[n];
377 memcpy(out, tmp.data, AES_BLOCK_SIZE);
378 iv = tmp2;
379 iv2 = tmp;
380 --len;
381 in += AES_BLOCK_SIZE;
382 out += AES_BLOCK_SIZE;
383 }
384 }
385 memcpy(ivec, iv.data, AES_BLOCK_SIZE);
386 memcpy(ivec + AES_BLOCK_SIZE, iv2.data, AES_BLOCK_SIZE);
387}
388LCRYPTO_ALIAS(AES_ige_encrypt);
389
181void 390void
182AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, 391AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
183 const AES_KEY *key, unsigned char *ivec, int *num) 392 const AES_KEY *key, unsigned char *ivec, int *num)
184{ 393{
185 CRYPTO_ofb128_encrypt(in, out, length, key, ivec, num, 394 CRYPTO_ofb128_encrypt(in, out, length, key, ivec, num,
186 (block128_f)AES_encrypt); 395 aes_encrypt_block128);
187} 396}
188LCRYPTO_ALIAS(AES_ofb128_encrypt); 397LCRYPTO_ALIAS(AES_ofb128_encrypt);
189 398
399void
400aes_xts_encrypt_generic(const unsigned char *in, unsigned char *out, size_t len,
401 const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16],
402 int encrypt)
403{
404 XTS128_CONTEXT xctx;
405
406 if (encrypt)
407 xctx.block1 = aes_encrypt_block128;
408 else
409 xctx.block1 = aes_decrypt_block128;
410
411 xctx.block2 = aes_encrypt_block128;
412 xctx.key1 = key1;
413 xctx.key2 = key2;
414
415 CRYPTO_xts128_encrypt(&xctx, iv, in, out, len, encrypt);
416}
417
418#ifndef HAVE_AES_XTS_ENCRYPT_INTERNAL
419void
420aes_xts_encrypt_internal(const unsigned char *in, unsigned char *out, size_t len,
421 const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16],
422 int encrypt)
423{
424 aes_xts_encrypt_generic(in, out, len, key1, key2, iv, encrypt);
425}
426#endif
427
190int 428int
191AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, 429AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
192 const unsigned char *in, unsigned int inlen) 430 const unsigned char *in, unsigned int inlen)
@@ -253,7 +491,7 @@ AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
253 } 491 }
254 if (!iv) 492 if (!iv)
255 iv = aes_wrap_default_iv; 493 iv = aes_wrap_default_iv;
256 if (memcmp(A, iv, 8)) { 494 if (timingsafe_memcmp(A, iv, 8) != 0) {
257 explicit_bzero(out, inlen); 495 explicit_bzero(out, inlen);
258 return 0; 496 return 0;
259 } 497 }
diff --git a/src/lib/libcrypto/aes/aes_amd64.c b/src/lib/libcrypto/aes/aes_amd64.c
new file mode 100644
index 0000000000..183a5cce14
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_amd64.c
@@ -0,0 +1,201 @@
1/* $OpenBSD: aes_amd64.c,v 1.5 2025/07/22 09:13:49 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <openssl/aes.h>
19
20#include "crypto_arch.h"
21#include "modes_local.h"
22
23int aes_set_encrypt_key_generic(const unsigned char *userKey, const int bits,
24 AES_KEY *key);
25int aes_set_decrypt_key_generic(const unsigned char *userKey, const int bits,
26 AES_KEY *key);
27
28void aes_encrypt_generic(const unsigned char *in, unsigned char *out,
29 const AES_KEY *key);
30void aes_decrypt_generic(const unsigned char *in, unsigned char *out,
31 const AES_KEY *key);
32
33void aes_cbc_encrypt_generic(const unsigned char *in, unsigned char *out,
34 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc);
35
36void aes_ccm64_encrypt_generic(const unsigned char *in, unsigned char *out,
37 size_t blocks, const void *key, const unsigned char ivec[16],
38 unsigned char cmac[16], int encrypt);
39
40void aes_ctr32_encrypt_generic(const unsigned char *in, unsigned char *out,
41 size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE]);
42
43void aes_xts_encrypt_generic(const unsigned char *in, unsigned char *out,
44 size_t len, const AES_KEY *key1, const AES_KEY *key2,
45 const unsigned char iv[16], int encrypt);
46
47int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
48 AES_KEY *key);
49int aesni_set_decrypt_key(const unsigned char *userKey, int bits,
50 AES_KEY *key);
51
52void aesni_encrypt(const unsigned char *in, unsigned char *out,
53 const AES_KEY *key);
54void aesni_decrypt(const unsigned char *in, unsigned char *out,
55 const AES_KEY *key);
56
57void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out,
58 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc);
59
60void aesni_ccm64_encrypt_blocks(const unsigned char *in, unsigned char *out,
61 size_t blocks, const void *key, const unsigned char ivec[16],
62 unsigned char cmac[16]);
63
64void aesni_ccm64_decrypt_blocks(const unsigned char *in, unsigned char *out,
65 size_t blocks, const void *key, const unsigned char ivec[16],
66 unsigned char cmac[16]);
67
68void aesni_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
69 size_t blocks, const void *key, const unsigned char *ivec);
70
71void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out,
72 size_t length, const AES_KEY *key, int enc);
73
74void aesni_xts_encrypt(const unsigned char *in, unsigned char *out,
75 size_t length, const AES_KEY *key1, const AES_KEY *key2,
76 const unsigned char iv[16]);
77
78void aesni_xts_decrypt(const unsigned char *in, unsigned char *out,
79 size_t length, const AES_KEY *key1, const AES_KEY *key2,
80 const unsigned char iv[16]);
81
82int
83aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits,
84 AES_KEY *key)
85{
86 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0)
87 return aesni_set_encrypt_key(userKey, bits, key);
88
89 return aes_set_encrypt_key_generic(userKey, bits, key);
90}
91
92int
93aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits,
94 AES_KEY *key)
95{
96 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0)
97 return aesni_set_decrypt_key(userKey, bits, key);
98
99 return aes_set_decrypt_key_generic(userKey, bits, key);
100}
101
102void
103aes_encrypt_internal(const unsigned char *in, unsigned char *out,
104 const AES_KEY *key)
105{
106 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0) {
107 aesni_encrypt(in, out, key);
108 return;
109 }
110
111 aes_encrypt_generic(in, out, key);
112}
113
114void
115aes_decrypt_internal(const unsigned char *in, unsigned char *out,
116 const AES_KEY *key)
117{
118 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0) {
119 aesni_decrypt(in, out, key);
120 return;
121 }
122
123 aes_decrypt_generic(in, out, key);
124}
125
126void
127aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out,
128 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc)
129{
130 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0) {
131 aesni_cbc_encrypt(in, out, len, key, ivec, enc);
132 return;
133 }
134
135 aes_cbc_encrypt_generic(in, out, len, key, ivec, enc);
136}
137
138void
139aes_ccm64_encrypt_internal(const unsigned char *in, unsigned char *out,
140 size_t blocks, const void *key, const unsigned char ivec[16],
141 unsigned char cmac[16], int encrypt)
142{
143 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0) {
144 if (encrypt)
145 aesni_ccm64_encrypt_blocks(in, out, blocks, key, ivec, cmac);
146 else
147 aesni_ccm64_decrypt_blocks(in, out, blocks, key, ivec, cmac);
148 return;
149 }
150
151 aes_ccm64_encrypt_generic(in, out, blocks, key, ivec, cmac, encrypt);
152}
153
154void
155aes_ctr32_encrypt_internal(const unsigned char *in, unsigned char *out,
156 size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE])
157{
158 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0) {
159 aesni_ctr32_encrypt_blocks(in, out, blocks, key, ivec);
160 return;
161 }
162
163 aes_ctr32_encrypt_generic(in, out, blocks, key, ivec);
164}
165
166void
167aes_ecb_encrypt_internal(const unsigned char *in, unsigned char *out,
168 size_t len, const AES_KEY *key, int encrypt)
169{
170 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0) {
171 aesni_ecb_encrypt(in, out, len, key, encrypt);
172 return;
173 }
174
175 while (len >= AES_BLOCK_SIZE) {
176 if (encrypt)
177 aes_encrypt_generic(in, out, key);
178 else
179 aes_decrypt_generic(in, out, key);
180
181 in += AES_BLOCK_SIZE;
182 out += AES_BLOCK_SIZE;
183 len -= AES_BLOCK_SIZE;
184 }
185}
186
187void
188aes_xts_encrypt_internal(const unsigned char *in, unsigned char *out,
189 size_t len, const AES_KEY *key1, const AES_KEY *key2,
190 const unsigned char iv[16], int encrypt)
191{
192 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_AES) != 0) {
193 if (encrypt)
194 aesni_xts_encrypt(in, out, len, key1, key2, iv);
195 else
196 aesni_xts_decrypt(in, out, len, key1, key2, iv);
197 return;
198 }
199
200 aes_xts_encrypt_generic(in, out, len, key1, key2, iv, encrypt);
201}
diff --git a/src/lib/libcrypto/aes/aes_i386.c b/src/lib/libcrypto/aes/aes_i386.c
new file mode 100644
index 0000000000..85a14454da
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_i386.c
@@ -0,0 +1,201 @@
1/* $OpenBSD: aes_i386.c,v 1.5 2025/07/22 09:13:49 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <openssl/aes.h>
19
20#include "crypto_arch.h"
21#include "modes_local.h"
22
23int aes_set_encrypt_key_generic(const unsigned char *userKey, const int bits,
24 AES_KEY *key);
25int aes_set_decrypt_key_generic(const unsigned char *userKey, const int bits,
26 AES_KEY *key);
27
28void aes_encrypt_generic(const unsigned char *in, unsigned char *out,
29 const AES_KEY *key);
30void aes_decrypt_generic(const unsigned char *in, unsigned char *out,
31 const AES_KEY *key);
32
33void aes_cbc_encrypt_generic(const unsigned char *in, unsigned char *out,
34 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc);
35
36void aes_ccm64_encrypt_generic(const unsigned char *in, unsigned char *out,
37 size_t blocks, const void *key, const unsigned char ivec[16],
38 unsigned char cmac[16], int encrypt);
39
40void aes_ctr32_encrypt_generic(const unsigned char *in, unsigned char *out,
41 size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE]);
42
43void aes_xts_encrypt_generic(const unsigned char *in, unsigned char *out,
44 size_t len, const AES_KEY *key1, const AES_KEY *key2,
45 const unsigned char iv[16], int encrypt);
46
47int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
48 AES_KEY *key);
49int aesni_set_decrypt_key(const unsigned char *userKey, int bits,
50 AES_KEY *key);
51
52void aesni_encrypt(const unsigned char *in, unsigned char *out,
53 const AES_KEY *key);
54void aesni_decrypt(const unsigned char *in, unsigned char *out,
55 const AES_KEY *key);
56
57void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out,
58 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc);
59
60void aesni_ccm64_encrypt_blocks(const unsigned char *in, unsigned char *out,
61 size_t blocks, const void *key, const unsigned char ivec[16],
62 unsigned char cmac[16]);
63
64void aesni_ccm64_decrypt_blocks(const unsigned char *in, unsigned char *out,
65 size_t blocks, const void *key, const unsigned char ivec[16],
66 unsigned char cmac[16]);
67
68void aesni_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
69 size_t blocks, const void *key, const unsigned char *ivec);
70
71void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out,
72 size_t length, const AES_KEY *key, int enc);
73
74void aesni_xts_encrypt(const unsigned char *in, unsigned char *out,
75 size_t length, const AES_KEY *key1, const AES_KEY *key2,
76 const unsigned char iv[16]);
77
78void aesni_xts_decrypt(const unsigned char *in, unsigned char *out,
79 size_t length, const AES_KEY *key1, const AES_KEY *key2,
80 const unsigned char iv[16]);
81
82int
83aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits,
84 AES_KEY *key)
85{
86 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0)
87 return aesni_set_encrypt_key(userKey, bits, key);
88
89 return aes_set_encrypt_key_generic(userKey, bits, key);
90}
91
92int
93aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits,
94 AES_KEY *key)
95{
96 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0)
97 return aesni_set_decrypt_key(userKey, bits, key);
98
99 return aes_set_decrypt_key_generic(userKey, bits, key);
100}
101
102void
103aes_encrypt_internal(const unsigned char *in, unsigned char *out,
104 const AES_KEY *key)
105{
106 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0) {
107 aesni_encrypt(in, out, key);
108 return;
109 }
110
111 aes_encrypt_generic(in, out, key);
112}
113
114void
115aes_decrypt_internal(const unsigned char *in, unsigned char *out,
116 const AES_KEY *key)
117{
118 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0) {
119 aesni_decrypt(in, out, key);
120 return;
121 }
122
123 aes_decrypt_generic(in, out, key);
124}
125
126void
127aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out,
128 size_t len, const AES_KEY *key, unsigned char *ivec, const int enc)
129{
130 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0) {
131 aesni_cbc_encrypt(in, out, len, key, ivec, enc);
132 return;
133 }
134
135 aes_cbc_encrypt_generic(in, out, len, key, ivec, enc);
136}
137
138void
139aes_ccm64_encrypt_internal(const unsigned char *in, unsigned char *out,
140 size_t blocks, const void *key, const unsigned char ivec[16],
141 unsigned char cmac[16], int encrypt)
142{
143 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0) {
144 if (encrypt)
145 aesni_ccm64_encrypt_blocks(in, out, blocks, key, ivec, cmac);
146 else
147 aesni_ccm64_decrypt_blocks(in, out, blocks, key, ivec, cmac);
148 return;
149 }
150
151 aes_ccm64_encrypt_generic(in, out, blocks, key, ivec, cmac, encrypt);
152}
153
154void
155aes_ctr32_encrypt_internal(const unsigned char *in, unsigned char *out,
156 size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE])
157{
158 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0) {
159 aesni_ctr32_encrypt_blocks(in, out, blocks, key, ivec);
160 return;
161 }
162
163 aes_ctr32_encrypt_generic(in, out, blocks, key, ivec);
164}
165
166void
167aes_ecb_encrypt_internal(const unsigned char *in, unsigned char *out,
168 size_t len, const AES_KEY *key, int encrypt)
169{
170 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0) {
171 aesni_ecb_encrypt(in, out, len, key, encrypt);
172 return;
173 }
174
175 while (len >= AES_BLOCK_SIZE) {
176 if (encrypt)
177 aes_encrypt_generic(in, out, key);
178 else
179 aes_decrypt_generic(in, out, key);
180
181 in += AES_BLOCK_SIZE;
182 out += AES_BLOCK_SIZE;
183 len -= AES_BLOCK_SIZE;
184 }
185}
186
187void
188aes_xts_encrypt_internal(const unsigned char *in, unsigned char *out,
189 size_t len, const AES_KEY *key1, const AES_KEY *key2,
190 const unsigned char iv[16], int encrypt)
191{
192 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_AES) != 0) {
193 if (encrypt)
194 aesni_xts_encrypt(in, out, len, key1, key2, iv);
195 else
196 aesni_xts_decrypt(in, out, len, key1, key2, iv);
197 return;
198 }
199
200 aes_xts_encrypt_generic(in, out, len, key1, key2, iv, encrypt);
201}
diff --git a/src/lib/libcrypto/aes/aes_ige.c b/src/lib/libcrypto/aes/aes_ige.c
deleted file mode 100644
index 1a6fcfcfbf..0000000000
--- a/src/lib/libcrypto/aes/aes_ige.c
+++ /dev/null
@@ -1,195 +0,0 @@
1/* $OpenBSD: aes_ige.c,v 1.10 2024/03/30 05:14:12 joshua Exp $ */
2/* ====================================================================
3 * Copyright (c) 2006 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 */
51
52#include <openssl/aes.h>
53#include <openssl/crypto.h>
54
55#include "aes_local.h"
56
57#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long))
58typedef struct {
59 unsigned long data[N_WORDS];
60} aes_block_t;
61
62/* XXX: probably some better way to do this */
63#if defined(__i386__) || defined(__x86_64__)
64#define UNALIGNED_MEMOPS_ARE_FAST 1
65#else
66#define UNALIGNED_MEMOPS_ARE_FAST 0
67#endif
68
69#if UNALIGNED_MEMOPS_ARE_FAST
70#define load_block(d, s) (d) = *(const aes_block_t *)(s)
71#define store_block(d, s) *(aes_block_t *)(d) = (s)
72#else
73#define load_block(d, s) memcpy((d).data, (s), AES_BLOCK_SIZE)
74#define store_block(d, s) memcpy((d), (s).data, AES_BLOCK_SIZE)
75#endif
76
77/* N.B. The IV for this mode is _twice_ the block size */
78
79void
80AES_ige_encrypt(const unsigned char *in, unsigned char *out, size_t length,
81 const AES_KEY *key, unsigned char *ivec, const int enc)
82{
83 size_t n;
84 size_t len;
85
86 OPENSSL_assert((length % AES_BLOCK_SIZE) == 0);
87
88 len = length / AES_BLOCK_SIZE;
89
90 if (AES_ENCRYPT == enc) {
91 if (in != out && (UNALIGNED_MEMOPS_ARE_FAST ||
92 ((size_t)in|(size_t)out|(size_t)ivec) %
93 sizeof(long) == 0)) {
94 aes_block_t *ivp = (aes_block_t *)ivec;
95 aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE);
96
97 while (len) {
98 aes_block_t *inp = (aes_block_t *)in;
99 aes_block_t *outp = (aes_block_t *)out;
100
101 for (n = 0; n < N_WORDS; ++n)
102 outp->data[n] = inp->data[n] ^ ivp->data[n];
103 AES_encrypt((unsigned char *)outp->data, (unsigned char *)outp->data, key);
104 for (n = 0; n < N_WORDS; ++n)
105 outp->data[n] ^= iv2p->data[n];
106 ivp = outp;
107 iv2p = inp;
108 --len;
109 in += AES_BLOCK_SIZE;
110 out += AES_BLOCK_SIZE;
111 }
112 memmove(ivec, ivp->data, AES_BLOCK_SIZE);
113 memmove(ivec + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE);
114 } else {
115 aes_block_t tmp, tmp2;
116 aes_block_t iv;
117 aes_block_t iv2;
118
119 load_block(iv, ivec);
120 load_block(iv2, ivec + AES_BLOCK_SIZE);
121
122 while (len) {
123 load_block(tmp, in);
124 for (n = 0; n < N_WORDS; ++n)
125 tmp2.data[n] = tmp.data[n] ^ iv.data[n];
126 AES_encrypt((unsigned char *)tmp2.data,
127 (unsigned char *)tmp2.data, key);
128 for (n = 0; n < N_WORDS; ++n)
129 tmp2.data[n] ^= iv2.data[n];
130 store_block(out, tmp2);
131 iv = tmp2;
132 iv2 = tmp;
133 --len;
134 in += AES_BLOCK_SIZE;
135 out += AES_BLOCK_SIZE;
136 }
137 memcpy(ivec, iv.data, AES_BLOCK_SIZE);
138 memcpy(ivec + AES_BLOCK_SIZE, iv2.data, AES_BLOCK_SIZE);
139 }
140 } else {
141 if (in != out && (UNALIGNED_MEMOPS_ARE_FAST ||
142 ((size_t)in|(size_t)out|(size_t)ivec) %
143 sizeof(long) == 0)) {
144 aes_block_t *ivp = (aes_block_t *)ivec;
145 aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE);
146
147 while (len) {
148 aes_block_t tmp;
149 aes_block_t *inp = (aes_block_t *)in;
150 aes_block_t *outp = (aes_block_t *)out;
151
152 for (n = 0; n < N_WORDS; ++n)
153 tmp.data[n] = inp->data[n] ^ iv2p->data[n];
154 AES_decrypt((unsigned char *)tmp.data,
155 (unsigned char *)outp->data, key);
156 for (n = 0; n < N_WORDS; ++n)
157 outp->data[n] ^= ivp->data[n];
158 ivp = inp;
159 iv2p = outp;
160 --len;
161 in += AES_BLOCK_SIZE;
162 out += AES_BLOCK_SIZE;
163 }
164 memmove(ivec, ivp->data, AES_BLOCK_SIZE);
165 memmove(ivec + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE);
166 } else {
167 aes_block_t tmp, tmp2;
168 aes_block_t iv;
169 aes_block_t iv2;
170
171 load_block(iv, ivec);
172 load_block(iv2, ivec + AES_BLOCK_SIZE);
173
174 while (len) {
175 load_block(tmp, in);
176 tmp2 = tmp;
177 for (n = 0; n < N_WORDS; ++n)
178 tmp.data[n] ^= iv2.data[n];
179 AES_decrypt((unsigned char *)tmp.data,
180 (unsigned char *)tmp.data, key);
181 for (n = 0; n < N_WORDS; ++n)
182 tmp.data[n] ^= iv.data[n];
183 store_block(out, tmp);
184 iv = tmp2;
185 iv2 = tmp;
186 --len;
187 in += AES_BLOCK_SIZE;
188 out += AES_BLOCK_SIZE;
189 }
190 memcpy(ivec, iv.data, AES_BLOCK_SIZE);
191 memcpy(ivec + AES_BLOCK_SIZE, iv2.data, AES_BLOCK_SIZE);
192 }
193 }
194}
195LCRYPTO_ALIAS(AES_ige_encrypt);
diff --git a/src/lib/libcrypto/aes/aes_local.h b/src/lib/libcrypto/aes/aes_local.h
index 823dbab574..a265eaac1d 100644
--- a/src/lib/libcrypto/aes/aes_local.h
+++ b/src/lib/libcrypto/aes/aes_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: aes_local.h,v 1.5 2025/04/21 12:23:09 jsing Exp $ */ 1/* $OpenBSD: aes_local.h,v 1.11 2025/07/22 09:29:31 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -60,13 +60,30 @@
60 60
61__BEGIN_HIDDEN_DECLS 61__BEGIN_HIDDEN_DECLS
62 62
63#define MAXKC (256/32)
64#define MAXKB (256/8)
65#define MAXNR 14
66
67/* This controls loop-unrolling in aes_core.c */ 63/* This controls loop-unrolling in aes_core.c */
68#undef FULL_UNROLL 64#undef FULL_UNROLL
69 65
66void aes_encrypt_block128(const unsigned char *in, unsigned char *out,
67 const void *key);
68
69void aes_ctr32_encrypt_ctr128f(const unsigned char *in, unsigned char *out,
70 size_t blocks, const void *key, const unsigned char ivec[AES_BLOCK_SIZE]);
71
72void aes_ccm64_encrypt_ccm128f(const unsigned char *in, unsigned char *out,
73 size_t blocks, const void *key, const unsigned char ivec[16],
74 unsigned char cmac[16]);
75
76void aes_ccm64_decrypt_ccm128f(const unsigned char *in, unsigned char *out,
77 size_t blocks, const void *key, const unsigned char ivec[16],
78 unsigned char cmac[16]);
79
80void aes_ecb_encrypt_internal(const unsigned char *in, unsigned char *out,
81 size_t len, const AES_KEY *key, int encrypt);
82
83void aes_xts_encrypt_internal(const char unsigned *in, char unsigned *out,
84 size_t len, const AES_KEY *key1, const AES_KEY *key2,
85 const unsigned char iv[16], int encrypt);
86
70__END_HIDDEN_DECLS 87__END_HIDDEN_DECLS
71 88
72#endif /* !HEADER_AES_LOCAL_H */ 89#endif /* !HEADER_AES_LOCAL_H */
diff --git a/src/lib/libcrypto/aes/asm/aes-586.pl b/src/lib/libcrypto/aes/asm/aes-586.pl
index 364099d4d3..402a1a3c46 100644
--- a/src/lib/libcrypto/aes/asm/aes-586.pl
+++ b/src/lib/libcrypto/aes/asm/aes-586.pl
@@ -1158,8 +1158,8 @@ sub enclast()
1158 &data_word(0x00000000, 0x00000000, 0x00000000, 0x00000000); 1158 &data_word(0x00000000, 0x00000000, 0x00000000, 0x00000000);
1159 &previous(); 1159 &previous();
1160 1160
1161# void aes_encrypt_internal(const void *inp, void *out, const AES_KEY *key); 1161# void aes_encrypt_generic(const void *inp, void *out, const AES_KEY *key);
1162&function_begin("aes_encrypt_internal"); 1162&function_begin("aes_encrypt_generic");
1163 &mov ($acc,&wparam(0)); # load inp 1163 &mov ($acc,&wparam(0)); # load inp
1164 &mov ($key,&wparam(2)); # load key 1164 &mov ($key,&wparam(2)); # load key
1165 1165
@@ -1213,7 +1213,7 @@ sub enclast()
1213 &mov (&DWP(4,$acc),$s1); 1213 &mov (&DWP(4,$acc),$s1);
1214 &mov (&DWP(8,$acc),$s2); 1214 &mov (&DWP(8,$acc),$s2);
1215 &mov (&DWP(12,$acc),$s3); 1215 &mov (&DWP(12,$acc),$s3);
1216&function_end("aes_encrypt_internal"); 1216&function_end("aes_encrypt_generic");
1217 1217
1218#--------------------------------------------------------------------# 1218#--------------------------------------------------------------------#
1219 1219
@@ -1947,8 +1947,8 @@ sub declast()
1947 &data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d); 1947 &data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
1948 &previous(); 1948 &previous();
1949 1949
1950# void aes_decrypt_internal(const void *inp, void *out, const AES_KEY *key); 1950# void aes_decrypt_generic(const void *inp, void *out, const AES_KEY *key);
1951&function_begin("aes_decrypt_internal"); 1951&function_begin("aes_decrypt_generic");
1952 &mov ($acc,&wparam(0)); # load inp 1952 &mov ($acc,&wparam(0)); # load inp
1953 &mov ($key,&wparam(2)); # load key 1953 &mov ($key,&wparam(2)); # load key
1954 1954
@@ -2002,9 +2002,9 @@ sub declast()
2002 &mov (&DWP(4,$acc),$s1); 2002 &mov (&DWP(4,$acc),$s1);
2003 &mov (&DWP(8,$acc),$s2); 2003 &mov (&DWP(8,$acc),$s2);
2004 &mov (&DWP(12,$acc),$s3); 2004 &mov (&DWP(12,$acc),$s3);
2005&function_end("aes_decrypt_internal"); 2005&function_end("aes_decrypt_generic");
2006 2006
2007# void aes_cbc_encrypt_internal(const void char *inp, unsigned char *out, 2007# void aes_cbc_encrypt_generic(const void char *inp, unsigned char *out,
2008# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc); 2008# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc);
2009{ 2009{
2010# stack frame layout 2010# stack frame layout
@@ -2028,7 +2028,7 @@ my $ivec=&DWP(60,"esp"); # ivec[16]
2028my $aes_key=&DWP(76,"esp"); # copy of aes_key 2028my $aes_key=&DWP(76,"esp"); # copy of aes_key
2029my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds 2029my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
2030 2030
2031&function_begin("aes_cbc_encrypt_internal"); 2031&function_begin("aes_cbc_encrypt_generic");
2032 &mov ($s2 eq "ecx"? $s2 : "",&wparam(2)); # load len 2032 &mov ($s2 eq "ecx"? $s2 : "",&wparam(2)); # load len
2033 &cmp ($s2,0); 2033 &cmp ($s2,0);
2034 &je (&label("drop_out")); 2034 &je (&label("drop_out"));
@@ -2616,7 +2616,7 @@ my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
2616 2616
2617 &mov ("esp",$_esp); 2617 &mov ("esp",$_esp);
2618 &popf (); 2618 &popf ();
2619&function_end("aes_cbc_encrypt_internal"); 2619&function_end("aes_cbc_encrypt_generic");
2620} 2620}
2621 2621
2622#------------------------------------------------------------------# 2622#------------------------------------------------------------------#
@@ -2849,12 +2849,12 @@ sub enckey()
2849 &set_label("exit"); 2849 &set_label("exit");
2850&function_end("_x86_AES_set_encrypt_key"); 2850&function_end("_x86_AES_set_encrypt_key");
2851 2851
2852# int aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits, 2852# int aes_set_encrypt_key_generic(const unsigned char *userKey, const int bits,
2853# AES_KEY *key) 2853# AES_KEY *key)
2854&function_begin_B("aes_set_encrypt_key_internal"); 2854&function_begin_B("aes_set_encrypt_key_generic");
2855 &call ("_x86_AES_set_encrypt_key"); 2855 &call ("_x86_AES_set_encrypt_key");
2856 &ret (); 2856 &ret ();
2857&function_end_B("aes_set_encrypt_key_internal"); 2857&function_end_B("aes_set_encrypt_key_generic");
2858 2858
2859sub deckey() 2859sub deckey()
2860{ my ($i,$key,$tp1,$tp2,$tp4,$tp8) = @_; 2860{ my ($i,$key,$tp1,$tp2,$tp4,$tp8) = @_;
@@ -2911,9 +2911,9 @@ sub deckey()
2911 &mov (&DWP(4*$i,$key),$tp1); 2911 &mov (&DWP(4*$i,$key),$tp1);
2912} 2912}
2913 2913
2914# int aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits, 2914# int aes_set_decrypt_key_generic(const unsigned char *userKey, const int bits,
2915# AES_KEY *key) 2915# AES_KEY *key)
2916&function_begin_B("aes_set_decrypt_key_internal"); 2916&function_begin_B("aes_set_decrypt_key_generic");
2917 &call ("_x86_AES_set_encrypt_key"); 2917 &call ("_x86_AES_set_encrypt_key");
2918 &cmp ("eax",0); 2918 &cmp ("eax",0);
2919 &je (&label("proceed")); 2919 &je (&label("proceed"));
@@ -2969,6 +2969,6 @@ sub deckey()
2969 &jb (&label("permute")); 2969 &jb (&label("permute"));
2970 2970
2971 &xor ("eax","eax"); # return success 2971 &xor ("eax","eax"); # return success
2972&function_end("aes_set_decrypt_key_internal"); 2972&function_end("aes_set_decrypt_key_generic");
2973 2973
2974&asm_finish(); 2974&asm_finish();
diff --git a/src/lib/libcrypto/aes/asm/aes-x86_64.pl b/src/lib/libcrypto/aes/asm/aes-x86_64.pl
index 324c4a2be2..2c73627546 100755
--- a/src/lib/libcrypto/aes/asm/aes-x86_64.pl
+++ b/src/lib/libcrypto/aes/asm/aes-x86_64.pl
@@ -586,15 +586,15 @@ $code.=<<___;
586.size _x86_64_AES_encrypt_compact,.-_x86_64_AES_encrypt_compact 586.size _x86_64_AES_encrypt_compact,.-_x86_64_AES_encrypt_compact
587___ 587___
588 588
589# void aes_encrypt_internal(const void *inp, void *out, const AES_KEY *key); 589# void aes_encrypt_generic(const void *inp, void *out, const AES_KEY *key);
590$code.=<<___; 590$code.=<<___;
591.globl aes_encrypt_internal 591.globl aes_encrypt_generic
592.type aes_encrypt_internal,\@function,3 592.type aes_encrypt_generic,\@function,3
593.align 16 593.align 16
594.globl asm_AES_encrypt 594.globl asm_AES_encrypt
595.hidden asm_AES_encrypt 595.hidden asm_AES_encrypt
596asm_AES_encrypt: 596asm_AES_encrypt:
597aes_encrypt_internal: 597aes_encrypt_generic:
598 _CET_ENDBR 598 _CET_ENDBR
599 push %rbx 599 push %rbx
600 push %rbp 600 push %rbp
@@ -655,7 +655,7 @@ aes_encrypt_internal:
655 lea 48(%rsi),%rsp 655 lea 48(%rsi),%rsp
656.Lenc_epilogue: 656.Lenc_epilogue:
657 ret 657 ret
658.size aes_encrypt_internal,.-aes_encrypt_internal 658.size aes_encrypt_generic,.-aes_encrypt_generic
659___ 659___
660 660
661#------------------------------------------------------------------# 661#------------------------------------------------------------------#
@@ -1188,15 +1188,15 @@ $code.=<<___;
1188.size _x86_64_AES_decrypt_compact,.-_x86_64_AES_decrypt_compact 1188.size _x86_64_AES_decrypt_compact,.-_x86_64_AES_decrypt_compact
1189___ 1189___
1190 1190
1191# void aes_decrypt_internal(const void *inp, void *out, const AES_KEY *key); 1191# void aes_decrypt_generic(const void *inp, void *out, const AES_KEY *key);
1192$code.=<<___; 1192$code.=<<___;
1193.globl aes_decrypt_internal 1193.globl aes_decrypt_generic
1194.type aes_decrypt_internal,\@function,3 1194.type aes_decrypt_generic,\@function,3
1195.align 16 1195.align 16
1196.globl asm_AES_decrypt 1196.globl asm_AES_decrypt
1197.hidden asm_AES_decrypt 1197.hidden asm_AES_decrypt
1198asm_AES_decrypt: 1198asm_AES_decrypt:
1199aes_decrypt_internal: 1199aes_decrypt_generic:
1200 _CET_ENDBR 1200 _CET_ENDBR
1201 push %rbx 1201 push %rbx
1202 push %rbp 1202 push %rbp
@@ -1259,7 +1259,7 @@ aes_decrypt_internal:
1259 lea 48(%rsi),%rsp 1259 lea 48(%rsi),%rsp
1260.Ldec_epilogue: 1260.Ldec_epilogue:
1261 ret 1261 ret
1262.size aes_decrypt_internal,.-aes_decrypt_internal 1262.size aes_decrypt_generic,.-aes_decrypt_generic
1263___ 1263___
1264#------------------------------------------------------------------# 1264#------------------------------------------------------------------#
1265 1265
@@ -1290,13 +1290,13 @@ $code.=<<___;
1290___ 1290___
1291} 1291}
1292 1292
1293# int aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits, 1293# int aes_set_encrypt_key_generic(const unsigned char *userKey, const int bits,
1294# AES_KEY *key) 1294# AES_KEY *key)
1295$code.=<<___; 1295$code.=<<___;
1296.globl aes_set_encrypt_key_internal 1296.globl aes_set_encrypt_key_generic
1297.type aes_set_encrypt_key_internal,\@function,3 1297.type aes_set_encrypt_key_generic,\@function,3
1298.align 16 1298.align 16
1299aes_set_encrypt_key_internal: 1299aes_set_encrypt_key_generic:
1300 _CET_ENDBR 1300 _CET_ENDBR
1301 push %rbx 1301 push %rbx
1302 push %rbp 1302 push %rbp
@@ -1318,7 +1318,7 @@ aes_set_encrypt_key_internal:
1318 add \$56,%rsp 1318 add \$56,%rsp
1319.Lenc_key_epilogue: 1319.Lenc_key_epilogue:
1320 ret 1320 ret
1321.size aes_set_encrypt_key_internal,.-aes_set_encrypt_key_internal 1321.size aes_set_encrypt_key_generic,.-aes_set_encrypt_key_generic
1322 1322
1323.type _x86_64_AES_set_encrypt_key,\@abi-omnipotent 1323.type _x86_64_AES_set_encrypt_key,\@abi-omnipotent
1324.align 16 1324.align 16
@@ -1562,13 +1562,13 @@ $code.=<<___;
1562___ 1562___
1563} 1563}
1564 1564
1565# int aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits, 1565# int aes_set_decrypt_key_generic(const unsigned char *userKey, const int bits,
1566# AES_KEY *key) 1566# AES_KEY *key)
1567$code.=<<___; 1567$code.=<<___;
1568.globl aes_set_decrypt_key_internal 1568.globl aes_set_decrypt_key_generic
1569.type aes_set_decrypt_key_internal,\@function,3 1569.type aes_set_decrypt_key_generic,\@function,3
1570.align 16 1570.align 16
1571aes_set_decrypt_key_internal: 1571aes_set_decrypt_key_generic:
1572 _CET_ENDBR 1572 _CET_ENDBR
1573 push %rbx 1573 push %rbx
1574 push %rbp 1574 push %rbp
@@ -1638,10 +1638,10 @@ $code.=<<___;
1638 add \$56,%rsp 1638 add \$56,%rsp
1639.Ldec_key_epilogue: 1639.Ldec_key_epilogue:
1640 ret 1640 ret
1641.size aes_set_decrypt_key_internal,.-aes_set_decrypt_key_internal 1641.size aes_set_decrypt_key_generic,.-aes_set_decrypt_key_generic
1642___ 1642___
1643 1643
1644# void aes_cbc_encrypt_internal(const void char *inp, unsigned char *out, 1644# void aes_cbc_encrypt_generic(const void char *inp, unsigned char *out,
1645# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc); 1645# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc);
1646{ 1646{
1647# stack frame layout 1647# stack frame layout
@@ -1659,15 +1659,15 @@ my $aes_key="80(%rsp)"; # copy of aes_key
1659my $mark="80+240(%rsp)"; # copy of aes_key->rounds 1659my $mark="80+240(%rsp)"; # copy of aes_key->rounds
1660 1660
1661$code.=<<___; 1661$code.=<<___;
1662.globl aes_cbc_encrypt_internal 1662.globl aes_cbc_encrypt_generic
1663.type aes_cbc_encrypt_internal,\@function,6 1663.type aes_cbc_encrypt_generic,\@function,6
1664.align 16 1664.align 16
1665.extern OPENSSL_ia32cap_P 1665.extern OPENSSL_ia32cap_P
1666.hidden OPENSSL_ia32cap_P 1666.hidden OPENSSL_ia32cap_P
1667.globl asm_AES_cbc_encrypt 1667.globl asm_AES_cbc_encrypt
1668.hidden asm_AES_cbc_encrypt 1668.hidden asm_AES_cbc_encrypt
1669asm_AES_cbc_encrypt: 1669asm_AES_cbc_encrypt:
1670aes_cbc_encrypt_internal: 1670aes_cbc_encrypt_generic:
1671 _CET_ENDBR 1671 _CET_ENDBR
1672 cmp \$0,%rdx # check length 1672 cmp \$0,%rdx # check length
1673 je .Lcbc_epilogue 1673 je .Lcbc_epilogue
@@ -2117,7 +2117,7 @@ aes_cbc_encrypt_internal:
2117 popfq 2117 popfq
2118.Lcbc_epilogue: 2118.Lcbc_epilogue:
2119 ret 2119 ret
2120.size aes_cbc_encrypt_internal,.-aes_cbc_encrypt_internal 2120.size aes_cbc_encrypt_generic,.-aes_cbc_encrypt_generic
2121___ 2121___
2122} 2122}
2123 2123
@@ -2782,45 +2782,45 @@ cbc_se_handler:
2782 2782
2783.section .pdata 2783.section .pdata
2784.align 4 2784.align 4
2785 .rva .LSEH_begin_aes_encrypt_internal 2785 .rva .LSEH_begin_aes_encrypt_generic
2786 .rva .LSEH_end_aes_encrypt_internal 2786 .rva .LSEH_end_aes_encrypt_generic
2787 .rva .LSEH_info_aes_encrypt_internal 2787 .rva .LSEH_info_aes_encrypt_generic
2788 2788
2789 .rva .LSEH_begin_aes_decrypt_internal 2789 .rva .LSEH_begin_aes_decrypt_generic
2790 .rva .LSEH_end_aes_decrypt_internal 2790 .rva .LSEH_end_aes_decrypt_generic
2791 .rva .LSEH_info_aes_decrypt_internal 2791 .rva .LSEH_info_aes_decrypt_generic
2792 2792
2793 .rva .LSEH_begin_aes_set_encrypt_key_internal 2793 .rva .LSEH_begin_aes_set_encrypt_key_generic
2794 .rva .LSEH_end_aes_set_encrypt_key_internal 2794 .rva .LSEH_end_aes_set_encrypt_key_generic
2795 .rva .LSEH_info_aes_set_encrypt_key_internal 2795 .rva .LSEH_info_aes_set_encrypt_key_generic
2796 2796
2797 .rva .LSEH_begin_aes_set_decrypt_key_internal 2797 .rva .LSEH_begin_aes_set_decrypt_key_generic
2798 .rva .LSEH_end_aes_set_decrypt_key_internal 2798 .rva .LSEH_end_aes_set_decrypt_key_generic
2799 .rva .LSEH_info_aes_set_decrypt_key_internal 2799 .rva .LSEH_info_aes_set_decrypt_key_generic
2800 2800
2801 .rva .LSEH_begin_aes_cbc_encrypt_internal 2801 .rva .LSEH_begin_aes_cbc_encrypt_generic
2802 .rva .LSEH_end_aes_cbc_encrypt_internal 2802 .rva .LSEH_end_aes_cbc_encrypt_generic
2803 .rva .LSEH_info_aes_cbc_encrypt_internal 2803 .rva .LSEH_info_aes_cbc_encrypt_generic
2804 2804
2805.section .xdata 2805.section .xdata
2806.align 8 2806.align 8
2807.LSEH_info_aes_encrypt_internal: 2807.LSEH_info_aes_encrypt_generic:
2808 .byte 9,0,0,0 2808 .byte 9,0,0,0
2809 .rva block_se_handler 2809 .rva block_se_handler
2810 .rva .Lenc_prologue,.Lenc_epilogue # HandlerData[] 2810 .rva .Lenc_prologue,.Lenc_epilogue # HandlerData[]
2811.LSEH_info_aes_decrypt_internal: 2811.LSEH_info_aes_decrypt_generic:
2812 .byte 9,0,0,0 2812 .byte 9,0,0,0
2813 .rva block_se_handler 2813 .rva block_se_handler
2814 .rva .Ldec_prologue,.Ldec_epilogue # HandlerData[] 2814 .rva .Ldec_prologue,.Ldec_epilogue # HandlerData[]
2815.LSEH_info_aes_set_encrypt_key_internal: 2815.LSEH_info_aes_set_encrypt_key_generic:
2816 .byte 9,0,0,0 2816 .byte 9,0,0,0
2817 .rva key_se_handler 2817 .rva key_se_handler
2818 .rva .Lenc_key_prologue,.Lenc_key_epilogue # HandlerData[] 2818 .rva .Lenc_key_prologue,.Lenc_key_epilogue # HandlerData[]
2819.LSEH_info_aes_set_decrypt_key_internal: 2819.LSEH_info_aes_set_decrypt_key_generic:
2820 .byte 9,0,0,0 2820 .byte 9,0,0,0
2821 .rva key_se_handler 2821 .rva key_se_handler
2822 .rva .Ldec_key_prologue,.Ldec_key_epilogue # HandlerData[] 2822 .rva .Ldec_key_prologue,.Ldec_key_epilogue # HandlerData[]
2823.LSEH_info_aes_cbc_encrypt_internal: 2823.LSEH_info_aes_cbc_encrypt_generic:
2824 .byte 9,0,0,0 2824 .byte 9,0,0,0
2825 .rva cbc_se_handler 2825 .rva cbc_se_handler
2826___ 2826___
diff --git a/src/lib/libcrypto/aes/asm/bsaes-x86_64.pl b/src/lib/libcrypto/aes/asm/bsaes-x86_64.pl
deleted file mode 100644
index c44a338114..0000000000
--- a/src/lib/libcrypto/aes/asm/bsaes-x86_64.pl
+++ /dev/null
@@ -1,3123 +0,0 @@
1#!/usr/bin/env perl
2
3###################################################################
4### AES-128 [originally in CTR mode] ###
5### bitsliced implementation for Intel Core 2 processors ###
6### requires support of SSE extensions up to SSSE3 ###
7### Author: Emilia Käsper and Peter Schwabe ###
8### Date: 2009-03-19 ###
9### Public domain ###
10### ###
11### See http://homes.esat.kuleuven.be/~ekasper/#software for ###
12### further information. ###
13###################################################################
14#
15# September 2011.
16#
17# Started as transliteration to "perlasm" the original code has
18# undergone following changes:
19#
20# - code was made position-independent;
21# - rounds were folded into a loop resulting in >5x size reduction
22# from 12.5KB to 2.2KB;
23# - above was possible thanks to mixcolumns() modification that
24# allowed to feed its output back to aesenc[last], this was
25# achieved at cost of two additional inter-registers moves;
26# - some instruction reordering and interleaving;
27# - this module doesn't implement key setup subroutine, instead it
28# relies on conversion of "conventional" key schedule as returned
29# by AES_set_encrypt_key (see discussion below);
30# - first and last round keys are treated differently, which allowed
31# to skip one shiftrows(), reduce bit-sliced key schedule and
32# speed-up conversion by 22%;
33# - support for 192- and 256-bit keys was added;
34#
35# Resulting performance in CPU cycles spent to encrypt one byte out
36# of 4096-byte buffer with 128-bit key is:
37#
38# Emilia's this(*) difference
39#
40# Core 2 9.30 8.69 +7%
41# Nehalem(**) 7.63 6.98 +9%
42# Atom 17.1 17.4 -2%(***)
43#
44# (*) Comparison is not completely fair, because "this" is ECB,
45# i.e. no extra processing such as counter values calculation
46# and xor-ing input as in Emilia's CTR implementation is
47# performed. However, the CTR calculations stand for not more
48# than 1% of total time, so comparison is *rather* fair.
49#
50# (**) Results were collected on Westmere, which is considered to
51# be equivalent to Nehalem for this code.
52#
53# (***) Slowdown on Atom is rather strange per se, because original
54# implementation has a number of 9+-bytes instructions, which
55# are bad for Atom front-end, and which I eliminated completely.
56# In attempt to address deterioration sbox() was tested in FP
57# SIMD "domain" (movaps instead of movdqa, xorps instead of
58# pxor, etc.). While it resulted in nominal 4% improvement on
59# Atom, it hurted Westmere by more than 2x factor.
60#
61# As for key schedule conversion subroutine. Interface to OpenSSL
62# relies on per-invocation on-the-fly conversion. This naturally
63# has impact on performance, especially for short inputs. Conversion
64# time in CPU cycles and its ratio to CPU cycles spent in 8x block
65# function is:
66#
67# conversion conversion/8x block
68# Core 2 240 0.22
69# Nehalem 180 0.20
70# Atom 430 0.19
71#
72# The ratio values mean that 128-byte blocks will be processed
73# 16-18% slower, 256-byte blocks - 9-10%, 384-byte blocks - 6-7%,
74# etc. Then keep in mind that input sizes not divisible by 128 are
75# *effectively* slower, especially shortest ones, e.g. consecutive
76# 144-byte blocks are processed 44% slower than one would expect,
77# 272 - 29%, 400 - 22%, etc. Yet, despite all these "shortcomings"
78# it's still faster than ["hyper-threading-safe" code path in]
79# aes-x86_64.pl on all lengths above 64 bytes...
80#
81# October 2011.
82#
83# Add decryption procedure. Performance in CPU cycles spent to decrypt
84# one byte out of 4096-byte buffer with 128-bit key is:
85#
86# Core 2 9.83
87# Nehalem 7.74
88# Atom 19.0
89#
90# November 2011.
91#
92# Add bsaes_xts_[en|de]crypt. Less-than-80-bytes-block performance is
93# suboptimal, but XTS is meant to be used with larger blocks...
94#
95# <appro@openssl.org>
96
97$flavour = shift;
98$output = shift;
99if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
100
101$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
102
103$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
104( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or
105( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
106die "can't locate x86_64-xlate.pl";
107
108open OUT,"| \"$^X\" $xlate $flavour $output";
109*STDOUT=*OUT;
110
111my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx");
112my @XMM=map("%xmm$_",(15,0..14)); # best on Atom, +10% over (0..15)
113my $ecb=0; # suppress unreferenced ECB subroutines, spare some space...
114
115{
116my ($key,$rounds,$const)=("%rax","%r10d","%r11");
117
118sub Sbox {
119# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb
120# output in lsb > [b0, b1, b4, b6, b3, b7, b2, b5] < msb
121my @b=@_[0..7];
122my @t=@_[8..11];
123my @s=@_[12..15];
124 &InBasisChange (@b);
125 &Inv_GF256 (@b[6,5,0,3,7,1,4,2],@t,@s);
126 &OutBasisChange (@b[7,1,4,2,6,5,0,3]);
127}
128
129sub InBasisChange {
130# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb
131# output in lsb > [b6, b5, b0, b3, b7, b1, b4, b2] < msb
132my @b=@_[0..7];
133$code.=<<___;
134 pxor @b[6], @b[5]
135 pxor @b[1], @b[2]
136 pxor @b[0], @b[3]
137 pxor @b[2], @b[6]
138 pxor @b[0], @b[5]
139
140 pxor @b[3], @b[6]
141 pxor @b[7], @b[3]
142 pxor @b[5], @b[7]
143 pxor @b[4], @b[3]
144 pxor @b[5], @b[4]
145 pxor @b[1], @b[3]
146
147 pxor @b[7], @b[2]
148 pxor @b[5], @b[1]
149___
150}
151
152sub OutBasisChange {
153# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb
154# output in lsb > [b6, b1, b2, b4, b7, b0, b3, b5] < msb
155my @b=@_[0..7];
156$code.=<<___;
157 pxor @b[6], @b[0]
158 pxor @b[4], @b[1]
159 pxor @b[0], @b[2]
160 pxor @b[6], @b[4]
161 pxor @b[1], @b[6]
162
163 pxor @b[5], @b[1]
164 pxor @b[3], @b[5]
165 pxor @b[7], @b[3]
166 pxor @b[5], @b[7]
167 pxor @b[5], @b[2]
168
169 pxor @b[7], @b[4]
170___
171}
172
173sub InvSbox {
174# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb
175# output in lsb > [b0, b1, b6, b4, b2, b7, b3, b5] < msb
176my @b=@_[0..7];
177my @t=@_[8..11];
178my @s=@_[12..15];
179 &InvInBasisChange (@b);
180 &Inv_GF256 (@b[5,1,2,6,3,7,0,4],@t,@s);
181 &InvOutBasisChange (@b[3,7,0,4,5,1,2,6]);
182}
183
184sub InvInBasisChange { # OutBasisChange in reverse
185my @b=@_[5,1,2,6,3,7,0,4];
186$code.=<<___
187 pxor @b[7], @b[4]
188
189 pxor @b[5], @b[7]
190 pxor @b[5], @b[2]
191 pxor @b[7], @b[3]
192 pxor @b[3], @b[5]
193 pxor @b[5], @b[1]
194
195 pxor @b[1], @b[6]
196 pxor @b[0], @b[2]
197 pxor @b[6], @b[4]
198 pxor @b[6], @b[0]
199 pxor @b[4], @b[1]
200___
201}
202
203sub InvOutBasisChange { # InBasisChange in reverse
204my @b=@_[2,5,7,3,6,1,0,4];
205$code.=<<___;
206 pxor @b[5], @b[1]
207 pxor @b[7], @b[2]
208
209 pxor @b[1], @b[3]
210 pxor @b[5], @b[4]
211 pxor @b[5], @b[7]
212 pxor @b[4], @b[3]
213 pxor @b[0], @b[5]
214 pxor @b[7], @b[3]
215 pxor @b[2], @b[6]
216 pxor @b[1], @b[2]
217 pxor @b[3], @b[6]
218
219 pxor @b[0], @b[3]
220 pxor @b[6], @b[5]
221___
222}
223
224sub Mul_GF4 {
225#;*************************************************************
226#;* Mul_GF4: Input x0-x1,y0-y1 Output x0-x1 Temp t0 (8) *
227#;*************************************************************
228my ($x0,$x1,$y0,$y1,$t0)=@_;
229$code.=<<___;
230 movdqa $y0, $t0
231 pxor $y1, $t0
232 pand $x0, $t0
233 pxor $x1, $x0
234 pand $y0, $x1
235 pand $y1, $x0
236 pxor $x1, $x0
237 pxor $t0, $x1
238___
239}
240
241sub Mul_GF4_N { # not used, see next subroutine
242# multiply and scale by N
243my ($x0,$x1,$y0,$y1,$t0)=@_;
244$code.=<<___;
245 movdqa $y0, $t0
246 pxor $y1, $t0
247 pand $x0, $t0
248 pxor $x1, $x0
249 pand $y0, $x1
250 pand $y1, $x0
251 pxor $x0, $x1
252 pxor $t0, $x0
253___
254}
255
256sub Mul_GF4_N_GF4 {
257# interleaved Mul_GF4_N and Mul_GF4
258my ($x0,$x1,$y0,$y1,$t0,
259 $x2,$x3,$y2,$y3,$t1)=@_;
260$code.=<<___;
261 movdqa $y0, $t0
262 movdqa $y2, $t1
263 pxor $y1, $t0
264 pxor $y3, $t1
265 pand $x0, $t0
266 pand $x2, $t1
267 pxor $x1, $x0
268 pxor $x3, $x2
269 pand $y0, $x1
270 pand $y2, $x3
271 pand $y1, $x0
272 pand $y3, $x2
273 pxor $x0, $x1
274 pxor $x3, $x2
275 pxor $t0, $x0
276 pxor $t1, $x3
277___
278}
279sub Mul_GF16_2 {
280my @x=@_[0..7];
281my @y=@_[8..11];
282my @t=@_[12..15];
283$code.=<<___;
284 movdqa @x[0], @t[0]
285 movdqa @x[1], @t[1]
286___
287 &Mul_GF4 (@x[0], @x[1], @y[0], @y[1], @t[2]);
288$code.=<<___;
289 pxor @x[2], @t[0]
290 pxor @x[3], @t[1]
291 pxor @y[2], @y[0]
292 pxor @y[3], @y[1]
293___
294 Mul_GF4_N_GF4 (@t[0], @t[1], @y[0], @y[1], @t[3],
295 @x[2], @x[3], @y[2], @y[3], @t[2]);
296$code.=<<___;
297 pxor @t[0], @x[0]
298 pxor @t[0], @x[2]
299 pxor @t[1], @x[1]
300 pxor @t[1], @x[3]
301
302 movdqa @x[4], @t[0]
303 movdqa @x[5], @t[1]
304 pxor @x[6], @t[0]
305 pxor @x[7], @t[1]
306___
307 &Mul_GF4_N_GF4 (@t[0], @t[1], @y[0], @y[1], @t[3],
308 @x[6], @x[7], @y[2], @y[3], @t[2]);
309$code.=<<___;
310 pxor @y[2], @y[0]
311 pxor @y[3], @y[1]
312___
313 &Mul_GF4 (@x[4], @x[5], @y[0], @y[1], @t[3]);
314$code.=<<___;
315 pxor @t[0], @x[4]
316 pxor @t[0], @x[6]
317 pxor @t[1], @x[5]
318 pxor @t[1], @x[7]
319___
320}
321sub Inv_GF256 {
322#;********************************************************************
323#;* Inv_GF256: Input x0-x7 Output x0-x7 Temp t0-t3,s0-s3 (144) *
324#;********************************************************************
325my @x=@_[0..7];
326my @t=@_[8..11];
327my @s=@_[12..15];
328# direct optimizations from hardware
329$code.=<<___;
330 movdqa @x[4], @t[3]
331 movdqa @x[5], @t[2]
332 movdqa @x[1], @t[1]
333 movdqa @x[7], @s[1]
334 movdqa @x[0], @s[0]
335
336 pxor @x[6], @t[3]
337 pxor @x[7], @t[2]
338 pxor @x[3], @t[1]
339 movdqa @t[3], @s[2]
340 pxor @x[6], @s[1]
341 movdqa @t[2], @t[0]
342 pxor @x[2], @s[0]
343 movdqa @t[3], @s[3]
344
345 por @t[1], @t[2]
346 por @s[0], @t[3]
347 pxor @t[0], @s[3]
348 pand @s[0], @s[2]
349 pxor @t[1], @s[0]
350 pand @t[1], @t[0]
351 pand @s[0], @s[3]
352 movdqa @x[3], @s[0]
353 pxor @x[2], @s[0]
354 pand @s[0], @s[1]
355 pxor @s[1], @t[3]
356 pxor @s[1], @t[2]
357 movdqa @x[4], @s[1]
358 movdqa @x[1], @s[0]
359 pxor @x[5], @s[1]
360 pxor @x[0], @s[0]
361 movdqa @s[1], @t[1]
362 pand @s[0], @s[1]
363 por @s[0], @t[1]
364 pxor @s[1], @t[0]
365 pxor @s[3], @t[3]
366 pxor @s[2], @t[2]
367 pxor @s[3], @t[1]
368 movdqa @x[7], @s[0]
369 pxor @s[2], @t[0]
370 movdqa @x[6], @s[1]
371 pxor @s[2], @t[1]
372 movdqa @x[5], @s[2]
373 pand @x[3], @s[0]
374 movdqa @x[4], @s[3]
375 pand @x[2], @s[1]
376 pand @x[1], @s[2]
377 por @x[0], @s[3]
378 pxor @s[0], @t[3]
379 pxor @s[1], @t[2]
380 pxor @s[2], @t[1]
381 pxor @s[3], @t[0]
382
383 #Inv_GF16 \t0, \t1, \t2, \t3, \s0, \s1, \s2, \s3
384
385 # new smaller inversion
386
387 movdqa @t[3], @s[0]
388 pand @t[1], @t[3]
389 pxor @t[2], @s[0]
390
391 movdqa @t[0], @s[2]
392 movdqa @s[0], @s[3]
393 pxor @t[3], @s[2]
394 pand @s[2], @s[3]
395
396 movdqa @t[1], @s[1]
397 pxor @t[2], @s[3]
398 pxor @t[0], @s[1]
399
400 pxor @t[2], @t[3]
401
402 pand @t[3], @s[1]
403
404 movdqa @s[2], @t[2]
405 pxor @t[0], @s[1]
406
407 pxor @s[1], @t[2]
408 pxor @s[1], @t[1]
409
410 pand @t[0], @t[2]
411
412 pxor @t[2], @s[2]
413 pxor @t[2], @t[1]
414
415 pand @s[3], @s[2]
416
417 pxor @s[0], @s[2]
418___
419# output in s3, s2, s1, t1
420
421# Mul_GF16_2 \x0, \x1, \x2, \x3, \x4, \x5, \x6, \x7, \t2, \t3, \t0, \t1, \s0, \s1, \s2, \s3
422
423# Mul_GF16_2 \x0, \x1, \x2, \x3, \x4, \x5, \x6, \x7, \s3, \s2, \s1, \t1, \s0, \t0, \t2, \t3
424 &Mul_GF16_2(@x,@s[3,2,1],@t[1],@s[0],@t[0,2,3]);
425
426### output msb > [x3,x2,x1,x0,x7,x6,x5,x4] < lsb
427}
428
429# AES linear components
430
431sub ShiftRows {
432my @x=@_[0..7];
433my $mask=pop;
434$code.=<<___;
435 pxor 0x00($key),@x[0]
436 pxor 0x10($key),@x[1]
437 pshufb $mask,@x[0]
438 pxor 0x20($key),@x[2]
439 pshufb $mask,@x[1]
440 pxor 0x30($key),@x[3]
441 pshufb $mask,@x[2]
442 pxor 0x40($key),@x[4]
443 pshufb $mask,@x[3]
444 pxor 0x50($key),@x[5]
445 pshufb $mask,@x[4]
446 pxor 0x60($key),@x[6]
447 pshufb $mask,@x[5]
448 pxor 0x70($key),@x[7]
449 pshufb $mask,@x[6]
450 lea 0x80($key),$key
451 pshufb $mask,@x[7]
452___
453}
454
455sub MixColumns {
456# modified to emit output in order suitable for feeding back to aesenc[last]
457my @x=@_[0..7];
458my @t=@_[8..15];
459my $inv=@_[16]; # optional
460$code.=<<___;
461 pshufd \$0x93, @x[0], @t[0] # x0 <<< 32
462 pshufd \$0x93, @x[1], @t[1]
463 pxor @t[0], @x[0] # x0 ^ (x0 <<< 32)
464 pshufd \$0x93, @x[2], @t[2]
465 pxor @t[1], @x[1]
466 pshufd \$0x93, @x[3], @t[3]
467 pxor @t[2], @x[2]
468 pshufd \$0x93, @x[4], @t[4]
469 pxor @t[3], @x[3]
470 pshufd \$0x93, @x[5], @t[5]
471 pxor @t[4], @x[4]
472 pshufd \$0x93, @x[6], @t[6]
473 pxor @t[5], @x[5]
474 pshufd \$0x93, @x[7], @t[7]
475 pxor @t[6], @x[6]
476 pxor @t[7], @x[7]
477
478 pxor @x[0], @t[1]
479 pxor @x[7], @t[0]
480 pxor @x[7], @t[1]
481 pshufd \$0x4E, @x[0], @x[0] # (x0 ^ (x0 <<< 32)) <<< 64)
482 pxor @x[1], @t[2]
483 pshufd \$0x4E, @x[1], @x[1]
484 pxor @x[4], @t[5]
485 pxor @t[0], @x[0]
486 pxor @x[5], @t[6]
487 pxor @t[1], @x[1]
488 pxor @x[3], @t[4]
489 pshufd \$0x4E, @x[4], @t[0]
490 pxor @x[6], @t[7]
491 pshufd \$0x4E, @x[5], @t[1]
492 pxor @x[2], @t[3]
493 pshufd \$0x4E, @x[3], @x[4]
494 pxor @x[7], @t[3]
495 pshufd \$0x4E, @x[7], @x[5]
496 pxor @x[7], @t[4]
497 pshufd \$0x4E, @x[6], @x[3]
498 pxor @t[4], @t[0]
499 pshufd \$0x4E, @x[2], @x[6]
500 pxor @t[5], @t[1]
501___
502$code.=<<___ if (!$inv);
503 pxor @t[3], @x[4]
504 pxor @t[7], @x[5]
505 pxor @t[6], @x[3]
506 movdqa @t[0], @x[2]
507 pxor @t[2], @x[6]
508 movdqa @t[1], @x[7]
509___
510$code.=<<___ if ($inv);
511 pxor @x[4], @t[3]
512 pxor @t[7], @x[5]
513 pxor @x[3], @t[6]
514 movdqa @t[0], @x[3]
515 pxor @t[2], @x[6]
516 movdqa @t[6], @x[2]
517 movdqa @t[1], @x[7]
518 movdqa @x[6], @x[4]
519 movdqa @t[3], @x[6]
520___
521}
522
523sub InvMixColumns_orig {
524my @x=@_[0..7];
525my @t=@_[8..15];
526
527$code.=<<___;
528 # multiplication by 0x0e
529 pshufd \$0x93, @x[7], @t[7]
530 movdqa @x[2], @t[2]
531 pxor @x[5], @x[7] # 7 5
532 pxor @x[5], @x[2] # 2 5
533 pshufd \$0x93, @x[0], @t[0]
534 movdqa @x[5], @t[5]
535 pxor @x[0], @x[5] # 5 0 [1]
536 pxor @x[1], @x[0] # 0 1
537 pshufd \$0x93, @x[1], @t[1]
538 pxor @x[2], @x[1] # 1 25
539 pxor @x[6], @x[0] # 01 6 [2]
540 pxor @x[3], @x[1] # 125 3 [4]
541 pshufd \$0x93, @x[3], @t[3]
542 pxor @x[0], @x[2] # 25 016 [3]
543 pxor @x[7], @x[3] # 3 75
544 pxor @x[6], @x[7] # 75 6 [0]
545 pshufd \$0x93, @x[6], @t[6]
546 movdqa @x[4], @t[4]
547 pxor @x[4], @x[6] # 6 4
548 pxor @x[3], @x[4] # 4 375 [6]
549 pxor @x[7], @x[3] # 375 756=36
550 pxor @t[5], @x[6] # 64 5 [7]
551 pxor @t[2], @x[3] # 36 2
552 pxor @t[4], @x[3] # 362 4 [5]
553 pshufd \$0x93, @t[5], @t[5]
554___
555 my @y = @x[7,5,0,2,1,3,4,6];
556$code.=<<___;
557 # multiplication by 0x0b
558 pxor @y[0], @y[1]
559 pxor @t[0], @y[0]
560 pxor @t[1], @y[1]
561 pshufd \$0x93, @t[2], @t[2]
562 pxor @t[5], @y[0]
563 pxor @t[6], @y[1]
564 pxor @t[7], @y[0]
565 pshufd \$0x93, @t[4], @t[4]
566 pxor @t[6], @t[7] # clobber t[7]
567 pxor @y[0], @y[1]
568
569 pxor @t[0], @y[3]
570 pshufd \$0x93, @t[0], @t[0]
571 pxor @t[1], @y[2]
572 pxor @t[1], @y[4]
573 pxor @t[2], @y[2]
574 pshufd \$0x93, @t[1], @t[1]
575 pxor @t[2], @y[3]
576 pxor @t[2], @y[5]
577 pxor @t[7], @y[2]
578 pshufd \$0x93, @t[2], @t[2]
579 pxor @t[3], @y[3]
580 pxor @t[3], @y[6]
581 pxor @t[3], @y[4]
582 pshufd \$0x93, @t[3], @t[3]
583 pxor @t[4], @y[7]
584 pxor @t[4], @y[5]
585 pxor @t[7], @y[7]
586 pxor @t[5], @y[3]
587 pxor @t[4], @y[4]
588 pxor @t[5], @t[7] # clobber t[7] even more
589
590 pxor @t[7], @y[5]
591 pshufd \$0x93, @t[4], @t[4]
592 pxor @t[7], @y[6]
593 pxor @t[7], @y[4]
594
595 pxor @t[5], @t[7]
596 pshufd \$0x93, @t[5], @t[5]
597 pxor @t[6], @t[7] # restore t[7]
598
599 # multiplication by 0x0d
600 pxor @y[7], @y[4]
601 pxor @t[4], @y[7]
602 pshufd \$0x93, @t[6], @t[6]
603 pxor @t[0], @y[2]
604 pxor @t[5], @y[7]
605 pxor @t[2], @y[2]
606 pshufd \$0x93, @t[7], @t[7]
607
608 pxor @y[1], @y[3]
609 pxor @t[1], @y[1]
610 pxor @t[0], @y[0]
611 pxor @t[0], @y[3]
612 pxor @t[5], @y[1]
613 pxor @t[5], @y[0]
614 pxor @t[7], @y[1]
615 pshufd \$0x93, @t[0], @t[0]
616 pxor @t[6], @y[0]
617 pxor @y[1], @y[3]
618 pxor @t[1], @y[4]
619 pshufd \$0x93, @t[1], @t[1]
620
621 pxor @t[7], @y[7]
622 pxor @t[2], @y[4]
623 pxor @t[2], @y[5]
624 pshufd \$0x93, @t[2], @t[2]
625 pxor @t[6], @y[2]
626 pxor @t[3], @t[6] # clobber t[6]
627 pxor @y[7], @y[4]
628 pxor @t[6], @y[3]
629
630 pxor @t[6], @y[6]
631 pxor @t[5], @y[5]
632 pxor @t[4], @y[6]
633 pshufd \$0x93, @t[4], @t[4]
634 pxor @t[6], @y[5]
635 pxor @t[7], @y[6]
636 pxor @t[3], @t[6] # restore t[6]
637
638 pshufd \$0x93, @t[5], @t[5]
639 pshufd \$0x93, @t[6], @t[6]
640 pshufd \$0x93, @t[7], @t[7]
641 pshufd \$0x93, @t[3], @t[3]
642
643 # multiplication by 0x09
644 pxor @y[1], @y[4]
645 pxor @y[1], @t[1] # t[1]=y[1]
646 pxor @t[5], @t[0] # clobber t[0]
647 pxor @t[5], @t[1]
648 pxor @t[0], @y[3]
649 pxor @y[0], @t[0] # t[0]=y[0]
650 pxor @t[6], @t[1]
651 pxor @t[7], @t[6] # clobber t[6]
652 pxor @t[1], @y[4]
653 pxor @t[4], @y[7]
654 pxor @y[4], @t[4] # t[4]=y[4]
655 pxor @t[3], @y[6]
656 pxor @y[3], @t[3] # t[3]=y[3]
657 pxor @t[2], @y[5]
658 pxor @y[2], @t[2] # t[2]=y[2]
659 pxor @t[7], @t[3]
660 pxor @y[5], @t[5] # t[5]=y[5]
661 pxor @t[6], @t[2]
662 pxor @t[6], @t[5]
663 pxor @y[6], @t[6] # t[6]=y[6]
664 pxor @y[7], @t[7] # t[7]=y[7]
665
666 movdqa @t[0],@XMM[0]
667 movdqa @t[1],@XMM[1]
668 movdqa @t[2],@XMM[2]
669 movdqa @t[3],@XMM[3]
670 movdqa @t[4],@XMM[4]
671 movdqa @t[5],@XMM[5]
672 movdqa @t[6],@XMM[6]
673 movdqa @t[7],@XMM[7]
674___
675}
676
677sub InvMixColumns {
678my @x=@_[0..7];
679my @t=@_[8..15];
680
681# Thanks to Jussi Kivilinna for providing pointer to
682#
683# | 0e 0b 0d 09 | | 02 03 01 01 | | 05 00 04 00 |
684# | 09 0e 0b 0d | = | 01 02 03 01 | x | 00 05 00 04 |
685# | 0d 09 0e 0b | | 01 01 02 03 | | 04 00 05 00 |
686# | 0b 0d 09 0e | | 03 01 01 02 | | 00 04 00 05 |
687
688$code.=<<___;
689 # multiplication by 0x05-0x00-0x04-0x00
690 pshufd \$0x4E, @x[0], @t[0]
691 pshufd \$0x4E, @x[6], @t[6]
692 pxor @x[0], @t[0]
693 pshufd \$0x4E, @x[7], @t[7]
694 pxor @x[6], @t[6]
695 pshufd \$0x4E, @x[1], @t[1]
696 pxor @x[7], @t[7]
697 pshufd \$0x4E, @x[2], @t[2]
698 pxor @x[1], @t[1]
699 pshufd \$0x4E, @x[3], @t[3]
700 pxor @x[2], @t[2]
701 pxor @t[6], @x[0]
702 pxor @t[6], @x[1]
703 pshufd \$0x4E, @x[4], @t[4]
704 pxor @x[3], @t[3]
705 pxor @t[0], @x[2]
706 pxor @t[1], @x[3]
707 pshufd \$0x4E, @x[5], @t[5]
708 pxor @x[4], @t[4]
709 pxor @t[7], @x[1]
710 pxor @t[2], @x[4]
711 pxor @x[5], @t[5]
712
713 pxor @t[7], @x[2]
714 pxor @t[6], @x[3]
715 pxor @t[6], @x[4]
716 pxor @t[3], @x[5]
717 pxor @t[4], @x[6]
718 pxor @t[7], @x[4]
719 pxor @t[7], @x[5]
720 pxor @t[5], @x[7]
721___
722 &MixColumns (@x,@t,1); # flipped 2<->3 and 4<->6
723}
724
725sub aesenc { # not used
726my @b=@_[0..7];
727my @t=@_[8..15];
728$code.=<<___;
729 movdqa 0x30($const),@t[0] # .LSR
730___
731 &ShiftRows (@b,@t[0]);
732 &Sbox (@b,@t);
733 &MixColumns (@b[0,1,4,6,3,7,2,5],@t);
734}
735
736sub aesenclast { # not used
737my @b=@_[0..7];
738my @t=@_[8..15];
739$code.=<<___;
740 movdqa 0x40($const),@t[0] # .LSRM0
741___
742 &ShiftRows (@b,@t[0]);
743 &Sbox (@b,@t);
744$code.=<<___
745 pxor 0x00($key),@b[0]
746 pxor 0x10($key),@b[1]
747 pxor 0x20($key),@b[4]
748 pxor 0x30($key),@b[6]
749 pxor 0x40($key),@b[3]
750 pxor 0x50($key),@b[7]
751 pxor 0x60($key),@b[2]
752 pxor 0x70($key),@b[5]
753___
754}
755
756sub swapmove {
757my ($a,$b,$n,$mask,$t)=@_;
758$code.=<<___;
759 movdqa $b,$t
760 psrlq \$$n,$b
761 pxor $a,$b
762 pand $mask,$b
763 pxor $b,$a
764 psllq \$$n,$b
765 pxor $t,$b
766___
767}
768sub swapmove2x {
769my ($a0,$b0,$a1,$b1,$n,$mask,$t0,$t1)=@_;
770$code.=<<___;
771 movdqa $b0,$t0
772 psrlq \$$n,$b0
773 movdqa $b1,$t1
774 psrlq \$$n,$b1
775 pxor $a0,$b0
776 pxor $a1,$b1
777 pand $mask,$b0
778 pand $mask,$b1
779 pxor $b0,$a0
780 psllq \$$n,$b0
781 pxor $b1,$a1
782 psllq \$$n,$b1
783 pxor $t0,$b0
784 pxor $t1,$b1
785___
786}
787
788sub bitslice {
789my @x=reverse(@_[0..7]);
790my ($t0,$t1,$t2,$t3)=@_[8..11];
791$code.=<<___;
792 movdqa 0x00($const),$t0 # .LBS0
793 movdqa 0x10($const),$t1 # .LBS1
794___
795 &swapmove2x(@x[0,1,2,3],1,$t0,$t2,$t3);
796 &swapmove2x(@x[4,5,6,7],1,$t0,$t2,$t3);
797$code.=<<___;
798 movdqa 0x20($const),$t0 # .LBS2
799___
800 &swapmove2x(@x[0,2,1,3],2,$t1,$t2,$t3);
801 &swapmove2x(@x[4,6,5,7],2,$t1,$t2,$t3);
802
803 &swapmove2x(@x[0,4,1,5],4,$t0,$t2,$t3);
804 &swapmove2x(@x[2,6,3,7],4,$t0,$t2,$t3);
805}
806
807$code.=<<___;
808.text
809
810.extern asm_AES_encrypt
811.extern asm_AES_decrypt
812
813.type _bsaes_encrypt8,\@abi-omnipotent
814.align 64
815_bsaes_encrypt8:
816 _CET_ENDBR
817 lea .LBS0(%rip), $const # constants table
818
819 movdqa ($key), @XMM[9] # round 0 key
820 lea 0x10($key), $key
821 movdqa 0x50($const), @XMM[8] # .LM0SR
822 pxor @XMM[9], @XMM[0] # xor with round0 key
823 pxor @XMM[9], @XMM[1]
824 pshufb @XMM[8], @XMM[0]
825 pxor @XMM[9], @XMM[2]
826 pshufb @XMM[8], @XMM[1]
827 pxor @XMM[9], @XMM[3]
828 pshufb @XMM[8], @XMM[2]
829 pxor @XMM[9], @XMM[4]
830 pshufb @XMM[8], @XMM[3]
831 pxor @XMM[9], @XMM[5]
832 pshufb @XMM[8], @XMM[4]
833 pxor @XMM[9], @XMM[6]
834 pshufb @XMM[8], @XMM[5]
835 pxor @XMM[9], @XMM[7]
836 pshufb @XMM[8], @XMM[6]
837 pshufb @XMM[8], @XMM[7]
838_bsaes_encrypt8_bitslice:
839___
840 &bitslice (@XMM[0..7, 8..11]);
841$code.=<<___;
842 dec $rounds
843 jmp .Lenc_sbox
844.align 16
845.Lenc_loop:
846___
847 &ShiftRows (@XMM[0..7, 8]);
848$code.=".Lenc_sbox:\n";
849 &Sbox (@XMM[0..7, 8..15]);
850$code.=<<___;
851 dec $rounds
852 jl .Lenc_done
853___
854 &MixColumns (@XMM[0,1,4,6,3,7,2,5, 8..15]);
855$code.=<<___;
856 movdqa 0x30($const), @XMM[8] # .LSR
857 jnz .Lenc_loop
858 movdqa 0x40($const), @XMM[8] # .LSRM0
859 jmp .Lenc_loop
860.align 16
861.Lenc_done:
862___
863 # output in lsb > [t0, t1, t4, t6, t3, t7, t2, t5] < msb
864 &bitslice (@XMM[0,1,4,6,3,7,2,5, 8..11]);
865$code.=<<___;
866 movdqa ($key), @XMM[8] # last round key
867 pxor @XMM[8], @XMM[4]
868 pxor @XMM[8], @XMM[6]
869 pxor @XMM[8], @XMM[3]
870 pxor @XMM[8], @XMM[7]
871 pxor @XMM[8], @XMM[2]
872 pxor @XMM[8], @XMM[5]
873 pxor @XMM[8], @XMM[0]
874 pxor @XMM[8], @XMM[1]
875 ret
876.size _bsaes_encrypt8,.-_bsaes_encrypt8
877
878.type _bsaes_decrypt8,\@abi-omnipotent
879.align 64
880_bsaes_decrypt8:
881 _CET_ENDBR
882 lea .LBS0(%rip), $const # constants table
883
884 movdqa ($key), @XMM[9] # round 0 key
885 lea 0x10($key), $key
886 movdqa -0x30($const), @XMM[8] # .LM0ISR
887 pxor @XMM[9], @XMM[0] # xor with round0 key
888 pxor @XMM[9], @XMM[1]
889 pshufb @XMM[8], @XMM[0]
890 pxor @XMM[9], @XMM[2]
891 pshufb @XMM[8], @XMM[1]
892 pxor @XMM[9], @XMM[3]
893 pshufb @XMM[8], @XMM[2]
894 pxor @XMM[9], @XMM[4]
895 pshufb @XMM[8], @XMM[3]
896 pxor @XMM[9], @XMM[5]
897 pshufb @XMM[8], @XMM[4]
898 pxor @XMM[9], @XMM[6]
899 pshufb @XMM[8], @XMM[5]
900 pxor @XMM[9], @XMM[7]
901 pshufb @XMM[8], @XMM[6]
902 pshufb @XMM[8], @XMM[7]
903___
904 &bitslice (@XMM[0..7, 8..11]);
905$code.=<<___;
906 dec $rounds
907 jmp .Ldec_sbox
908.align 16
909.Ldec_loop:
910___
911 &ShiftRows (@XMM[0..7, 8]);
912$code.=".Ldec_sbox:\n";
913 &InvSbox (@XMM[0..7, 8..15]);
914$code.=<<___;
915 dec $rounds
916 jl .Ldec_done
917___
918 &InvMixColumns (@XMM[0,1,6,4,2,7,3,5, 8..15]);
919$code.=<<___;
920 movdqa -0x10($const), @XMM[8] # .LISR
921 jnz .Ldec_loop
922 movdqa -0x20($const), @XMM[8] # .LISRM0
923 jmp .Ldec_loop
924.align 16
925.Ldec_done:
926___
927 &bitslice (@XMM[0,1,6,4,2,7,3,5, 8..11]);
928$code.=<<___;
929 movdqa ($key), @XMM[8] # last round key
930 pxor @XMM[8], @XMM[6]
931 pxor @XMM[8], @XMM[4]
932 pxor @XMM[8], @XMM[2]
933 pxor @XMM[8], @XMM[7]
934 pxor @XMM[8], @XMM[3]
935 pxor @XMM[8], @XMM[5]
936 pxor @XMM[8], @XMM[0]
937 pxor @XMM[8], @XMM[1]
938 ret
939.size _bsaes_decrypt8,.-_bsaes_decrypt8
940___
941}
942{
943my ($out,$inp,$rounds,$const)=("%rax","%rcx","%r10d","%r11");
944
945sub bitslice_key {
946my @x=reverse(@_[0..7]);
947my ($bs0,$bs1,$bs2,$t2,$t3)=@_[8..12];
948
949 &swapmove (@x[0,1],1,$bs0,$t2,$t3);
950$code.=<<___;
951 #&swapmove(@x[2,3],1,$t0,$t2,$t3);
952 movdqa @x[0], @x[2]
953 movdqa @x[1], @x[3]
954___
955 #&swapmove2x(@x[4,5,6,7],1,$t0,$t2,$t3);
956
957 &swapmove2x (@x[0,2,1,3],2,$bs1,$t2,$t3);
958$code.=<<___;
959 #&swapmove2x(@x[4,6,5,7],2,$t1,$t2,$t3);
960 movdqa @x[0], @x[4]
961 movdqa @x[2], @x[6]
962 movdqa @x[1], @x[5]
963 movdqa @x[3], @x[7]
964___
965 &swapmove2x (@x[0,4,1,5],4,$bs2,$t2,$t3);
966 &swapmove2x (@x[2,6,3,7],4,$bs2,$t2,$t3);
967}
968
969$code.=<<___;
970.type _bsaes_key_convert,\@abi-omnipotent
971.align 16
972_bsaes_key_convert:
973 _CET_ENDBR
974 lea .Lmasks(%rip), $const
975 movdqu ($inp), %xmm7 # load round 0 key
976 lea 0x10($inp), $inp
977 movdqa 0x00($const), %xmm0 # 0x01...
978 movdqa 0x10($const), %xmm1 # 0x02...
979 movdqa 0x20($const), %xmm2 # 0x04...
980 movdqa 0x30($const), %xmm3 # 0x08...
981 movdqa 0x40($const), %xmm4 # .LM0
982 pcmpeqd %xmm5, %xmm5 # .LNOT
983
984 movdqu ($inp), %xmm6 # load round 1 key
985 movdqa %xmm7, ($out) # save round 0 key
986 lea 0x10($out), $out
987 dec $rounds
988 jmp .Lkey_loop
989.align 16
990.Lkey_loop:
991 pshufb %xmm4, %xmm6 # .LM0
992
993 movdqa %xmm0, %xmm8
994 movdqa %xmm1, %xmm9
995
996 pand %xmm6, %xmm8
997 pand %xmm6, %xmm9
998 movdqa %xmm2, %xmm10
999 pcmpeqb %xmm0, %xmm8
1000 psllq \$4, %xmm0 # 0x10...
1001 movdqa %xmm3, %xmm11
1002 pcmpeqb %xmm1, %xmm9
1003 psllq \$4, %xmm1 # 0x20...
1004
1005 pand %xmm6, %xmm10
1006 pand %xmm6, %xmm11
1007 movdqa %xmm0, %xmm12
1008 pcmpeqb %xmm2, %xmm10
1009 psllq \$4, %xmm2 # 0x40...
1010 movdqa %xmm1, %xmm13
1011 pcmpeqb %xmm3, %xmm11
1012 psllq \$4, %xmm3 # 0x80...
1013
1014 movdqa %xmm2, %xmm14
1015 movdqa %xmm3, %xmm15
1016 pxor %xmm5, %xmm8 # "pnot"
1017 pxor %xmm5, %xmm9
1018
1019 pand %xmm6, %xmm12
1020 pand %xmm6, %xmm13
1021 movdqa %xmm8, 0x00($out) # write bit-sliced round key
1022 pcmpeqb %xmm0, %xmm12
1023 psrlq \$4, %xmm0 # 0x01...
1024 movdqa %xmm9, 0x10($out)
1025 pcmpeqb %xmm1, %xmm13
1026 psrlq \$4, %xmm1 # 0x02...
1027 lea 0x10($inp), $inp
1028
1029 pand %xmm6, %xmm14
1030 pand %xmm6, %xmm15
1031 movdqa %xmm10, 0x20($out)
1032 pcmpeqb %xmm2, %xmm14
1033 psrlq \$4, %xmm2 # 0x04...
1034 movdqa %xmm11, 0x30($out)
1035 pcmpeqb %xmm3, %xmm15
1036 psrlq \$4, %xmm3 # 0x08...
1037 movdqu ($inp), %xmm6 # load next round key
1038
1039 pxor %xmm5, %xmm13 # "pnot"
1040 pxor %xmm5, %xmm14
1041 movdqa %xmm12, 0x40($out)
1042 movdqa %xmm13, 0x50($out)
1043 movdqa %xmm14, 0x60($out)
1044 movdqa %xmm15, 0x70($out)
1045 lea 0x80($out),$out
1046 dec $rounds
1047 jnz .Lkey_loop
1048
1049 movdqa 0x50($const), %xmm7 # .L63
1050 #movdqa %xmm6, ($out) # don't save last round key
1051 ret
1052.size _bsaes_key_convert,.-_bsaes_key_convert
1053___
1054}
1055
1056if (0 && !$win64) { # following four functions are unsupported interface
1057 # used for benchmarking...
1058$code.=<<___;
1059.globl bsaes_enc_key_convert
1060.type bsaes_enc_key_convert,\@function,2
1061.align 16
1062bsaes_enc_key_convert:
1063 _CET_ENDBR
1064 mov 240($inp),%r10d # pass rounds
1065 mov $inp,%rcx # pass key
1066 mov $out,%rax # pass key schedule
1067 call _bsaes_key_convert
1068 pxor %xmm6,%xmm7 # fix up last round key
1069 movdqa %xmm7,(%rax) # save last round key
1070 ret
1071.size bsaes_enc_key_convert,.-bsaes_enc_key_convert
1072
1073.globl bsaes_encrypt_128
1074.type bsaes_encrypt_128,\@function,4
1075.align 16
1076bsaes_encrypt_128:
1077.Lenc128_loop:
1078 _CET_ENDBR
1079 movdqu 0x00($inp), @XMM[0] # load input
1080 movdqu 0x10($inp), @XMM[1]
1081 movdqu 0x20($inp), @XMM[2]
1082 movdqu 0x30($inp), @XMM[3]
1083 movdqu 0x40($inp), @XMM[4]
1084 movdqu 0x50($inp), @XMM[5]
1085 movdqu 0x60($inp), @XMM[6]
1086 movdqu 0x70($inp), @XMM[7]
1087 mov $key, %rax # pass the $key
1088 lea 0x80($inp), $inp
1089 mov \$10,%r10d
1090
1091 call _bsaes_encrypt8
1092
1093 movdqu @XMM[0], 0x00($out) # write output
1094 movdqu @XMM[1], 0x10($out)
1095 movdqu @XMM[4], 0x20($out)
1096 movdqu @XMM[6], 0x30($out)
1097 movdqu @XMM[3], 0x40($out)
1098 movdqu @XMM[7], 0x50($out)
1099 movdqu @XMM[2], 0x60($out)
1100 movdqu @XMM[5], 0x70($out)
1101 lea 0x80($out), $out
1102 sub \$0x80,$len
1103 ja .Lenc128_loop
1104 ret
1105.size bsaes_encrypt_128,.-bsaes_encrypt_128
1106
1107.globl bsaes_dec_key_convert
1108.type bsaes_dec_key_convert,\@function,2
1109.align 16
1110bsaes_dec_key_convert:
1111 _CET_ENDBR
1112 mov 240($inp),%r10d # pass rounds
1113 mov $inp,%rcx # pass key
1114 mov $out,%rax # pass key schedule
1115 call _bsaes_key_convert
1116 pxor ($out),%xmm7 # fix up round 0 key
1117 movdqa %xmm6,(%rax) # save last round key
1118 movdqa %xmm7,($out)
1119 ret
1120.size bsaes_dec_key_convert,.-bsaes_dec_key_convert
1121
1122.globl bsaes_decrypt_128
1123.type bsaes_decrypt_128,\@function,4
1124.align 16
1125bsaes_decrypt_128:
1126 _CET_ENDBR
1127.Ldec128_loop:
1128 movdqu 0x00($inp), @XMM[0] # load input
1129 movdqu 0x10($inp), @XMM[1]
1130 movdqu 0x20($inp), @XMM[2]
1131 movdqu 0x30($inp), @XMM[3]
1132 movdqu 0x40($inp), @XMM[4]
1133 movdqu 0x50($inp), @XMM[5]
1134 movdqu 0x60($inp), @XMM[6]
1135 movdqu 0x70($inp), @XMM[7]
1136 mov $key, %rax # pass the $key
1137 lea 0x80($inp), $inp
1138 mov \$10,%r10d
1139
1140 call _bsaes_decrypt8
1141
1142 movdqu @XMM[0], 0x00($out) # write output
1143 movdqu @XMM[1], 0x10($out)
1144 movdqu @XMM[6], 0x20($out)
1145 movdqu @XMM[4], 0x30($out)
1146 movdqu @XMM[2], 0x40($out)
1147 movdqu @XMM[7], 0x50($out)
1148 movdqu @XMM[3], 0x60($out)
1149 movdqu @XMM[5], 0x70($out)
1150 lea 0x80($out), $out
1151 sub \$0x80,$len
1152 ja .Ldec128_loop
1153 ret
1154.size bsaes_decrypt_128,.-bsaes_decrypt_128
1155___
1156}
1157{
1158######################################################################
1159#
1160# OpenSSL interface
1161#
1162my ($arg1,$arg2,$arg3,$arg4,$arg5,$arg6)=$win64 ? ("%rcx","%rdx","%r8","%r9","%r10","%r11d")
1163 : ("%rdi","%rsi","%rdx","%rcx","%r8","%r9d");
1164my ($inp,$out,$len,$key)=("%r12","%r13","%r14","%r15");
1165
1166if ($ecb) {
1167$code.=<<___;
1168.globl bsaes_ecb_encrypt_blocks
1169.type bsaes_ecb_encrypt_blocks,\@abi-omnipotent
1170.align 16
1171bsaes_ecb_encrypt_blocks:
1172 _CET_ENDBR
1173 mov %rsp, %rax
1174.Lecb_enc_prologue:
1175 push %rbp
1176 push %rbx
1177 push %r12
1178 push %r13
1179 push %r14
1180 push %r15
1181 lea -0x48(%rsp),%rsp
1182___
1183$code.=<<___ if ($win64);
1184 lea -0xa0(%rsp), %rsp
1185 movaps %xmm6, 0x40(%rsp)
1186 movaps %xmm7, 0x50(%rsp)
1187 movaps %xmm8, 0x60(%rsp)
1188 movaps %xmm9, 0x70(%rsp)
1189 movaps %xmm10, 0x80(%rsp)
1190 movaps %xmm11, 0x90(%rsp)
1191 movaps %xmm12, 0xa0(%rsp)
1192 movaps %xmm13, 0xb0(%rsp)
1193 movaps %xmm14, 0xc0(%rsp)
1194 movaps %xmm15, 0xd0(%rsp)
1195.Lecb_enc_body:
1196___
1197$code.=<<___;
1198 mov %rsp,%rbp # backup %rsp
1199 mov 240($arg4),%eax # rounds
1200 mov $arg1,$inp # backup arguments
1201 mov $arg2,$out
1202 mov $arg3,$len
1203 mov $arg4,$key
1204 cmp \$8,$arg3
1205 jb .Lecb_enc_short
1206
1207 mov %eax,%ebx # backup rounds
1208 shl \$7,%rax # 128 bytes per inner round key
1209 sub \$`128-32`,%rax # size of bit-sliced key schedule
1210 sub %rax,%rsp
1211 mov %rsp,%rax # pass key schedule
1212 mov $key,%rcx # pass key
1213 mov %ebx,%r10d # pass rounds
1214 call _bsaes_key_convert
1215 pxor %xmm6,%xmm7 # fix up last round key
1216 movdqa %xmm7,(%rax) # save last round key
1217
1218 sub \$8,$len
1219.Lecb_enc_loop:
1220 movdqu 0x00($inp), @XMM[0] # load input
1221 movdqu 0x10($inp), @XMM[1]
1222 movdqu 0x20($inp), @XMM[2]
1223 movdqu 0x30($inp), @XMM[3]
1224 movdqu 0x40($inp), @XMM[4]
1225 movdqu 0x50($inp), @XMM[5]
1226 mov %rsp, %rax # pass key schedule
1227 movdqu 0x60($inp), @XMM[6]
1228 mov %ebx,%r10d # pass rounds
1229 movdqu 0x70($inp), @XMM[7]
1230 lea 0x80($inp), $inp
1231
1232 call _bsaes_encrypt8
1233
1234 movdqu @XMM[0], 0x00($out) # write output
1235 movdqu @XMM[1], 0x10($out)
1236 movdqu @XMM[4], 0x20($out)
1237 movdqu @XMM[6], 0x30($out)
1238 movdqu @XMM[3], 0x40($out)
1239 movdqu @XMM[7], 0x50($out)
1240 movdqu @XMM[2], 0x60($out)
1241 movdqu @XMM[5], 0x70($out)
1242 lea 0x80($out), $out
1243 sub \$8,$len
1244 jnc .Lecb_enc_loop
1245
1246 add \$8,$len
1247 jz .Lecb_enc_done
1248
1249 movdqu 0x00($inp), @XMM[0] # load input
1250 mov %rsp, %rax # pass key schedule
1251 mov %ebx,%r10d # pass rounds
1252 cmp \$2,$len
1253 jb .Lecb_enc_one
1254 movdqu 0x10($inp), @XMM[1]
1255 je .Lecb_enc_two
1256 movdqu 0x20($inp), @XMM[2]
1257 cmp \$4,$len
1258 jb .Lecb_enc_three
1259 movdqu 0x30($inp), @XMM[3]
1260 je .Lecb_enc_four
1261 movdqu 0x40($inp), @XMM[4]
1262 cmp \$6,$len
1263 jb .Lecb_enc_five
1264 movdqu 0x50($inp), @XMM[5]
1265 je .Lecb_enc_six
1266 movdqu 0x60($inp), @XMM[6]
1267 call _bsaes_encrypt8
1268 movdqu @XMM[0], 0x00($out) # write output
1269 movdqu @XMM[1], 0x10($out)
1270 movdqu @XMM[4], 0x20($out)
1271 movdqu @XMM[6], 0x30($out)
1272 movdqu @XMM[3], 0x40($out)
1273 movdqu @XMM[7], 0x50($out)
1274 movdqu @XMM[2], 0x60($out)
1275 jmp .Lecb_enc_done
1276.align 16
1277.Lecb_enc_six:
1278 call _bsaes_encrypt8
1279 movdqu @XMM[0], 0x00($out) # write output
1280 movdqu @XMM[1], 0x10($out)
1281 movdqu @XMM[4], 0x20($out)
1282 movdqu @XMM[6], 0x30($out)
1283 movdqu @XMM[3], 0x40($out)
1284 movdqu @XMM[7], 0x50($out)
1285 jmp .Lecb_enc_done
1286.align 16
1287.Lecb_enc_five:
1288 call _bsaes_encrypt8
1289 movdqu @XMM[0], 0x00($out) # write output
1290 movdqu @XMM[1], 0x10($out)
1291 movdqu @XMM[4], 0x20($out)
1292 movdqu @XMM[6], 0x30($out)
1293 movdqu @XMM[3], 0x40($out)
1294 jmp .Lecb_enc_done
1295.align 16
1296.Lecb_enc_four:
1297 call _bsaes_encrypt8
1298 movdqu @XMM[0], 0x00($out) # write output
1299 movdqu @XMM[1], 0x10($out)
1300 movdqu @XMM[4], 0x20($out)
1301 movdqu @XMM[6], 0x30($out)
1302 jmp .Lecb_enc_done
1303.align 16
1304.Lecb_enc_three:
1305 call _bsaes_encrypt8
1306 movdqu @XMM[0], 0x00($out) # write output
1307 movdqu @XMM[1], 0x10($out)
1308 movdqu @XMM[4], 0x20($out)
1309 jmp .Lecb_enc_done
1310.align 16
1311.Lecb_enc_two:
1312 call _bsaes_encrypt8
1313 movdqu @XMM[0], 0x00($out) # write output
1314 movdqu @XMM[1], 0x10($out)
1315 jmp .Lecb_enc_done
1316.align 16
1317.Lecb_enc_one:
1318 call _bsaes_encrypt8
1319 movdqu @XMM[0], 0x00($out) # write output
1320 jmp .Lecb_enc_done
1321.align 16
1322.Lecb_enc_short:
1323 lea ($inp), $arg1
1324 lea ($out), $arg2
1325 lea ($key), $arg3
1326 call asm_AES_encrypt
1327 lea 16($inp), $inp
1328 lea 16($out), $out
1329 dec $len
1330 jnz .Lecb_enc_short
1331
1332.Lecb_enc_done:
1333 lea (%rsp),%rax
1334 pxor %xmm0, %xmm0
1335.Lecb_enc_bzero: # wipe key schedule [if any]
1336 movdqa %xmm0, 0x00(%rax)
1337 movdqa %xmm0, 0x10(%rax)
1338 lea 0x20(%rax), %rax
1339 cmp %rax, %rbp
1340 jb .Lecb_enc_bzero
1341
1342 lea (%rbp),%rsp # restore %rsp
1343___
1344$code.=<<___ if ($win64);
1345 movaps 0x40(%rbp), %xmm6
1346 movaps 0x50(%rbp), %xmm7
1347 movaps 0x60(%rbp), %xmm8
1348 movaps 0x70(%rbp), %xmm9
1349 movaps 0x80(%rbp), %xmm10
1350 movaps 0x90(%rbp), %xmm11
1351 movaps 0xa0(%rbp), %xmm12
1352 movaps 0xb0(%rbp), %xmm13
1353 movaps 0xc0(%rbp), %xmm14
1354 movaps 0xd0(%rbp), %xmm15
1355 lea 0xa0(%rbp), %rsp
1356___
1357$code.=<<___;
1358 mov 0x48(%rsp), %r15
1359 mov 0x50(%rsp), %r14
1360 mov 0x58(%rsp), %r13
1361 mov 0x60(%rsp), %r12
1362 mov 0x68(%rsp), %rbx
1363 mov 0x70(%rsp), %rax
1364 lea 0x78(%rsp), %rsp
1365 mov %rax, %rbp
1366.Lecb_enc_epilogue:
1367 ret
1368.size bsaes_ecb_encrypt_blocks,.-bsaes_ecb_encrypt_blocks
1369
1370.globl bsaes_ecb_decrypt_blocks
1371.type bsaes_ecb_decrypt_blocks,\@abi-omnipotent
1372.align 16
1373bsaes_ecb_decrypt_blocks:
1374 _CET_ENDBR
1375 mov %rsp, %rax
1376.Lecb_dec_prologue:
1377 push %rbp
1378 push %rbx
1379 push %r12
1380 push %r13
1381 push %r14
1382 push %r15
1383 lea -0x48(%rsp),%rsp
1384___
1385$code.=<<___ if ($win64);
1386 lea -0xa0(%rsp), %rsp
1387 movaps %xmm6, 0x40(%rsp)
1388 movaps %xmm7, 0x50(%rsp)
1389 movaps %xmm8, 0x60(%rsp)
1390 movaps %xmm9, 0x70(%rsp)
1391 movaps %xmm10, 0x80(%rsp)
1392 movaps %xmm11, 0x90(%rsp)
1393 movaps %xmm12, 0xa0(%rsp)
1394 movaps %xmm13, 0xb0(%rsp)
1395 movaps %xmm14, 0xc0(%rsp)
1396 movaps %xmm15, 0xd0(%rsp)
1397.Lecb_dec_body:
1398___
1399$code.=<<___;
1400 mov %rsp,%rbp # backup %rsp
1401 mov 240($arg4),%eax # rounds
1402 mov $arg1,$inp # backup arguments
1403 mov $arg2,$out
1404 mov $arg3,$len
1405 mov $arg4,$key
1406 cmp \$8,$arg3
1407 jb .Lecb_dec_short
1408
1409 mov %eax,%ebx # backup rounds
1410 shl \$7,%rax # 128 bytes per inner round key
1411 sub \$`128-32`,%rax # size of bit-sliced key schedule
1412 sub %rax,%rsp
1413 mov %rsp,%rax # pass key schedule
1414 mov $key,%rcx # pass key
1415 mov %ebx,%r10d # pass rounds
1416 call _bsaes_key_convert
1417 pxor (%rsp),%xmm7 # fix up 0 round key
1418 movdqa %xmm6,(%rax) # save last round key
1419 movdqa %xmm7,(%rsp)
1420
1421 sub \$8,$len
1422.Lecb_dec_loop:
1423 movdqu 0x00($inp), @XMM[0] # load input
1424 movdqu 0x10($inp), @XMM[1]
1425 movdqu 0x20($inp), @XMM[2]
1426 movdqu 0x30($inp), @XMM[3]
1427 movdqu 0x40($inp), @XMM[4]
1428 movdqu 0x50($inp), @XMM[5]
1429 mov %rsp, %rax # pass key schedule
1430 movdqu 0x60($inp), @XMM[6]
1431 mov %ebx,%r10d # pass rounds
1432 movdqu 0x70($inp), @XMM[7]
1433 lea 0x80($inp), $inp
1434
1435 call _bsaes_decrypt8
1436
1437 movdqu @XMM[0], 0x00($out) # write output
1438 movdqu @XMM[1], 0x10($out)
1439 movdqu @XMM[6], 0x20($out)
1440 movdqu @XMM[4], 0x30($out)
1441 movdqu @XMM[2], 0x40($out)
1442 movdqu @XMM[7], 0x50($out)
1443 movdqu @XMM[3], 0x60($out)
1444 movdqu @XMM[5], 0x70($out)
1445 lea 0x80($out), $out
1446 sub \$8,$len
1447 jnc .Lecb_dec_loop
1448
1449 add \$8,$len
1450 jz .Lecb_dec_done
1451
1452 movdqu 0x00($inp), @XMM[0] # load input
1453 mov %rsp, %rax # pass key schedule
1454 mov %ebx,%r10d # pass rounds
1455 cmp \$2,$len
1456 jb .Lecb_dec_one
1457 movdqu 0x10($inp), @XMM[1]
1458 je .Lecb_dec_two
1459 movdqu 0x20($inp), @XMM[2]
1460 cmp \$4,$len
1461 jb .Lecb_dec_three
1462 movdqu 0x30($inp), @XMM[3]
1463 je .Lecb_dec_four
1464 movdqu 0x40($inp), @XMM[4]
1465 cmp \$6,$len
1466 jb .Lecb_dec_five
1467 movdqu 0x50($inp), @XMM[5]
1468 je .Lecb_dec_six
1469 movdqu 0x60($inp), @XMM[6]
1470 call _bsaes_decrypt8
1471 movdqu @XMM[0], 0x00($out) # write output
1472 movdqu @XMM[1], 0x10($out)
1473 movdqu @XMM[6], 0x20($out)
1474 movdqu @XMM[4], 0x30($out)
1475 movdqu @XMM[2], 0x40($out)
1476 movdqu @XMM[7], 0x50($out)
1477 movdqu @XMM[3], 0x60($out)
1478 jmp .Lecb_dec_done
1479.align 16
1480.Lecb_dec_six:
1481 call _bsaes_decrypt8
1482 movdqu @XMM[0], 0x00($out) # write output
1483 movdqu @XMM[1], 0x10($out)
1484 movdqu @XMM[6], 0x20($out)
1485 movdqu @XMM[4], 0x30($out)
1486 movdqu @XMM[2], 0x40($out)
1487 movdqu @XMM[7], 0x50($out)
1488 jmp .Lecb_dec_done
1489.align 16
1490.Lecb_dec_five:
1491 call _bsaes_decrypt8
1492 movdqu @XMM[0], 0x00($out) # write output
1493 movdqu @XMM[1], 0x10($out)
1494 movdqu @XMM[6], 0x20($out)
1495 movdqu @XMM[4], 0x30($out)
1496 movdqu @XMM[2], 0x40($out)
1497 jmp .Lecb_dec_done
1498.align 16
1499.Lecb_dec_four:
1500 call _bsaes_decrypt8
1501 movdqu @XMM[0], 0x00($out) # write output
1502 movdqu @XMM[1], 0x10($out)
1503 movdqu @XMM[6], 0x20($out)
1504 movdqu @XMM[4], 0x30($out)
1505 jmp .Lecb_dec_done
1506.align 16
1507.Lecb_dec_three:
1508 call _bsaes_decrypt8
1509 movdqu @XMM[0], 0x00($out) # write output
1510 movdqu @XMM[1], 0x10($out)
1511 movdqu @XMM[6], 0x20($out)
1512 jmp .Lecb_dec_done
1513.align 16
1514.Lecb_dec_two:
1515 call _bsaes_decrypt8
1516 movdqu @XMM[0], 0x00($out) # write output
1517 movdqu @XMM[1], 0x10($out)
1518 jmp .Lecb_dec_done
1519.align 16
1520.Lecb_dec_one:
1521 call _bsaes_decrypt8
1522 movdqu @XMM[0], 0x00($out) # write output
1523 jmp .Lecb_dec_done
1524.align 16
1525.Lecb_dec_short:
1526 lea ($inp), $arg1
1527 lea ($out), $arg2
1528 lea ($key), $arg3
1529 call asm_AES_decrypt
1530 lea 16($inp), $inp
1531 lea 16($out), $out
1532 dec $len
1533 jnz .Lecb_dec_short
1534
1535.Lecb_dec_done:
1536 lea (%rsp),%rax
1537 pxor %xmm0, %xmm0
1538.Lecb_dec_bzero: # wipe key schedule [if any]
1539 movdqa %xmm0, 0x00(%rax)
1540 movdqa %xmm0, 0x10(%rax)
1541 lea 0x20(%rax), %rax
1542 cmp %rax, %rbp
1543 jb .Lecb_dec_bzero
1544
1545 lea (%rbp),%rsp # restore %rsp
1546___
1547$code.=<<___ if ($win64);
1548 movaps 0x40(%rbp), %xmm6
1549 movaps 0x50(%rbp), %xmm7
1550 movaps 0x60(%rbp), %xmm8
1551 movaps 0x70(%rbp), %xmm9
1552 movaps 0x80(%rbp), %xmm10
1553 movaps 0x90(%rbp), %xmm11
1554 movaps 0xa0(%rbp), %xmm12
1555 movaps 0xb0(%rbp), %xmm13
1556 movaps 0xc0(%rbp), %xmm14
1557 movaps 0xd0(%rbp), %xmm15
1558 lea 0xa0(%rbp), %rsp
1559___
1560$code.=<<___;
1561 mov 0x48(%rsp), %r15
1562 mov 0x50(%rsp), %r14
1563 mov 0x58(%rsp), %r13
1564 mov 0x60(%rsp), %r12
1565 mov 0x68(%rsp), %rbx
1566 mov 0x70(%rsp), %rax
1567 lea 0x78(%rsp), %rsp
1568 mov %rax, %rbp
1569.Lecb_dec_epilogue:
1570 ret
1571.size bsaes_ecb_decrypt_blocks,.-bsaes_ecb_decrypt_blocks
1572___
1573}
1574$code.=<<___;
1575.extern asm_AES_cbc_encrypt
1576.globl bsaes_cbc_encrypt
1577.type bsaes_cbc_encrypt,\@abi-omnipotent
1578.align 16
1579bsaes_cbc_encrypt:
1580 _CET_ENDBR
1581___
1582$code.=<<___ if ($win64);
1583 mov 48(%rsp),$arg6 # pull direction flag
1584___
1585$code.=<<___;
1586 cmp \$0,$arg6
1587 jne asm_AES_cbc_encrypt
1588 cmp \$128,$arg3
1589 jb asm_AES_cbc_encrypt
1590
1591 mov %rsp, %rax
1592.Lcbc_dec_prologue:
1593 push %rbp
1594 push %rbx
1595 push %r12
1596 push %r13
1597 push %r14
1598 push %r15
1599 lea -0x48(%rsp), %rsp
1600___
1601$code.=<<___ if ($win64);
1602 mov 0xa0(%rsp),$arg5 # pull ivp
1603 lea -0xa0(%rsp), %rsp
1604 movaps %xmm6, 0x40(%rsp)
1605 movaps %xmm7, 0x50(%rsp)
1606 movaps %xmm8, 0x60(%rsp)
1607 movaps %xmm9, 0x70(%rsp)
1608 movaps %xmm10, 0x80(%rsp)
1609 movaps %xmm11, 0x90(%rsp)
1610 movaps %xmm12, 0xa0(%rsp)
1611 movaps %xmm13, 0xb0(%rsp)
1612 movaps %xmm14, 0xc0(%rsp)
1613 movaps %xmm15, 0xd0(%rsp)
1614.Lcbc_dec_body:
1615___
1616$code.=<<___;
1617 mov %rsp, %rbp # backup %rsp
1618 mov 240($arg4), %eax # rounds
1619 mov $arg1, $inp # backup arguments
1620 mov $arg2, $out
1621 mov $arg3, $len
1622 mov $arg4, $key
1623 mov $arg5, %rbx
1624 shr \$4, $len # bytes to blocks
1625
1626 mov %eax, %edx # rounds
1627 shl \$7, %rax # 128 bytes per inner round key
1628 sub \$`128-32`, %rax # size of bit-sliced key schedule
1629 sub %rax, %rsp
1630
1631 mov %rsp, %rax # pass key schedule
1632 mov $key, %rcx # pass key
1633 mov %edx, %r10d # pass rounds
1634 call _bsaes_key_convert
1635 pxor (%rsp),%xmm7 # fix up 0 round key
1636 movdqa %xmm6,(%rax) # save last round key
1637 movdqa %xmm7,(%rsp)
1638
1639 movdqu (%rbx), @XMM[15] # load IV
1640 sub \$8,$len
1641.Lcbc_dec_loop:
1642 movdqu 0x00($inp), @XMM[0] # load input
1643 movdqu 0x10($inp), @XMM[1]
1644 movdqu 0x20($inp), @XMM[2]
1645 movdqu 0x30($inp), @XMM[3]
1646 movdqu 0x40($inp), @XMM[4]
1647 movdqu 0x50($inp), @XMM[5]
1648 mov %rsp, %rax # pass key schedule
1649 movdqu 0x60($inp), @XMM[6]
1650 mov %edx,%r10d # pass rounds
1651 movdqu 0x70($inp), @XMM[7]
1652 movdqa @XMM[15], 0x20(%rbp) # put aside IV
1653
1654 call _bsaes_decrypt8
1655
1656 pxor 0x20(%rbp), @XMM[0] # ^= IV
1657 movdqu 0x00($inp), @XMM[8] # re-load input
1658 movdqu 0x10($inp), @XMM[9]
1659 pxor @XMM[8], @XMM[1]
1660 movdqu 0x20($inp), @XMM[10]
1661 pxor @XMM[9], @XMM[6]
1662 movdqu 0x30($inp), @XMM[11]
1663 pxor @XMM[10], @XMM[4]
1664 movdqu 0x40($inp), @XMM[12]
1665 pxor @XMM[11], @XMM[2]
1666 movdqu 0x50($inp), @XMM[13]
1667 pxor @XMM[12], @XMM[7]
1668 movdqu 0x60($inp), @XMM[14]
1669 pxor @XMM[13], @XMM[3]
1670 movdqu 0x70($inp), @XMM[15] # IV
1671 pxor @XMM[14], @XMM[5]
1672 movdqu @XMM[0], 0x00($out) # write output
1673 lea 0x80($inp), $inp
1674 movdqu @XMM[1], 0x10($out)
1675 movdqu @XMM[6], 0x20($out)
1676 movdqu @XMM[4], 0x30($out)
1677 movdqu @XMM[2], 0x40($out)
1678 movdqu @XMM[7], 0x50($out)
1679 movdqu @XMM[3], 0x60($out)
1680 movdqu @XMM[5], 0x70($out)
1681 lea 0x80($out), $out
1682 sub \$8,$len
1683 jnc .Lcbc_dec_loop
1684
1685 add \$8,$len
1686 jz .Lcbc_dec_done
1687
1688 movdqu 0x00($inp), @XMM[0] # load input
1689 mov %rsp, %rax # pass key schedule
1690 mov %edx, %r10d # pass rounds
1691 cmp \$2,$len
1692 jb .Lcbc_dec_one
1693 movdqu 0x10($inp), @XMM[1]
1694 je .Lcbc_dec_two
1695 movdqu 0x20($inp), @XMM[2]
1696 cmp \$4,$len
1697 jb .Lcbc_dec_three
1698 movdqu 0x30($inp), @XMM[3]
1699 je .Lcbc_dec_four
1700 movdqu 0x40($inp), @XMM[4]
1701 cmp \$6,$len
1702 jb .Lcbc_dec_five
1703 movdqu 0x50($inp), @XMM[5]
1704 je .Lcbc_dec_six
1705 movdqu 0x60($inp), @XMM[6]
1706 movdqa @XMM[15], 0x20(%rbp) # put aside IV
1707 call _bsaes_decrypt8
1708 pxor 0x20(%rbp), @XMM[0] # ^= IV
1709 movdqu 0x00($inp), @XMM[8] # re-load input
1710 movdqu 0x10($inp), @XMM[9]
1711 pxor @XMM[8], @XMM[1]
1712 movdqu 0x20($inp), @XMM[10]
1713 pxor @XMM[9], @XMM[6]
1714 movdqu 0x30($inp), @XMM[11]
1715 pxor @XMM[10], @XMM[4]
1716 movdqu 0x40($inp), @XMM[12]
1717 pxor @XMM[11], @XMM[2]
1718 movdqu 0x50($inp), @XMM[13]
1719 pxor @XMM[12], @XMM[7]
1720 movdqu 0x60($inp), @XMM[15] # IV
1721 pxor @XMM[13], @XMM[3]
1722 movdqu @XMM[0], 0x00($out) # write output
1723 movdqu @XMM[1], 0x10($out)
1724 movdqu @XMM[6], 0x20($out)
1725 movdqu @XMM[4], 0x30($out)
1726 movdqu @XMM[2], 0x40($out)
1727 movdqu @XMM[7], 0x50($out)
1728 movdqu @XMM[3], 0x60($out)
1729 jmp .Lcbc_dec_done
1730.align 16
1731.Lcbc_dec_six:
1732 movdqa @XMM[15], 0x20(%rbp) # put aside IV
1733 call _bsaes_decrypt8
1734 pxor 0x20(%rbp), @XMM[0] # ^= IV
1735 movdqu 0x00($inp), @XMM[8] # re-load input
1736 movdqu 0x10($inp), @XMM[9]
1737 pxor @XMM[8], @XMM[1]
1738 movdqu 0x20($inp), @XMM[10]
1739 pxor @XMM[9], @XMM[6]
1740 movdqu 0x30($inp), @XMM[11]
1741 pxor @XMM[10], @XMM[4]
1742 movdqu 0x40($inp), @XMM[12]
1743 pxor @XMM[11], @XMM[2]
1744 movdqu 0x50($inp), @XMM[15] # IV
1745 pxor @XMM[12], @XMM[7]
1746 movdqu @XMM[0], 0x00($out) # write output
1747 movdqu @XMM[1], 0x10($out)
1748 movdqu @XMM[6], 0x20($out)
1749 movdqu @XMM[4], 0x30($out)
1750 movdqu @XMM[2], 0x40($out)
1751 movdqu @XMM[7], 0x50($out)
1752 jmp .Lcbc_dec_done
1753.align 16
1754.Lcbc_dec_five:
1755 movdqa @XMM[15], 0x20(%rbp) # put aside IV
1756 call _bsaes_decrypt8
1757 pxor 0x20(%rbp), @XMM[0] # ^= IV
1758 movdqu 0x00($inp), @XMM[8] # re-load input
1759 movdqu 0x10($inp), @XMM[9]
1760 pxor @XMM[8], @XMM[1]
1761 movdqu 0x20($inp), @XMM[10]
1762 pxor @XMM[9], @XMM[6]
1763 movdqu 0x30($inp), @XMM[11]
1764 pxor @XMM[10], @XMM[4]
1765 movdqu 0x40($inp), @XMM[15] # IV
1766 pxor @XMM[11], @XMM[2]
1767 movdqu @XMM[0], 0x00($out) # write output
1768 movdqu @XMM[1], 0x10($out)
1769 movdqu @XMM[6], 0x20($out)
1770 movdqu @XMM[4], 0x30($out)
1771 movdqu @XMM[2], 0x40($out)
1772 jmp .Lcbc_dec_done
1773.align 16
1774.Lcbc_dec_four:
1775 movdqa @XMM[15], 0x20(%rbp) # put aside IV
1776 call _bsaes_decrypt8
1777 pxor 0x20(%rbp), @XMM[0] # ^= IV
1778 movdqu 0x00($inp), @XMM[8] # re-load input
1779 movdqu 0x10($inp), @XMM[9]
1780 pxor @XMM[8], @XMM[1]
1781 movdqu 0x20($inp), @XMM[10]
1782 pxor @XMM[9], @XMM[6]
1783 movdqu 0x30($inp), @XMM[15] # IV
1784 pxor @XMM[10], @XMM[4]
1785 movdqu @XMM[0], 0x00($out) # write output
1786 movdqu @XMM[1], 0x10($out)
1787 movdqu @XMM[6], 0x20($out)
1788 movdqu @XMM[4], 0x30($out)
1789 jmp .Lcbc_dec_done
1790.align 16
1791.Lcbc_dec_three:
1792 movdqa @XMM[15], 0x20(%rbp) # put aside IV
1793 call _bsaes_decrypt8
1794 pxor 0x20(%rbp), @XMM[0] # ^= IV
1795 movdqu 0x00($inp), @XMM[8] # re-load input
1796 movdqu 0x10($inp), @XMM[9]
1797 pxor @XMM[8], @XMM[1]
1798 movdqu 0x20($inp), @XMM[15] # IV
1799 pxor @XMM[9], @XMM[6]
1800 movdqu @XMM[0], 0x00($out) # write output
1801 movdqu @XMM[1], 0x10($out)
1802 movdqu @XMM[6], 0x20($out)
1803 jmp .Lcbc_dec_done
1804.align 16
1805.Lcbc_dec_two:
1806 movdqa @XMM[15], 0x20(%rbp) # put aside IV
1807 call _bsaes_decrypt8
1808 pxor 0x20(%rbp), @XMM[0] # ^= IV
1809 movdqu 0x00($inp), @XMM[8] # re-load input
1810 movdqu 0x10($inp), @XMM[15] # IV
1811 pxor @XMM[8], @XMM[1]
1812 movdqu @XMM[0], 0x00($out) # write output
1813 movdqu @XMM[1], 0x10($out)
1814 jmp .Lcbc_dec_done
1815.align 16
1816.Lcbc_dec_one:
1817 lea ($inp), $arg1
1818 lea 0x20(%rbp), $arg2 # buffer output
1819 lea ($key), $arg3
1820 call asm_AES_decrypt # doesn't touch %xmm
1821 pxor 0x20(%rbp), @XMM[15] # ^= IV
1822 movdqu @XMM[15], ($out) # write output
1823 movdqa @XMM[0], @XMM[15] # IV
1824
1825.Lcbc_dec_done:
1826 movdqu @XMM[15], (%rbx) # return IV
1827 lea (%rsp), %rax
1828 pxor %xmm0, %xmm0
1829.Lcbc_dec_bzero: # wipe key schedule [if any]
1830 movdqa %xmm0, 0x00(%rax)
1831 movdqa %xmm0, 0x10(%rax)
1832 lea 0x20(%rax), %rax
1833 cmp %rax, %rbp
1834 ja .Lcbc_dec_bzero
1835
1836 lea (%rbp),%rsp # restore %rsp
1837___
1838$code.=<<___ if ($win64);
1839 movaps 0x40(%rbp), %xmm6
1840 movaps 0x50(%rbp), %xmm7
1841 movaps 0x60(%rbp), %xmm8
1842 movaps 0x70(%rbp), %xmm9
1843 movaps 0x80(%rbp), %xmm10
1844 movaps 0x90(%rbp), %xmm11
1845 movaps 0xa0(%rbp), %xmm12
1846 movaps 0xb0(%rbp), %xmm13
1847 movaps 0xc0(%rbp), %xmm14
1848 movaps 0xd0(%rbp), %xmm15
1849 lea 0xa0(%rbp), %rsp
1850___
1851$code.=<<___;
1852 mov 0x48(%rsp), %r15
1853 mov 0x50(%rsp), %r14
1854 mov 0x58(%rsp), %r13
1855 mov 0x60(%rsp), %r12
1856 mov 0x68(%rsp), %rbx
1857 mov 0x70(%rsp), %rax
1858 lea 0x78(%rsp), %rsp
1859 mov %rax, %rbp
1860.Lcbc_dec_epilogue:
1861 ret
1862.size bsaes_cbc_encrypt,.-bsaes_cbc_encrypt
1863
1864.globl bsaes_ctr32_encrypt_blocks
1865.type bsaes_ctr32_encrypt_blocks,\@abi-omnipotent
1866.align 16
1867bsaes_ctr32_encrypt_blocks:
1868 _CET_ENDBR
1869 mov %rsp, %rax
1870.Lctr_enc_prologue:
1871 push %rbp
1872 push %rbx
1873 push %r12
1874 push %r13
1875 push %r14
1876 push %r15
1877 lea -0x48(%rsp), %rsp
1878___
1879$code.=<<___ if ($win64);
1880 mov 0xa0(%rsp),$arg5 # pull ivp
1881 lea -0xa0(%rsp), %rsp
1882 movaps %xmm6, 0x40(%rsp)
1883 movaps %xmm7, 0x50(%rsp)
1884 movaps %xmm8, 0x60(%rsp)
1885 movaps %xmm9, 0x70(%rsp)
1886 movaps %xmm10, 0x80(%rsp)
1887 movaps %xmm11, 0x90(%rsp)
1888 movaps %xmm12, 0xa0(%rsp)
1889 movaps %xmm13, 0xb0(%rsp)
1890 movaps %xmm14, 0xc0(%rsp)
1891 movaps %xmm15, 0xd0(%rsp)
1892.Lctr_enc_body:
1893___
1894$code.=<<___;
1895 mov %rsp, %rbp # backup %rsp
1896 movdqu ($arg5), %xmm0 # load counter
1897 mov 240($arg4), %eax # rounds
1898 mov $arg1, $inp # backup arguments
1899 mov $arg2, $out
1900 mov $arg3, $len
1901 mov $arg4, $key
1902 movdqa %xmm0, 0x20(%rbp) # copy counter
1903 cmp \$8, $arg3
1904 jb .Lctr_enc_short
1905
1906 mov %eax, %ebx # rounds
1907 shl \$7, %rax # 128 bytes per inner round key
1908 sub \$`128-32`, %rax # size of bit-sliced key schedule
1909 sub %rax, %rsp
1910
1911 mov %rsp, %rax # pass key schedule
1912 mov $key, %rcx # pass key
1913 mov %ebx, %r10d # pass rounds
1914 call _bsaes_key_convert
1915 pxor %xmm6,%xmm7 # fix up last round key
1916 movdqa %xmm7,(%rax) # save last round key
1917
1918 movdqa (%rsp), @XMM[9] # load round0 key
1919 lea .LADD1(%rip), %r11
1920 movdqa 0x20(%rbp), @XMM[0] # counter copy
1921 movdqa -0x20(%r11), @XMM[8] # .LSWPUP
1922 pshufb @XMM[8], @XMM[9] # byte swap upper part
1923 pshufb @XMM[8], @XMM[0]
1924 movdqa @XMM[9], (%rsp) # save adjusted round0 key
1925 jmp .Lctr_enc_loop
1926.align 16
1927.Lctr_enc_loop:
1928 movdqa @XMM[0], 0x20(%rbp) # save counter
1929 movdqa @XMM[0], @XMM[1] # prepare 8 counter values
1930 movdqa @XMM[0], @XMM[2]
1931 paddd 0x00(%r11), @XMM[1] # .LADD1
1932 movdqa @XMM[0], @XMM[3]
1933 paddd 0x10(%r11), @XMM[2] # .LADD2
1934 movdqa @XMM[0], @XMM[4]
1935 paddd 0x20(%r11), @XMM[3] # .LADD3
1936 movdqa @XMM[0], @XMM[5]
1937 paddd 0x30(%r11), @XMM[4] # .LADD4
1938 movdqa @XMM[0], @XMM[6]
1939 paddd 0x40(%r11), @XMM[5] # .LADD5
1940 movdqa @XMM[0], @XMM[7]
1941 paddd 0x50(%r11), @XMM[6] # .LADD6
1942 paddd 0x60(%r11), @XMM[7] # .LADD7
1943
1944 # Borrow prologue from _bsaes_encrypt8 to use the opportunity
1945 # to flip byte order in 32-bit counter
1946 movdqa (%rsp), @XMM[9] # round 0 key
1947 lea 0x10(%rsp), %rax # pass key schedule
1948 movdqa -0x10(%r11), @XMM[8] # .LSWPUPM0SR
1949 pxor @XMM[9], @XMM[0] # xor with round0 key
1950 pxor @XMM[9], @XMM[1]
1951 pshufb @XMM[8], @XMM[0]
1952 pxor @XMM[9], @XMM[2]
1953 pshufb @XMM[8], @XMM[1]
1954 pxor @XMM[9], @XMM[3]
1955 pshufb @XMM[8], @XMM[2]
1956 pxor @XMM[9], @XMM[4]
1957 pshufb @XMM[8], @XMM[3]
1958 pxor @XMM[9], @XMM[5]
1959 pshufb @XMM[8], @XMM[4]
1960 pxor @XMM[9], @XMM[6]
1961 pshufb @XMM[8], @XMM[5]
1962 pxor @XMM[9], @XMM[7]
1963 pshufb @XMM[8], @XMM[6]
1964 lea .LBS0(%rip), %r11 # constants table
1965 pshufb @XMM[8], @XMM[7]
1966 mov %ebx,%r10d # pass rounds
1967
1968 call _bsaes_encrypt8_bitslice
1969
1970 sub \$8,$len
1971 jc .Lctr_enc_loop_done
1972
1973 movdqu 0x00($inp), @XMM[8] # load input
1974 movdqu 0x10($inp), @XMM[9]
1975 movdqu 0x20($inp), @XMM[10]
1976 movdqu 0x30($inp), @XMM[11]
1977 movdqu 0x40($inp), @XMM[12]
1978 movdqu 0x50($inp), @XMM[13]
1979 movdqu 0x60($inp), @XMM[14]
1980 movdqu 0x70($inp), @XMM[15]
1981 lea 0x80($inp),$inp
1982 pxor @XMM[0], @XMM[8]
1983 movdqa 0x20(%rbp), @XMM[0] # load counter
1984 pxor @XMM[9], @XMM[1]
1985 movdqu @XMM[8], 0x00($out) # write output
1986 pxor @XMM[10], @XMM[4]
1987 movdqu @XMM[1], 0x10($out)
1988 pxor @XMM[11], @XMM[6]
1989 movdqu @XMM[4], 0x20($out)
1990 pxor @XMM[12], @XMM[3]
1991 movdqu @XMM[6], 0x30($out)
1992 pxor @XMM[13], @XMM[7]
1993 movdqu @XMM[3], 0x40($out)
1994 pxor @XMM[14], @XMM[2]
1995 movdqu @XMM[7], 0x50($out)
1996 pxor @XMM[15], @XMM[5]
1997 movdqu @XMM[2], 0x60($out)
1998 lea .LADD1(%rip), %r11
1999 movdqu @XMM[5], 0x70($out)
2000 lea 0x80($out), $out
2001 paddd 0x70(%r11), @XMM[0] # .LADD8
2002 jnz .Lctr_enc_loop
2003
2004 jmp .Lctr_enc_done
2005.align 16
2006.Lctr_enc_loop_done:
2007 add \$8, $len
2008 movdqu 0x00($inp), @XMM[8] # load input
2009 pxor @XMM[8], @XMM[0]
2010 movdqu @XMM[0], 0x00($out) # write output
2011 cmp \$2,$len
2012 jb .Lctr_enc_done
2013 movdqu 0x10($inp), @XMM[9]
2014 pxor @XMM[9], @XMM[1]
2015 movdqu @XMM[1], 0x10($out)
2016 je .Lctr_enc_done
2017 movdqu 0x20($inp), @XMM[10]
2018 pxor @XMM[10], @XMM[4]
2019 movdqu @XMM[4], 0x20($out)
2020 cmp \$4,$len
2021 jb .Lctr_enc_done
2022 movdqu 0x30($inp), @XMM[11]
2023 pxor @XMM[11], @XMM[6]
2024 movdqu @XMM[6], 0x30($out)
2025 je .Lctr_enc_done
2026 movdqu 0x40($inp), @XMM[12]
2027 pxor @XMM[12], @XMM[3]
2028 movdqu @XMM[3], 0x40($out)
2029 cmp \$6,$len
2030 jb .Lctr_enc_done
2031 movdqu 0x50($inp), @XMM[13]
2032 pxor @XMM[13], @XMM[7]
2033 movdqu @XMM[7], 0x50($out)
2034 je .Lctr_enc_done
2035 movdqu 0x60($inp), @XMM[14]
2036 pxor @XMM[14], @XMM[2]
2037 movdqu @XMM[2], 0x60($out)
2038 jmp .Lctr_enc_done
2039
2040.align 16
2041.Lctr_enc_short:
2042 lea 0x20(%rbp), $arg1
2043 lea 0x30(%rbp), $arg2
2044 lea ($key), $arg3
2045 call asm_AES_encrypt
2046 movdqu ($inp), @XMM[1]
2047 lea 16($inp), $inp
2048 mov 0x2c(%rbp), %eax # load 32-bit counter
2049 bswap %eax
2050 pxor 0x30(%rbp), @XMM[1]
2051 inc %eax # increment
2052 movdqu @XMM[1], ($out)
2053 bswap %eax
2054 lea 16($out), $out
2055 mov %eax, 0x2c(%rsp) # save 32-bit counter
2056 dec $len
2057 jnz .Lctr_enc_short
2058
2059.Lctr_enc_done:
2060 lea (%rsp), %rax
2061 pxor %xmm0, %xmm0
2062.Lctr_enc_bzero: # wipe key schedule [if any]
2063 movdqa %xmm0, 0x00(%rax)
2064 movdqa %xmm0, 0x10(%rax)
2065 lea 0x20(%rax), %rax
2066 cmp %rax, %rbp
2067 ja .Lctr_enc_bzero
2068
2069 lea (%rbp),%rsp # restore %rsp
2070___
2071$code.=<<___ if ($win64);
2072 movaps 0x40(%rbp), %xmm6
2073 movaps 0x50(%rbp), %xmm7
2074 movaps 0x60(%rbp), %xmm8
2075 movaps 0x70(%rbp), %xmm9
2076 movaps 0x80(%rbp), %xmm10
2077 movaps 0x90(%rbp), %xmm11
2078 movaps 0xa0(%rbp), %xmm12
2079 movaps 0xb0(%rbp), %xmm13
2080 movaps 0xc0(%rbp), %xmm14
2081 movaps 0xd0(%rbp), %xmm15
2082 lea 0xa0(%rbp), %rsp
2083___
2084$code.=<<___;
2085 mov 0x48(%rsp), %r15
2086 mov 0x50(%rsp), %r14
2087 mov 0x58(%rsp), %r13
2088 mov 0x60(%rsp), %r12
2089 mov 0x68(%rsp), %rbx
2090 mov 0x70(%rsp), %rax
2091 lea 0x78(%rsp), %rsp
2092 mov %rax, %rbp
2093.Lctr_enc_epilogue:
2094 ret
2095.size bsaes_ctr32_encrypt_blocks,.-bsaes_ctr32_encrypt_blocks
2096___
2097######################################################################
2098# void bsaes_xts_[en|de]crypt(const char *inp,char *out,size_t len,
2099# const AES_KEY *key1, const AES_KEY *key2,
2100# const unsigned char iv[16]);
2101#
2102my ($twmask,$twres,$twtmp)=@XMM[13..15];
2103$arg6=~s/d$//;
2104
2105$code.=<<___;
2106.globl bsaes_xts_encrypt
2107.type bsaes_xts_encrypt,\@abi-omnipotent
2108.align 16
2109bsaes_xts_encrypt:
2110 _CET_ENDBR
2111 mov %rsp, %rax
2112.Lxts_enc_prologue:
2113 push %rbp
2114 push %rbx
2115 push %r12
2116 push %r13
2117 push %r14
2118 push %r15
2119 lea -0x48(%rsp), %rsp
2120___
2121$code.=<<___ if ($win64);
2122 mov 0xa0(%rsp),$arg5 # pull key2
2123 mov 0xa8(%rsp),$arg6 # pull ivp
2124 lea -0xa0(%rsp), %rsp
2125 movaps %xmm6, 0x40(%rsp)
2126 movaps %xmm7, 0x50(%rsp)
2127 movaps %xmm8, 0x60(%rsp)
2128 movaps %xmm9, 0x70(%rsp)
2129 movaps %xmm10, 0x80(%rsp)
2130 movaps %xmm11, 0x90(%rsp)
2131 movaps %xmm12, 0xa0(%rsp)
2132 movaps %xmm13, 0xb0(%rsp)
2133 movaps %xmm14, 0xc0(%rsp)
2134 movaps %xmm15, 0xd0(%rsp)
2135.Lxts_enc_body:
2136___
2137$code.=<<___;
2138 mov %rsp, %rbp # backup %rsp
2139 mov $arg1, $inp # backup arguments
2140 mov $arg2, $out
2141 mov $arg3, $len
2142 mov $arg4, $key
2143
2144 lea ($arg6), $arg1
2145 lea 0x20(%rbp), $arg2
2146 lea ($arg5), $arg3
2147 call asm_AES_encrypt # generate initial tweak
2148
2149 mov 240($key), %eax # rounds
2150 mov $len, %rbx # backup $len
2151
2152 mov %eax, %edx # rounds
2153 shl \$7, %rax # 128 bytes per inner round key
2154 sub \$`128-32`, %rax # size of bit-sliced key schedule
2155 sub %rax, %rsp
2156
2157 mov %rsp, %rax # pass key schedule
2158 mov $key, %rcx # pass key
2159 mov %edx, %r10d # pass rounds
2160 call _bsaes_key_convert
2161 pxor %xmm6, %xmm7 # fix up last round key
2162 movdqa %xmm7, (%rax) # save last round key
2163
2164 and \$-16, $len
2165 sub \$0x80, %rsp # place for tweak[8]
2166 movdqa 0x20(%rbp), @XMM[7] # initial tweak
2167
2168 pxor $twtmp, $twtmp
2169 movdqa .Lxts_magic(%rip), $twmask
2170 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2171
2172 sub \$0x80, $len
2173 jc .Lxts_enc_short
2174 jmp .Lxts_enc_loop
2175
2176.align 16
2177.Lxts_enc_loop:
2178___
2179 for ($i=0;$i<7;$i++) {
2180 $code.=<<___;
2181 pshufd \$0x13, $twtmp, $twres
2182 pxor $twtmp, $twtmp
2183 movdqa @XMM[7], @XMM[$i]
2184 movdqa @XMM[7], `0x10*$i`(%rsp)# save tweak[$i]
2185 paddq @XMM[7], @XMM[7] # psllq 1,$tweak
2186 pand $twmask, $twres # isolate carry and residue
2187 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2188 pxor $twres, @XMM[7]
2189___
2190 $code.=<<___ if ($i>=1);
2191 movdqu `0x10*($i-1)`($inp), @XMM[8+$i-1]
2192___
2193 $code.=<<___ if ($i>=2);
2194 pxor @XMM[8+$i-2], @XMM[$i-2]# input[] ^ tweak[]
2195___
2196 }
2197$code.=<<___;
2198 movdqu 0x60($inp), @XMM[8+6]
2199 pxor @XMM[8+5], @XMM[5]
2200 movdqu 0x70($inp), @XMM[8+7]
2201 lea 0x80($inp), $inp
2202 movdqa @XMM[7], 0x70(%rsp)
2203 pxor @XMM[8+6], @XMM[6]
2204 lea 0x80(%rsp), %rax # pass key schedule
2205 pxor @XMM[8+7], @XMM[7]
2206 mov %edx, %r10d # pass rounds
2207
2208 call _bsaes_encrypt8
2209
2210 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2211 pxor 0x10(%rsp), @XMM[1]
2212 movdqu @XMM[0], 0x00($out) # write output
2213 pxor 0x20(%rsp), @XMM[4]
2214 movdqu @XMM[1], 0x10($out)
2215 pxor 0x30(%rsp), @XMM[6]
2216 movdqu @XMM[4], 0x20($out)
2217 pxor 0x40(%rsp), @XMM[3]
2218 movdqu @XMM[6], 0x30($out)
2219 pxor 0x50(%rsp), @XMM[7]
2220 movdqu @XMM[3], 0x40($out)
2221 pxor 0x60(%rsp), @XMM[2]
2222 movdqu @XMM[7], 0x50($out)
2223 pxor 0x70(%rsp), @XMM[5]
2224 movdqu @XMM[2], 0x60($out)
2225 movdqu @XMM[5], 0x70($out)
2226 lea 0x80($out), $out
2227
2228 movdqa 0x70(%rsp), @XMM[7] # prepare next iteration tweak
2229 pxor $twtmp, $twtmp
2230 movdqa .Lxts_magic(%rip), $twmask
2231 pcmpgtd @XMM[7], $twtmp
2232 pshufd \$0x13, $twtmp, $twres
2233 pxor $twtmp, $twtmp
2234 paddq @XMM[7], @XMM[7] # psllq 1,$tweak
2235 pand $twmask, $twres # isolate carry and residue
2236 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2237 pxor $twres, @XMM[7]
2238
2239 sub \$0x80,$len
2240 jnc .Lxts_enc_loop
2241
2242.Lxts_enc_short:
2243 add \$0x80, $len
2244 jz .Lxts_enc_done
2245___
2246 for ($i=0;$i<7;$i++) {
2247 $code.=<<___;
2248 pshufd \$0x13, $twtmp, $twres
2249 pxor $twtmp, $twtmp
2250 movdqa @XMM[7], @XMM[$i]
2251 movdqa @XMM[7], `0x10*$i`(%rsp)# save tweak[$i]
2252 paddq @XMM[7], @XMM[7] # psllq 1,$tweak
2253 pand $twmask, $twres # isolate carry and residue
2254 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2255 pxor $twres, @XMM[7]
2256___
2257 $code.=<<___ if ($i>=1);
2258 movdqu `0x10*($i-1)`($inp), @XMM[8+$i-1]
2259 cmp \$`0x10*$i`,$len
2260 je .Lxts_enc_$i
2261___
2262 $code.=<<___ if ($i>=2);
2263 pxor @XMM[8+$i-2], @XMM[$i-2]# input[] ^ tweak[]
2264___
2265 }
2266$code.=<<___;
2267 movdqu 0x60($inp), @XMM[8+6]
2268 pxor @XMM[8+5], @XMM[5]
2269 movdqa @XMM[7], 0x70(%rsp)
2270 lea 0x70($inp), $inp
2271 pxor @XMM[8+6], @XMM[6]
2272 lea 0x80(%rsp), %rax # pass key schedule
2273 mov %edx, %r10d # pass rounds
2274
2275 call _bsaes_encrypt8
2276
2277 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2278 pxor 0x10(%rsp), @XMM[1]
2279 movdqu @XMM[0], 0x00($out) # write output
2280 pxor 0x20(%rsp), @XMM[4]
2281 movdqu @XMM[1], 0x10($out)
2282 pxor 0x30(%rsp), @XMM[6]
2283 movdqu @XMM[4], 0x20($out)
2284 pxor 0x40(%rsp), @XMM[3]
2285 movdqu @XMM[6], 0x30($out)
2286 pxor 0x50(%rsp), @XMM[7]
2287 movdqu @XMM[3], 0x40($out)
2288 pxor 0x60(%rsp), @XMM[2]
2289 movdqu @XMM[7], 0x50($out)
2290 movdqu @XMM[2], 0x60($out)
2291 lea 0x70($out), $out
2292
2293 movdqa 0x70(%rsp), @XMM[7] # next iteration tweak
2294 jmp .Lxts_enc_done
2295.align 16
2296.Lxts_enc_6:
2297 pxor @XMM[8+4], @XMM[4]
2298 lea 0x60($inp), $inp
2299 pxor @XMM[8+5], @XMM[5]
2300 lea 0x80(%rsp), %rax # pass key schedule
2301 mov %edx, %r10d # pass rounds
2302
2303 call _bsaes_encrypt8
2304
2305 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2306 pxor 0x10(%rsp), @XMM[1]
2307 movdqu @XMM[0], 0x00($out) # write output
2308 pxor 0x20(%rsp), @XMM[4]
2309 movdqu @XMM[1], 0x10($out)
2310 pxor 0x30(%rsp), @XMM[6]
2311 movdqu @XMM[4], 0x20($out)
2312 pxor 0x40(%rsp), @XMM[3]
2313 movdqu @XMM[6], 0x30($out)
2314 pxor 0x50(%rsp), @XMM[7]
2315 movdqu @XMM[3], 0x40($out)
2316 movdqu @XMM[7], 0x50($out)
2317 lea 0x60($out), $out
2318
2319 movdqa 0x60(%rsp), @XMM[7] # next iteration tweak
2320 jmp .Lxts_enc_done
2321.align 16
2322.Lxts_enc_5:
2323 pxor @XMM[8+3], @XMM[3]
2324 lea 0x50($inp), $inp
2325 pxor @XMM[8+4], @XMM[4]
2326 lea 0x80(%rsp), %rax # pass key schedule
2327 mov %edx, %r10d # pass rounds
2328
2329 call _bsaes_encrypt8
2330
2331 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2332 pxor 0x10(%rsp), @XMM[1]
2333 movdqu @XMM[0], 0x00($out) # write output
2334 pxor 0x20(%rsp), @XMM[4]
2335 movdqu @XMM[1], 0x10($out)
2336 pxor 0x30(%rsp), @XMM[6]
2337 movdqu @XMM[4], 0x20($out)
2338 pxor 0x40(%rsp), @XMM[3]
2339 movdqu @XMM[6], 0x30($out)
2340 movdqu @XMM[3], 0x40($out)
2341 lea 0x50($out), $out
2342
2343 movdqa 0x50(%rsp), @XMM[7] # next iteration tweak
2344 jmp .Lxts_enc_done
2345.align 16
2346.Lxts_enc_4:
2347 pxor @XMM[8+2], @XMM[2]
2348 lea 0x40($inp), $inp
2349 pxor @XMM[8+3], @XMM[3]
2350 lea 0x80(%rsp), %rax # pass key schedule
2351 mov %edx, %r10d # pass rounds
2352
2353 call _bsaes_encrypt8
2354
2355 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2356 pxor 0x10(%rsp), @XMM[1]
2357 movdqu @XMM[0], 0x00($out) # write output
2358 pxor 0x20(%rsp), @XMM[4]
2359 movdqu @XMM[1], 0x10($out)
2360 pxor 0x30(%rsp), @XMM[6]
2361 movdqu @XMM[4], 0x20($out)
2362 movdqu @XMM[6], 0x30($out)
2363 lea 0x40($out), $out
2364
2365 movdqa 0x40(%rsp), @XMM[7] # next iteration tweak
2366 jmp .Lxts_enc_done
2367.align 16
2368.Lxts_enc_3:
2369 pxor @XMM[8+1], @XMM[1]
2370 lea 0x30($inp), $inp
2371 pxor @XMM[8+2], @XMM[2]
2372 lea 0x80(%rsp), %rax # pass key schedule
2373 mov %edx, %r10d # pass rounds
2374
2375 call _bsaes_encrypt8
2376
2377 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2378 pxor 0x10(%rsp), @XMM[1]
2379 movdqu @XMM[0], 0x00($out) # write output
2380 pxor 0x20(%rsp), @XMM[4]
2381 movdqu @XMM[1], 0x10($out)
2382 movdqu @XMM[4], 0x20($out)
2383 lea 0x30($out), $out
2384
2385 movdqa 0x30(%rsp), @XMM[7] # next iteration tweak
2386 jmp .Lxts_enc_done
2387.align 16
2388.Lxts_enc_2:
2389 pxor @XMM[8+0], @XMM[0]
2390 lea 0x20($inp), $inp
2391 pxor @XMM[8+1], @XMM[1]
2392 lea 0x80(%rsp), %rax # pass key schedule
2393 mov %edx, %r10d # pass rounds
2394
2395 call _bsaes_encrypt8
2396
2397 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2398 pxor 0x10(%rsp), @XMM[1]
2399 movdqu @XMM[0], 0x00($out) # write output
2400 movdqu @XMM[1], 0x10($out)
2401 lea 0x20($out), $out
2402
2403 movdqa 0x20(%rsp), @XMM[7] # next iteration tweak
2404 jmp .Lxts_enc_done
2405.align 16
2406.Lxts_enc_1:
2407 pxor @XMM[0], @XMM[8]
2408 lea 0x10($inp), $inp
2409 movdqa @XMM[8], 0x20(%rbp)
2410 lea 0x20(%rbp), $arg1
2411 lea 0x20(%rbp), $arg2
2412 lea ($key), $arg3
2413 call asm_AES_encrypt # doesn't touch %xmm
2414 pxor 0x20(%rbp), @XMM[0] # ^= tweak[]
2415 #pxor @XMM[8], @XMM[0]
2416 #lea 0x80(%rsp), %rax # pass key schedule
2417 #mov %edx, %r10d # pass rounds
2418 #call _bsaes_encrypt8
2419 #pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2420 movdqu @XMM[0], 0x00($out) # write output
2421 lea 0x10($out), $out
2422
2423 movdqa 0x10(%rsp), @XMM[7] # next iteration tweak
2424
2425.Lxts_enc_done:
2426 and \$15, %ebx
2427 jz .Lxts_enc_ret
2428 mov $out, %rdx
2429
2430.Lxts_enc_steal:
2431 movzb ($inp), %eax
2432 movzb -16(%rdx), %ecx
2433 lea 1($inp), $inp
2434 mov %al, -16(%rdx)
2435 mov %cl, 0(%rdx)
2436 lea 1(%rdx), %rdx
2437 sub \$1,%ebx
2438 jnz .Lxts_enc_steal
2439
2440 movdqu -16($out), @XMM[0]
2441 lea 0x20(%rbp), $arg1
2442 pxor @XMM[7], @XMM[0]
2443 lea 0x20(%rbp), $arg2
2444 movdqa @XMM[0], 0x20(%rbp)
2445 lea ($key), $arg3
2446 call asm_AES_encrypt # doesn't touch %xmm
2447 pxor 0x20(%rbp), @XMM[7]
2448 movdqu @XMM[7], -16($out)
2449
2450.Lxts_enc_ret:
2451 lea (%rsp), %rax
2452 pxor %xmm0, %xmm0
2453.Lxts_enc_bzero: # wipe key schedule [if any]
2454 movdqa %xmm0, 0x00(%rax)
2455 movdqa %xmm0, 0x10(%rax)
2456 lea 0x20(%rax), %rax
2457 cmp %rax, %rbp
2458 ja .Lxts_enc_bzero
2459
2460 lea (%rbp),%rsp # restore %rsp
2461___
2462$code.=<<___ if ($win64);
2463 movaps 0x40(%rbp), %xmm6
2464 movaps 0x50(%rbp), %xmm7
2465 movaps 0x60(%rbp), %xmm8
2466 movaps 0x70(%rbp), %xmm9
2467 movaps 0x80(%rbp), %xmm10
2468 movaps 0x90(%rbp), %xmm11
2469 movaps 0xa0(%rbp), %xmm12
2470 movaps 0xb0(%rbp), %xmm13
2471 movaps 0xc0(%rbp), %xmm14
2472 movaps 0xd0(%rbp), %xmm15
2473 lea 0xa0(%rbp), %rsp
2474___
2475$code.=<<___;
2476 mov 0x48(%rsp), %r15
2477 mov 0x50(%rsp), %r14
2478 mov 0x58(%rsp), %r13
2479 mov 0x60(%rsp), %r12
2480 mov 0x68(%rsp), %rbx
2481 mov 0x70(%rsp), %rax
2482 lea 0x78(%rsp), %rsp
2483 mov %rax, %rbp
2484.Lxts_enc_epilogue:
2485 ret
2486.size bsaes_xts_encrypt,.-bsaes_xts_encrypt
2487
2488.globl bsaes_xts_decrypt
2489.type bsaes_xts_decrypt,\@abi-omnipotent
2490.align 16
2491bsaes_xts_decrypt:
2492 _CET_ENDBR
2493 mov %rsp, %rax
2494.Lxts_dec_prologue:
2495 push %rbp
2496 push %rbx
2497 push %r12
2498 push %r13
2499 push %r14
2500 push %r15
2501 lea -0x48(%rsp), %rsp
2502___
2503$code.=<<___ if ($win64);
2504 mov 0xa0(%rsp),$arg5 # pull key2
2505 mov 0xa8(%rsp),$arg6 # pull ivp
2506 lea -0xa0(%rsp), %rsp
2507 movaps %xmm6, 0x40(%rsp)
2508 movaps %xmm7, 0x50(%rsp)
2509 movaps %xmm8, 0x60(%rsp)
2510 movaps %xmm9, 0x70(%rsp)
2511 movaps %xmm10, 0x80(%rsp)
2512 movaps %xmm11, 0x90(%rsp)
2513 movaps %xmm12, 0xa0(%rsp)
2514 movaps %xmm13, 0xb0(%rsp)
2515 movaps %xmm14, 0xc0(%rsp)
2516 movaps %xmm15, 0xd0(%rsp)
2517.Lxts_dec_body:
2518___
2519$code.=<<___;
2520 mov %rsp, %rbp # backup %rsp
2521 mov $arg1, $inp # backup arguments
2522 mov $arg2, $out
2523 mov $arg3, $len
2524 mov $arg4, $key
2525
2526 lea ($arg6), $arg1
2527 lea 0x20(%rbp), $arg2
2528 lea ($arg5), $arg3
2529 call asm_AES_encrypt # generate initial tweak
2530
2531 mov 240($key), %eax # rounds
2532 mov $len, %rbx # backup $len
2533
2534 mov %eax, %edx # rounds
2535 shl \$7, %rax # 128 bytes per inner round key
2536 sub \$`128-32`, %rax # size of bit-sliced key schedule
2537 sub %rax, %rsp
2538
2539 mov %rsp, %rax # pass key schedule
2540 mov $key, %rcx # pass key
2541 mov %edx, %r10d # pass rounds
2542 call _bsaes_key_convert
2543 pxor (%rsp), %xmm7 # fix up round 0 key
2544 movdqa %xmm6, (%rax) # save last round key
2545 movdqa %xmm7, (%rsp)
2546
2547 xor %eax, %eax # if ($len%16) len-=16;
2548 and \$-16, $len
2549 test \$15, %ebx
2550 setnz %al
2551 shl \$4, %rax
2552 sub %rax, $len
2553
2554 sub \$0x80, %rsp # place for tweak[8]
2555 movdqa 0x20(%rbp), @XMM[7] # initial tweak
2556
2557 pxor $twtmp, $twtmp
2558 movdqa .Lxts_magic(%rip), $twmask
2559 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2560
2561 sub \$0x80, $len
2562 jc .Lxts_dec_short
2563 jmp .Lxts_dec_loop
2564
2565.align 16
2566.Lxts_dec_loop:
2567___
2568 for ($i=0;$i<7;$i++) {
2569 $code.=<<___;
2570 pshufd \$0x13, $twtmp, $twres
2571 pxor $twtmp, $twtmp
2572 movdqa @XMM[7], @XMM[$i]
2573 movdqa @XMM[7], `0x10*$i`(%rsp)# save tweak[$i]
2574 paddq @XMM[7], @XMM[7] # psllq 1,$tweak
2575 pand $twmask, $twres # isolate carry and residue
2576 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2577 pxor $twres, @XMM[7]
2578___
2579 $code.=<<___ if ($i>=1);
2580 movdqu `0x10*($i-1)`($inp), @XMM[8+$i-1]
2581___
2582 $code.=<<___ if ($i>=2);
2583 pxor @XMM[8+$i-2], @XMM[$i-2]# input[] ^ tweak[]
2584___
2585 }
2586$code.=<<___;
2587 movdqu 0x60($inp), @XMM[8+6]
2588 pxor @XMM[8+5], @XMM[5]
2589 movdqu 0x70($inp), @XMM[8+7]
2590 lea 0x80($inp), $inp
2591 movdqa @XMM[7], 0x70(%rsp)
2592 pxor @XMM[8+6], @XMM[6]
2593 lea 0x80(%rsp), %rax # pass key schedule
2594 pxor @XMM[8+7], @XMM[7]
2595 mov %edx, %r10d # pass rounds
2596
2597 call _bsaes_decrypt8
2598
2599 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2600 pxor 0x10(%rsp), @XMM[1]
2601 movdqu @XMM[0], 0x00($out) # write output
2602 pxor 0x20(%rsp), @XMM[6]
2603 movdqu @XMM[1], 0x10($out)
2604 pxor 0x30(%rsp), @XMM[4]
2605 movdqu @XMM[6], 0x20($out)
2606 pxor 0x40(%rsp), @XMM[2]
2607 movdqu @XMM[4], 0x30($out)
2608 pxor 0x50(%rsp), @XMM[7]
2609 movdqu @XMM[2], 0x40($out)
2610 pxor 0x60(%rsp), @XMM[3]
2611 movdqu @XMM[7], 0x50($out)
2612 pxor 0x70(%rsp), @XMM[5]
2613 movdqu @XMM[3], 0x60($out)
2614 movdqu @XMM[5], 0x70($out)
2615 lea 0x80($out), $out
2616
2617 movdqa 0x70(%rsp), @XMM[7] # prepare next iteration tweak
2618 pxor $twtmp, $twtmp
2619 movdqa .Lxts_magic(%rip), $twmask
2620 pcmpgtd @XMM[7], $twtmp
2621 pshufd \$0x13, $twtmp, $twres
2622 pxor $twtmp, $twtmp
2623 paddq @XMM[7], @XMM[7] # psllq 1,$tweak
2624 pand $twmask, $twres # isolate carry and residue
2625 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2626 pxor $twres, @XMM[7]
2627
2628 sub \$0x80,$len
2629 jnc .Lxts_dec_loop
2630
2631.Lxts_dec_short:
2632 add \$0x80, $len
2633 jz .Lxts_dec_done
2634___
2635 for ($i=0;$i<7;$i++) {
2636 $code.=<<___;
2637 pshufd \$0x13, $twtmp, $twres
2638 pxor $twtmp, $twtmp
2639 movdqa @XMM[7], @XMM[$i]
2640 movdqa @XMM[7], `0x10*$i`(%rsp)# save tweak[$i]
2641 paddq @XMM[7], @XMM[7] # psllq 1,$tweak
2642 pand $twmask, $twres # isolate carry and residue
2643 pcmpgtd @XMM[7], $twtmp # broadcast upper bits
2644 pxor $twres, @XMM[7]
2645___
2646 $code.=<<___ if ($i>=1);
2647 movdqu `0x10*($i-1)`($inp), @XMM[8+$i-1]
2648 cmp \$`0x10*$i`,$len
2649 je .Lxts_dec_$i
2650___
2651 $code.=<<___ if ($i>=2);
2652 pxor @XMM[8+$i-2], @XMM[$i-2]# input[] ^ tweak[]
2653___
2654 }
2655$code.=<<___;
2656 movdqu 0x60($inp), @XMM[8+6]
2657 pxor @XMM[8+5], @XMM[5]
2658 movdqa @XMM[7], 0x70(%rsp)
2659 lea 0x70($inp), $inp
2660 pxor @XMM[8+6], @XMM[6]
2661 lea 0x80(%rsp), %rax # pass key schedule
2662 mov %edx, %r10d # pass rounds
2663
2664 call _bsaes_decrypt8
2665
2666 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2667 pxor 0x10(%rsp), @XMM[1]
2668 movdqu @XMM[0], 0x00($out) # write output
2669 pxor 0x20(%rsp), @XMM[6]
2670 movdqu @XMM[1], 0x10($out)
2671 pxor 0x30(%rsp), @XMM[4]
2672 movdqu @XMM[6], 0x20($out)
2673 pxor 0x40(%rsp), @XMM[2]
2674 movdqu @XMM[4], 0x30($out)
2675 pxor 0x50(%rsp), @XMM[7]
2676 movdqu @XMM[2], 0x40($out)
2677 pxor 0x60(%rsp), @XMM[3]
2678 movdqu @XMM[7], 0x50($out)
2679 movdqu @XMM[3], 0x60($out)
2680 lea 0x70($out), $out
2681
2682 movdqa 0x70(%rsp), @XMM[7] # next iteration tweak
2683 jmp .Lxts_dec_done
2684.align 16
2685.Lxts_dec_6:
2686 pxor @XMM[8+4], @XMM[4]
2687 lea 0x60($inp), $inp
2688 pxor @XMM[8+5], @XMM[5]
2689 lea 0x80(%rsp), %rax # pass key schedule
2690 mov %edx, %r10d # pass rounds
2691
2692 call _bsaes_decrypt8
2693
2694 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2695 pxor 0x10(%rsp), @XMM[1]
2696 movdqu @XMM[0], 0x00($out) # write output
2697 pxor 0x20(%rsp), @XMM[6]
2698 movdqu @XMM[1], 0x10($out)
2699 pxor 0x30(%rsp), @XMM[4]
2700 movdqu @XMM[6], 0x20($out)
2701 pxor 0x40(%rsp), @XMM[2]
2702 movdqu @XMM[4], 0x30($out)
2703 pxor 0x50(%rsp), @XMM[7]
2704 movdqu @XMM[2], 0x40($out)
2705 movdqu @XMM[7], 0x50($out)
2706 lea 0x60($out), $out
2707
2708 movdqa 0x60(%rsp), @XMM[7] # next iteration tweak
2709 jmp .Lxts_dec_done
2710.align 16
2711.Lxts_dec_5:
2712 pxor @XMM[8+3], @XMM[3]
2713 lea 0x50($inp), $inp
2714 pxor @XMM[8+4], @XMM[4]
2715 lea 0x80(%rsp), %rax # pass key schedule
2716 mov %edx, %r10d # pass rounds
2717
2718 call _bsaes_decrypt8
2719
2720 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2721 pxor 0x10(%rsp), @XMM[1]
2722 movdqu @XMM[0], 0x00($out) # write output
2723 pxor 0x20(%rsp), @XMM[6]
2724 movdqu @XMM[1], 0x10($out)
2725 pxor 0x30(%rsp), @XMM[4]
2726 movdqu @XMM[6], 0x20($out)
2727 pxor 0x40(%rsp), @XMM[2]
2728 movdqu @XMM[4], 0x30($out)
2729 movdqu @XMM[2], 0x40($out)
2730 lea 0x50($out), $out
2731
2732 movdqa 0x50(%rsp), @XMM[7] # next iteration tweak
2733 jmp .Lxts_dec_done
2734.align 16
2735.Lxts_dec_4:
2736 pxor @XMM[8+2], @XMM[2]
2737 lea 0x40($inp), $inp
2738 pxor @XMM[8+3], @XMM[3]
2739 lea 0x80(%rsp), %rax # pass key schedule
2740 mov %edx, %r10d # pass rounds
2741
2742 call _bsaes_decrypt8
2743
2744 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2745 pxor 0x10(%rsp), @XMM[1]
2746 movdqu @XMM[0], 0x00($out) # write output
2747 pxor 0x20(%rsp), @XMM[6]
2748 movdqu @XMM[1], 0x10($out)
2749 pxor 0x30(%rsp), @XMM[4]
2750 movdqu @XMM[6], 0x20($out)
2751 movdqu @XMM[4], 0x30($out)
2752 lea 0x40($out), $out
2753
2754 movdqa 0x40(%rsp), @XMM[7] # next iteration tweak
2755 jmp .Lxts_dec_done
2756.align 16
2757.Lxts_dec_3:
2758 pxor @XMM[8+1], @XMM[1]
2759 lea 0x30($inp), $inp
2760 pxor @XMM[8+2], @XMM[2]
2761 lea 0x80(%rsp), %rax # pass key schedule
2762 mov %edx, %r10d # pass rounds
2763
2764 call _bsaes_decrypt8
2765
2766 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2767 pxor 0x10(%rsp), @XMM[1]
2768 movdqu @XMM[0], 0x00($out) # write output
2769 pxor 0x20(%rsp), @XMM[6]
2770 movdqu @XMM[1], 0x10($out)
2771 movdqu @XMM[6], 0x20($out)
2772 lea 0x30($out), $out
2773
2774 movdqa 0x30(%rsp), @XMM[7] # next iteration tweak
2775 jmp .Lxts_dec_done
2776.align 16
2777.Lxts_dec_2:
2778 pxor @XMM[8+0], @XMM[0]
2779 lea 0x20($inp), $inp
2780 pxor @XMM[8+1], @XMM[1]
2781 lea 0x80(%rsp), %rax # pass key schedule
2782 mov %edx, %r10d # pass rounds
2783
2784 call _bsaes_decrypt8
2785
2786 pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2787 pxor 0x10(%rsp), @XMM[1]
2788 movdqu @XMM[0], 0x00($out) # write output
2789 movdqu @XMM[1], 0x10($out)
2790 lea 0x20($out), $out
2791
2792 movdqa 0x20(%rsp), @XMM[7] # next iteration tweak
2793 jmp .Lxts_dec_done
2794.align 16
2795.Lxts_dec_1:
2796 pxor @XMM[0], @XMM[8]
2797 lea 0x10($inp), $inp
2798 movdqa @XMM[8], 0x20(%rbp)
2799 lea 0x20(%rbp), $arg1
2800 lea 0x20(%rbp), $arg2
2801 lea ($key), $arg3
2802 call asm_AES_decrypt # doesn't touch %xmm
2803 pxor 0x20(%rbp), @XMM[0] # ^= tweak[]
2804 #pxor @XMM[8], @XMM[0]
2805 #lea 0x80(%rsp), %rax # pass key schedule
2806 #mov %edx, %r10d # pass rounds
2807 #call _bsaes_decrypt8
2808 #pxor 0x00(%rsp), @XMM[0] # ^= tweak[]
2809 movdqu @XMM[0], 0x00($out) # write output
2810 lea 0x10($out), $out
2811
2812 movdqa 0x10(%rsp), @XMM[7] # next iteration tweak
2813
2814.Lxts_dec_done:
2815 and \$15, %ebx
2816 jz .Lxts_dec_ret
2817
2818 pxor $twtmp, $twtmp
2819 movdqa .Lxts_magic(%rip), $twmask
2820 pcmpgtd @XMM[7], $twtmp
2821 pshufd \$0x13, $twtmp, $twres
2822 movdqa @XMM[7], @XMM[6]
2823 paddq @XMM[7], @XMM[7] # psllq 1,$tweak
2824 pand $twmask, $twres # isolate carry and residue
2825 movdqu ($inp), @XMM[0]
2826 pxor $twres, @XMM[7]
2827
2828 lea 0x20(%rbp), $arg1
2829 pxor @XMM[7], @XMM[0]
2830 lea 0x20(%rbp), $arg2
2831 movdqa @XMM[0], 0x20(%rbp)
2832 lea ($key), $arg3
2833 call asm_AES_decrypt # doesn't touch %xmm
2834 pxor 0x20(%rbp), @XMM[7]
2835 mov $out, %rdx
2836 movdqu @XMM[7], ($out)
2837
2838.Lxts_dec_steal:
2839 movzb 16($inp), %eax
2840 movzb (%rdx), %ecx
2841 lea 1($inp), $inp
2842 mov %al, (%rdx)
2843 mov %cl, 16(%rdx)
2844 lea 1(%rdx), %rdx
2845 sub \$1,%ebx
2846 jnz .Lxts_dec_steal
2847
2848 movdqu ($out), @XMM[0]
2849 lea 0x20(%rbp), $arg1
2850 pxor @XMM[6], @XMM[0]
2851 lea 0x20(%rbp), $arg2
2852 movdqa @XMM[0], 0x20(%rbp)
2853 lea ($key), $arg3
2854 call asm_AES_decrypt # doesn't touch %xmm
2855 pxor 0x20(%rbp), @XMM[6]
2856 movdqu @XMM[6], ($out)
2857
2858.Lxts_dec_ret:
2859 lea (%rsp), %rax
2860 pxor %xmm0, %xmm0
2861.Lxts_dec_bzero: # wipe key schedule [if any]
2862 movdqa %xmm0, 0x00(%rax)
2863 movdqa %xmm0, 0x10(%rax)
2864 lea 0x20(%rax), %rax
2865 cmp %rax, %rbp
2866 ja .Lxts_dec_bzero
2867
2868 lea (%rbp),%rsp # restore %rsp
2869___
2870$code.=<<___ if ($win64);
2871 movaps 0x40(%rbp), %xmm6
2872 movaps 0x50(%rbp), %xmm7
2873 movaps 0x60(%rbp), %xmm8
2874 movaps 0x70(%rbp), %xmm9
2875 movaps 0x80(%rbp), %xmm10
2876 movaps 0x90(%rbp), %xmm11
2877 movaps 0xa0(%rbp), %xmm12
2878 movaps 0xb0(%rbp), %xmm13
2879 movaps 0xc0(%rbp), %xmm14
2880 movaps 0xd0(%rbp), %xmm15
2881 lea 0xa0(%rbp), %rsp
2882___
2883$code.=<<___;
2884 mov 0x48(%rsp), %r15
2885 mov 0x50(%rsp), %r14
2886 mov 0x58(%rsp), %r13
2887 mov 0x60(%rsp), %r12
2888 mov 0x68(%rsp), %rbx
2889 mov 0x70(%rsp), %rax
2890 lea 0x78(%rsp), %rsp
2891 mov %rax, %rbp
2892.Lxts_dec_epilogue:
2893 ret
2894.size bsaes_xts_decrypt,.-bsaes_xts_decrypt
2895___
2896}
2897$code.=<<___;
2898.section .rodata
2899.type _bsaes_const,\@object
2900.align 64
2901_bsaes_const:
2902.LM0ISR: # InvShiftRows constants
2903 .quad 0x0a0e0206070b0f03, 0x0004080c0d010509
2904.LISRM0:
2905 .quad 0x01040b0e0205080f, 0x0306090c00070a0d
2906.LISR:
2907 .quad 0x0504070602010003, 0x0f0e0d0c080b0a09
2908.LBS0: # bit-slice constants
2909 .quad 0x5555555555555555, 0x5555555555555555
2910.LBS1:
2911 .quad 0x3333333333333333, 0x3333333333333333
2912.LBS2:
2913 .quad 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f
2914.LSR: # shiftrows constants
2915 .quad 0x0504070600030201, 0x0f0e0d0c0a09080b
2916.LSRM0:
2917 .quad 0x0304090e00050a0f, 0x01060b0c0207080d
2918.LM0SR:
2919 .quad 0x0a0e02060f03070b, 0x0004080c05090d01
2920.LSWPUP: # byte-swap upper dword
2921 .quad 0x0706050403020100, 0x0c0d0e0f0b0a0908
2922.LSWPUPM0SR:
2923 .quad 0x0a0d02060c03070b, 0x0004080f05090e01
2924.LADD1: # counter increment constants
2925 .quad 0x0000000000000000, 0x0000000100000000
2926.LADD2:
2927 .quad 0x0000000000000000, 0x0000000200000000
2928.LADD3:
2929 .quad 0x0000000000000000, 0x0000000300000000
2930.LADD4:
2931 .quad 0x0000000000000000, 0x0000000400000000
2932.LADD5:
2933 .quad 0x0000000000000000, 0x0000000500000000
2934.LADD6:
2935 .quad 0x0000000000000000, 0x0000000600000000
2936.LADD7:
2937 .quad 0x0000000000000000, 0x0000000700000000
2938.LADD8:
2939 .quad 0x0000000000000000, 0x0000000800000000
2940.Lxts_magic:
2941 .long 0x87,0,1,0
2942.Lmasks:
2943 .quad 0x0101010101010101, 0x0101010101010101
2944 .quad 0x0202020202020202, 0x0202020202020202
2945 .quad 0x0404040404040404, 0x0404040404040404
2946 .quad 0x0808080808080808, 0x0808080808080808
2947.LM0:
2948 .quad 0x02060a0e03070b0f, 0x0004080c0105090d
2949.L63:
2950 .quad 0x6363636363636363, 0x6363636363636363
2951.align 64
2952.size _bsaes_const,.-_bsaes_const
2953.text
2954___
2955
2956# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
2957# CONTEXT *context,DISPATCHER_CONTEXT *disp)
2958if ($win64) {
2959$rec="%rcx";
2960$frame="%rdx";
2961$context="%r8";
2962$disp="%r9";
2963
2964$code.=<<___;
2965.extern __imp_RtlVirtualUnwind
2966.type se_handler,\@abi-omnipotent
2967.align 16
2968se_handler:
2969 _CET_ENDBR
2970 push %rsi
2971 push %rdi
2972 push %rbx
2973 push %rbp
2974 push %r12
2975 push %r13
2976 push %r14
2977 push %r15
2978 pushfq
2979 sub \$64,%rsp
2980
2981 mov 120($context),%rax # pull context->Rax
2982 mov 248($context),%rbx # pull context->Rip
2983
2984 mov 8($disp),%rsi # disp->ImageBase
2985 mov 56($disp),%r11 # disp->HandlerData
2986
2987 mov 0(%r11),%r10d # HandlerData[0]
2988 lea (%rsi,%r10),%r10 # prologue label
2989 cmp %r10,%rbx # context->Rip<prologue label
2990 jb .Lin_prologue
2991
2992 mov 152($context),%rax # pull context->Rsp
2993
2994 mov 4(%r11),%r10d # HandlerData[1]
2995 lea (%rsi,%r10),%r10 # epilogue label
2996 cmp %r10,%rbx # context->Rip>=epilogue label
2997 jae .Lin_prologue
2998
2999 mov 160($context),%rax # pull context->Rbp
3000
3001 lea 0x40(%rax),%rsi # %xmm save area
3002 lea 512($context),%rdi # &context.Xmm6
3003 mov \$20,%ecx # 10*sizeof(%xmm0)/sizeof(%rax)
3004 .long 0xa548f3fc # cld; rep movsq
3005 lea 0xa0(%rax),%rax # adjust stack pointer
3006
3007 mov 0x70(%rax),%rbp
3008 mov 0x68(%rax),%rbx
3009 mov 0x60(%rax),%r12
3010 mov 0x58(%rax),%r13
3011 mov 0x50(%rax),%r14
3012 mov 0x48(%rax),%r15
3013 lea 0x78(%rax),%rax # adjust stack pointer
3014 mov %rbx,144($context) # restore context->Rbx
3015 mov %rbp,160($context) # restore context->Rbp
3016 mov %r12,216($context) # restore context->R12
3017 mov %r13,224($context) # restore context->R13
3018 mov %r14,232($context) # restore context->R14
3019 mov %r15,240($context) # restore context->R15
3020
3021.Lin_prologue:
3022 mov %rax,152($context) # restore context->Rsp
3023
3024 mov 40($disp),%rdi # disp->ContextRecord
3025 mov $context,%rsi # context
3026 mov \$`1232/8`,%ecx # sizeof(CONTEXT)
3027 .long 0xa548f3fc # cld; rep movsq
3028
3029 mov $disp,%rsi
3030 xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER
3031 mov 8(%rsi),%rdx # arg2, disp->ImageBase
3032 mov 0(%rsi),%r8 # arg3, disp->ControlPc
3033 mov 16(%rsi),%r9 # arg4, disp->FunctionEntry
3034 mov 40(%rsi),%r10 # disp->ContextRecord
3035 lea 56(%rsi),%r11 # &disp->HandlerData
3036 lea 24(%rsi),%r12 # &disp->EstablisherFrame
3037 mov %r10,32(%rsp) # arg5
3038 mov %r11,40(%rsp) # arg6
3039 mov %r12,48(%rsp) # arg7
3040 mov %rcx,56(%rsp) # arg8, (NULL)
3041 call *__imp_RtlVirtualUnwind(%rip)
3042
3043 mov \$1,%eax # ExceptionContinueSearch
3044 add \$64,%rsp
3045 popfq
3046 pop %r15
3047 pop %r14
3048 pop %r13
3049 pop %r12
3050 pop %rbp
3051 pop %rbx
3052 pop %rdi
3053 pop %rsi
3054 ret
3055.size se_handler,.-se_handler
3056
3057.section .pdata
3058.align 4
3059___
3060$code.=<<___ if ($ecb);
3061 .rva .Lecb_enc_prologue
3062 .rva .Lecb_enc_epilogue
3063 .rva .Lecb_enc_info
3064
3065 .rva .Lecb_dec_prologue
3066 .rva .Lecb_dec_epilogue
3067 .rva .Lecb_dec_info
3068___
3069$code.=<<___;
3070 .rva .Lcbc_dec_prologue
3071 .rva .Lcbc_dec_epilogue
3072 .rva .Lcbc_dec_info
3073
3074 .rva .Lctr_enc_prologue
3075 .rva .Lctr_enc_epilogue
3076 .rva .Lctr_enc_info
3077
3078 .rva .Lxts_enc_prologue
3079 .rva .Lxts_enc_epilogue
3080 .rva .Lxts_enc_info
3081
3082 .rva .Lxts_dec_prologue
3083 .rva .Lxts_dec_epilogue
3084 .rva .Lxts_dec_info
3085
3086.section .xdata
3087.align 8
3088___
3089$code.=<<___ if ($ecb);
3090.Lecb_enc_info:
3091 .byte 9,0,0,0
3092 .rva se_handler
3093 .rva .Lecb_enc_body,.Lecb_enc_epilogue # HandlerData[]
3094.Lecb_dec_info:
3095 .byte 9,0,0,0
3096 .rva se_handler
3097 .rva .Lecb_dec_body,.Lecb_dec_epilogue # HandlerData[]
3098___
3099$code.=<<___;
3100.Lcbc_dec_info:
3101 .byte 9,0,0,0
3102 .rva se_handler
3103 .rva .Lcbc_dec_body,.Lcbc_dec_epilogue # HandlerData[]
3104.Lctr_enc_info:
3105 .byte 9,0,0,0
3106 .rva se_handler
3107 .rva .Lctr_enc_body,.Lctr_enc_epilogue # HandlerData[]
3108.Lxts_enc_info:
3109 .byte 9,0,0,0
3110 .rva se_handler
3111 .rva .Lxts_enc_body,.Lxts_enc_epilogue # HandlerData[]
3112.Lxts_dec_info:
3113 .byte 9,0,0,0
3114 .rva se_handler
3115 .rva .Lxts_dec_body,.Lxts_dec_epilogue # HandlerData[]
3116___
3117}
3118
3119$code =~ s/\`([^\`]*)\`/eval($1)/gem;
3120
3121print $code;
3122
3123close STDOUT;
diff --git a/src/lib/libcrypto/aes/asm/vpaes-x86.pl b/src/lib/libcrypto/aes/asm/vpaes-x86.pl
deleted file mode 100644
index 6e7bd36d05..0000000000
--- a/src/lib/libcrypto/aes/asm/vpaes-x86.pl
+++ /dev/null
@@ -1,911 +0,0 @@
1#!/usr/bin/env perl
2
3######################################################################
4## Constant-time SSSE3 AES core implementation.
5## version 0.1
6##
7## By Mike Hamburg (Stanford University), 2009
8## Public domain.
9##
10## For details see http://shiftleft.org/papers/vector_aes/ and
11## http://crypto.stanford.edu/vpaes/.
12
13######################################################################
14# September 2011.
15#
16# Port vpaes-x86_64.pl as 32-bit "almost" drop-in replacement for
17# aes-586.pl. "Almost" refers to the fact that AES_cbc_encrypt
18# doesn't handle partial vectors (doesn't have to if called from
19# EVP only). "Drop-in" implies that this module doesn't share key
20# schedule structure with the original nor does it make assumption
21# about its alignment...
22#
23# Performance summary. aes-586.pl column lists large-block CBC
24# encrypt/decrypt/with-hyper-threading-off(*) results in cycles per
25# byte processed with 128-bit key, and vpaes-x86.pl column - [also
26# large-block CBC] encrypt/decrypt.
27#
28# aes-586.pl vpaes-x86.pl
29#
30# Core 2(**) 29.1/42.3/18.3 22.0/25.6(***)
31# Nehalem 27.9/40.4/18.1 10.3/12.0
32# Atom 102./119./60.1 64.5/85.3(***)
33#
34# (*) "Hyper-threading" in the context refers rather to cache shared
35# among multiple cores, than to specifically Intel HTT. As vast
36# majority of contemporary cores share cache, slower code path
37# is common place. In other words "with-hyper-threading-off"
38# results are presented mostly for reference purposes.
39#
40# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe.
41#
42# (***) Less impressive improvement on Core 2 and Atom is due to slow
43# pshufb, yet it's respectable +32%/65% improvement on Core 2
44# and +58%/40% on Atom (as implied, over "hyper-threading-safe"
45# code path).
46#
47# <appro@openssl.org>
48
49$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
50push(@INC,"${dir}","${dir}../../perlasm");
51require "x86asm.pl";
52
53&asm_init($ARGV[0],"vpaes-x86.pl",$x86only = $ARGV[$#ARGV] eq "386");
54
55$PREFIX="vpaes";
56
57my ($round, $base, $magic, $key, $const, $inp, $out)=
58 ("eax", "ebx", "ecx", "edx","ebp", "esi","edi");
59
60 &rodataseg();
61&static_label("_vpaes_consts");
62&static_label("_vpaes_schedule_low_round");
63
64&set_label("_vpaes_consts",64);
65$k_inv=-0x30; # inv, inva
66 &data_word(0x0D080180,0x0E05060F,0x0A0B0C02,0x04070309);
67 &data_word(0x0F0B0780,0x01040A06,0x02050809,0x030D0E0C);
68
69$k_s0F=-0x10; # s0F
70 &data_word(0x0F0F0F0F,0x0F0F0F0F,0x0F0F0F0F,0x0F0F0F0F);
71
72$k_ipt=0x00; # input transform (lo, hi)
73 &data_word(0x5A2A7000,0xC2B2E898,0x52227808,0xCABAE090);
74 &data_word(0x317C4D00,0x4C01307D,0xB0FDCC81,0xCD80B1FC);
75
76$k_sb1=0x20; # sb1u, sb1t
77 &data_word(0xCB503E00,0xB19BE18F,0x142AF544,0xA5DF7A6E);
78 &data_word(0xFAE22300,0x3618D415,0x0D2ED9EF,0x3BF7CCC1);
79$k_sb2=0x40; # sb2u, sb2t
80 &data_word(0x0B712400,0xE27A93C6,0xBC982FCD,0x5EB7E955);
81 &data_word(0x0AE12900,0x69EB8840,0xAB82234A,0xC2A163C8);
82$k_sbo=0x60; # sbou, sbot
83 &data_word(0x6FBDC700,0xD0D26D17,0xC502A878,0x15AABF7A);
84 &data_word(0x5FBB6A00,0xCFE474A5,0x412B35FA,0x8E1E90D1);
85
86$k_mc_forward=0x80; # mc_forward
87 &data_word(0x00030201,0x04070605,0x080B0A09,0x0C0F0E0D);
88 &data_word(0x04070605,0x080B0A09,0x0C0F0E0D,0x00030201);
89 &data_word(0x080B0A09,0x0C0F0E0D,0x00030201,0x04070605);
90 &data_word(0x0C0F0E0D,0x00030201,0x04070605,0x080B0A09);
91
92$k_mc_backward=0xc0; # mc_backward
93 &data_word(0x02010003,0x06050407,0x0A09080B,0x0E0D0C0F);
94 &data_word(0x0E0D0C0F,0x02010003,0x06050407,0x0A09080B);
95 &data_word(0x0A09080B,0x0E0D0C0F,0x02010003,0x06050407);
96 &data_word(0x06050407,0x0A09080B,0x0E0D0C0F,0x02010003);
97
98$k_sr=0x100; # sr
99 &data_word(0x03020100,0x07060504,0x0B0A0908,0x0F0E0D0C);
100 &data_word(0x0F0A0500,0x030E0904,0x07020D08,0x0B06010C);
101 &data_word(0x0B020900,0x0F060D04,0x030A0108,0x070E050C);
102 &data_word(0x070A0D00,0x0B0E0104,0x0F020508,0x0306090C);
103
104$k_rcon=0x140; # rcon
105 &data_word(0xAF9DEEB6,0x1F8391B9,0x4D7C7D81,0x702A9808);
106
107$k_s63=0x150; # s63: all equal to 0x63 transformed
108 &data_word(0x5B5B5B5B,0x5B5B5B5B,0x5B5B5B5B,0x5B5B5B5B);
109
110$k_opt=0x160; # output transform
111 &data_word(0xD6B66000,0xFF9F4929,0xDEBE6808,0xF7974121);
112 &data_word(0x50BCEC00,0x01EDBD51,0xB05C0CE0,0xE10D5DB1);
113
114$k_deskew=0x180; # deskew tables: inverts the sbox's "skew"
115 &data_word(0x47A4E300,0x07E4A340,0x5DBEF91A,0x1DFEB95A);
116 &data_word(0x83EA6900,0x5F36B5DC,0xF49D1E77,0x2841C2AB);
117##
118## Decryption stuff
119## Key schedule constants
120##
121$k_dksd=0x1a0; # decryption key schedule: invskew x*D
122 &data_word(0xA3E44700,0xFEB91A5D,0x5A1DBEF9,0x0740E3A4);
123 &data_word(0xB5368300,0x41C277F4,0xAB289D1E,0x5FDC69EA);
124$k_dksb=0x1c0; # decryption key schedule: invskew x*B
125 &data_word(0x8550D500,0x9A4FCA1F,0x1CC94C99,0x03D65386);
126 &data_word(0xB6FC4A00,0x115BEDA7,0x7E3482C8,0xD993256F);
127$k_dkse=0x1e0; # decryption key schedule: invskew x*E + 0x63
128 &data_word(0x1FC9D600,0xD5031CCA,0x994F5086,0x53859A4C);
129 &data_word(0x4FDC7BE8,0xA2319605,0x20B31487,0xCD5EF96A);
130$k_dks9=0x200; # decryption key schedule: invskew x*9
131 &data_word(0x7ED9A700,0xB6116FC8,0x82255BFC,0x4AED9334);
132 &data_word(0x27143300,0x45765162,0xE9DAFDCE,0x8BB89FAC);
133
134##
135## Decryption stuff
136## Round function constants
137##
138$k_dipt=0x220; # decryption input transform
139 &data_word(0x0B545F00,0x0F505B04,0x114E451A,0x154A411E);
140 &data_word(0x60056500,0x86E383E6,0xF491F194,0x12771772);
141
142$k_dsb9=0x240; # decryption sbox output *9*u, *9*t
143 &data_word(0x9A86D600,0x851C0353,0x4F994CC9,0xCAD51F50);
144 &data_word(0xECD74900,0xC03B1789,0xB2FBA565,0x725E2C9E);
145$k_dsbd=0x260; # decryption sbox output *D*u, *D*t
146 &data_word(0xE6B1A200,0x7D57CCDF,0x882A4439,0xF56E9B13);
147 &data_word(0x24C6CB00,0x3CE2FAF7,0x15DEEFD3,0x2931180D);
148$k_dsbb=0x280; # decryption sbox output *B*u, *B*t
149 &data_word(0x96B44200,0xD0226492,0xB0F2D404,0x602646F6);
150 &data_word(0xCD596700,0xC19498A6,0x3255AA6B,0xF3FF0C3E);
151$k_dsbe=0x2a0; # decryption sbox output *E*u, *E*t
152 &data_word(0x26D4D000,0x46F29296,0x64B4F6B0,0x22426004);
153 &data_word(0xFFAAC100,0x0C55A6CD,0x98593E32,0x9467F36B);
154$k_dsbo=0x2c0; # decryption sbox final output
155 &data_word(0x7EF94000,0x1387EA53,0xD4943E2D,0xC7AA6DB9);
156 &data_word(0x93441D00,0x12D7560F,0xD8C58E9C,0xCA4B8159);
157 &previous();
158
159&function_begin_B("_vpaes_preheat");
160 &movdqa ("xmm7",&QWP($k_inv,$const));
161 &movdqa ("xmm6",&QWP($k_s0F,$const));
162 &ret ();
163&function_end_B("_vpaes_preheat");
164
165##
166## _aes_encrypt_core
167##
168## AES-encrypt %xmm0.
169##
170## Inputs:
171## %xmm0 = input
172## %xmm6-%xmm7 as in _vpaes_preheat
173## (%edx) = scheduled keys
174##
175## Output in %xmm0
176## Clobbers %xmm1-%xmm5, %eax, %ebx, %ecx, %edx
177##
178##
179&function_begin_B("_vpaes_encrypt_core");
180 &mov ($magic,16);
181 &mov ($round,&DWP(240,$key));
182 &movdqa ("xmm1","xmm6")
183 &movdqa ("xmm2",&QWP($k_ipt,$const));
184 &pandn ("xmm1","xmm0");
185 &movdqu ("xmm5",&QWP(0,$key));
186 &psrld ("xmm1",4);
187 &pand ("xmm0","xmm6");
188 &pshufb ("xmm2","xmm0");
189 &movdqa ("xmm0",&QWP($k_ipt+16,$const));
190 &pshufb ("xmm0","xmm1");
191 &pxor ("xmm2","xmm5");
192 &pxor ("xmm0","xmm2");
193 &add ($key,16);
194 &lea ($base,&DWP($k_mc_backward,$const));
195 &jmp (&label("enc_entry"));
196
197
198&set_label("enc_loop",16);
199 # middle of middle round
200 &movdqa ("xmm4",&QWP($k_sb1,$const)); # 4 : sb1u
201 &pshufb ("xmm4","xmm2"); # 4 = sb1u
202 &pxor ("xmm4","xmm5"); # 4 = sb1u + k
203 &movdqa ("xmm0",&QWP($k_sb1+16,$const));# 0 : sb1t
204 &pshufb ("xmm0","xmm3"); # 0 = sb1t
205 &pxor ("xmm0","xmm4"); # 0 = A
206 &movdqa ("xmm5",&QWP($k_sb2,$const)); # 4 : sb2u
207 &pshufb ("xmm5","xmm2"); # 4 = sb2u
208 &movdqa ("xmm1",&QWP(-0x40,$base,$magic));# .Lk_mc_forward[]
209 &movdqa ("xmm2",&QWP($k_sb2+16,$const));# 2 : sb2t
210 &pshufb ("xmm2","xmm3"); # 2 = sb2t
211 &pxor ("xmm2","xmm5"); # 2 = 2A
212 &movdqa ("xmm4",&QWP(0,$base,$magic)); # .Lk_mc_backward[]
213 &movdqa ("xmm3","xmm0"); # 3 = A
214 &pshufb ("xmm0","xmm1"); # 0 = B
215 &add ($key,16); # next key
216 &pxor ("xmm0","xmm2"); # 0 = 2A+B
217 &pshufb ("xmm3","xmm4"); # 3 = D
218 &add ($magic,16); # next mc
219 &pxor ("xmm3","xmm0"); # 3 = 2A+B+D
220 &pshufb ("xmm0","xmm1"); # 0 = 2B+C
221 &and ($magic,0x30); # ... mod 4
222 &pxor ("xmm0","xmm3"); # 0 = 2A+3B+C+D
223 &sub ($round,1); # nr--
224
225&set_label("enc_entry");
226 # top of round
227 &movdqa ("xmm1","xmm6"); # 1 : i
228 &pandn ("xmm1","xmm0"); # 1 = i<<4
229 &psrld ("xmm1",4); # 1 = i
230 &pand ("xmm0","xmm6"); # 0 = k
231 &movdqa ("xmm5",&QWP($k_inv+16,$const));# 2 : a/k
232 &pshufb ("xmm5","xmm0"); # 2 = a/k
233 &pxor ("xmm0","xmm1"); # 0 = j
234 &movdqa ("xmm3","xmm7"); # 3 : 1/i
235 &pshufb ("xmm3","xmm1"); # 3 = 1/i
236 &pxor ("xmm3","xmm5"); # 3 = iak = 1/i + a/k
237 &movdqa ("xmm4","xmm7"); # 4 : 1/j
238 &pshufb ("xmm4","xmm0"); # 4 = 1/j
239 &pxor ("xmm4","xmm5"); # 4 = jak = 1/j + a/k
240 &movdqa ("xmm2","xmm7"); # 2 : 1/iak
241 &pshufb ("xmm2","xmm3"); # 2 = 1/iak
242 &pxor ("xmm2","xmm0"); # 2 = io
243 &movdqa ("xmm3","xmm7"); # 3 : 1/jak
244 &movdqu ("xmm5",&QWP(0,$key));
245 &pshufb ("xmm3","xmm4"); # 3 = 1/jak
246 &pxor ("xmm3","xmm1"); # 3 = jo
247 &jnz (&label("enc_loop"));
248
249 # middle of last round
250 &movdqa ("xmm4",&QWP($k_sbo,$const)); # 3 : sbou .Lk_sbo
251 &movdqa ("xmm0",&QWP($k_sbo+16,$const));# 3 : sbot .Lk_sbo+16
252 &pshufb ("xmm4","xmm2"); # 4 = sbou
253 &pxor ("xmm4","xmm5"); # 4 = sb1u + k
254 &pshufb ("xmm0","xmm3"); # 0 = sb1t
255 &movdqa ("xmm1",&QWP(0x40,$base,$magic));# .Lk_sr[]
256 &pxor ("xmm0","xmm4"); # 0 = A
257 &pshufb ("xmm0","xmm1");
258 &ret ();
259&function_end_B("_vpaes_encrypt_core");
260
261##
262## Decryption core
263##
264## Same API as encryption core.
265##
266&function_begin_B("_vpaes_decrypt_core");
267 &mov ($round,&DWP(240,$key));
268 &lea ($base,&DWP($k_dsbd,$const));
269 &movdqa ("xmm1","xmm6");
270 &movdqa ("xmm2",&QWP($k_dipt-$k_dsbd,$base));
271 &pandn ("xmm1","xmm0");
272 &mov ($magic,$round);
273 &psrld ("xmm1",4)
274 &movdqu ("xmm5",&QWP(0,$key));
275 &shl ($magic,4);
276 &pand ("xmm0","xmm6");
277 &pshufb ("xmm2","xmm0");
278 &movdqa ("xmm0",&QWP($k_dipt-$k_dsbd+16,$base));
279 &xor ($magic,0x30);
280 &pshufb ("xmm0","xmm1");
281 &and ($magic,0x30);
282 &pxor ("xmm2","xmm5");
283 &movdqa ("xmm5",&QWP($k_mc_forward+48,$const));
284 &pxor ("xmm0","xmm2");
285 &add ($key,16);
286 &lea ($magic,&DWP($k_sr-$k_dsbd,$base,$magic));
287 &jmp (&label("dec_entry"));
288
289&set_label("dec_loop",16);
290##
291## Inverse mix columns
292##
293 &movdqa ("xmm4",&QWP(-0x20,$base)); # 4 : sb9u
294 &pshufb ("xmm4","xmm2"); # 4 = sb9u
295 &pxor ("xmm4","xmm0");
296 &movdqa ("xmm0",&QWP(-0x10,$base)); # 0 : sb9t
297 &pshufb ("xmm0","xmm3"); # 0 = sb9t
298 &pxor ("xmm0","xmm4"); # 0 = ch
299 &add ($key,16); # next round key
300
301 &pshufb ("xmm0","xmm5"); # MC ch
302 &movdqa ("xmm4",&QWP(0,$base)); # 4 : sbdu
303 &pshufb ("xmm4","xmm2"); # 4 = sbdu
304 &pxor ("xmm4","xmm0"); # 4 = ch
305 &movdqa ("xmm0",&QWP(0x10,$base)); # 0 : sbdt
306 &pshufb ("xmm0","xmm3"); # 0 = sbdt
307 &pxor ("xmm0","xmm4"); # 0 = ch
308 &sub ($round,1); # nr--
309
310 &pshufb ("xmm0","xmm5"); # MC ch
311 &movdqa ("xmm4",&QWP(0x20,$base)); # 4 : sbbu
312 &pshufb ("xmm4","xmm2"); # 4 = sbbu
313 &pxor ("xmm4","xmm0"); # 4 = ch
314 &movdqa ("xmm0",&QWP(0x30,$base)); # 0 : sbbt
315 &pshufb ("xmm0","xmm3"); # 0 = sbbt
316 &pxor ("xmm0","xmm4"); # 0 = ch
317
318 &pshufb ("xmm0","xmm5"); # MC ch
319 &movdqa ("xmm4",&QWP(0x40,$base)); # 4 : sbeu
320 &pshufb ("xmm4","xmm2"); # 4 = sbeu
321 &pxor ("xmm4","xmm0"); # 4 = ch
322 &movdqa ("xmm0",&QWP(0x50,$base)); # 0 : sbet
323 &pshufb ("xmm0","xmm3"); # 0 = sbet
324 &pxor ("xmm0","xmm4"); # 0 = ch
325
326 &palignr("xmm5","xmm5",12);
327
328&set_label("dec_entry");
329 # top of round
330 &movdqa ("xmm1","xmm6"); # 1 : i
331 &pandn ("xmm1","xmm0"); # 1 = i<<4
332 &psrld ("xmm1",4); # 1 = i
333 &pand ("xmm0","xmm6"); # 0 = k
334 &movdqa ("xmm2",&QWP($k_inv+16,$const));# 2 : a/k
335 &pshufb ("xmm2","xmm0"); # 2 = a/k
336 &pxor ("xmm0","xmm1"); # 0 = j
337 &movdqa ("xmm3","xmm7"); # 3 : 1/i
338 &pshufb ("xmm3","xmm1"); # 3 = 1/i
339 &pxor ("xmm3","xmm2"); # 3 = iak = 1/i + a/k
340 &movdqa ("xmm4","xmm7"); # 4 : 1/j
341 &pshufb ("xmm4","xmm0"); # 4 = 1/j
342 &pxor ("xmm4","xmm2"); # 4 = jak = 1/j + a/k
343 &movdqa ("xmm2","xmm7"); # 2 : 1/iak
344 &pshufb ("xmm2","xmm3"); # 2 = 1/iak
345 &pxor ("xmm2","xmm0"); # 2 = io
346 &movdqa ("xmm3","xmm7"); # 3 : 1/jak
347 &pshufb ("xmm3","xmm4"); # 3 = 1/jak
348 &pxor ("xmm3","xmm1"); # 3 = jo
349 &movdqu ("xmm0",&QWP(0,$key));
350 &jnz (&label("dec_loop"));
351
352 # middle of last round
353 &movdqa ("xmm4",&QWP(0x60,$base)); # 3 : sbou
354 &pshufb ("xmm4","xmm2"); # 4 = sbou
355 &pxor ("xmm4","xmm0"); # 4 = sb1u + k
356 &movdqa ("xmm0",&QWP(0x70,$base)); # 0 : sbot
357 &movdqa ("xmm2",&QWP(0,$magic));
358 &pshufb ("xmm0","xmm3"); # 0 = sb1t
359 &pxor ("xmm0","xmm4"); # 0 = A
360 &pshufb ("xmm0","xmm2");
361 &ret ();
362&function_end_B("_vpaes_decrypt_core");
363
364########################################################
365## ##
366## AES key schedule ##
367## ##
368########################################################
369&function_begin_B("_vpaes_schedule_core");
370 &movdqu ("xmm0",&QWP(0,$inp)); # load key (unaligned)
371 &movdqa ("xmm2",&QWP($k_rcon,$const)); # load rcon
372
373 # input transform
374 &movdqa ("xmm3","xmm0");
375 &lea ($base,&DWP($k_ipt,$const));
376 &movdqa (&QWP(4,"esp"),"xmm2"); # xmm8
377 &call ("_vpaes_schedule_transform");
378 &movdqa ("xmm7","xmm0");
379
380 &test ($out,$out);
381 &jnz (&label("schedule_am_decrypting"));
382
383 # encrypting, output zeroth round key after transform
384 &movdqu (&QWP(0,$key),"xmm0");
385 &jmp (&label("schedule_go"));
386
387&set_label("schedule_am_decrypting");
388 # decrypting, output zeroth round key after shiftrows
389 &movdqa ("xmm1",&QWP($k_sr,$const,$magic));
390 &pshufb ("xmm3","xmm1");
391 &movdqu (&QWP(0,$key),"xmm3");
392 &xor ($magic,0x30);
393
394&set_label("schedule_go");
395 &cmp ($round,192);
396 &ja (&label("schedule_256"));
397 &je (&label("schedule_192"));
398 # 128: fall though
399
400##
401## .schedule_128
402##
403## 128-bit specific part of key schedule.
404##
405## This schedule is really simple, because all its parts
406## are accomplished by the subroutines.
407##
408&set_label("schedule_128");
409 &mov ($round,10);
410
411&set_label("loop_schedule_128");
412 &call ("_vpaes_schedule_round");
413 &dec ($round);
414 &jz (&label("schedule_mangle_last"));
415 &call ("_vpaes_schedule_mangle"); # write output
416 &jmp (&label("loop_schedule_128"));
417
418##
419## .aes_schedule_192
420##
421## 192-bit specific part of key schedule.
422##
423## The main body of this schedule is the same as the 128-bit
424## schedule, but with more smearing. The long, high side is
425## stored in %xmm7 as before, and the short, low side is in
426## the high bits of %xmm6.
427##
428## This schedule is somewhat nastier, however, because each
429## round produces 192 bits of key material, or 1.5 round keys.
430## Therefore, on each cycle we do 2 rounds and produce 3 round
431## keys.
432##
433&set_label("schedule_192",16);
434 &movdqu ("xmm0",&QWP(8,$inp)); # load key part 2 (very unaligned)
435 &call ("_vpaes_schedule_transform"); # input transform
436 &movdqa ("xmm6","xmm0"); # save short part
437 &pxor ("xmm4","xmm4"); # clear 4
438 &movhlps("xmm6","xmm4"); # clobber low side with zeros
439 &mov ($round,4);
440
441&set_label("loop_schedule_192");
442 &call ("_vpaes_schedule_round");
443 &palignr("xmm0","xmm6",8);
444 &call ("_vpaes_schedule_mangle"); # save key n
445 &call ("_vpaes_schedule_192_smear");
446 &call ("_vpaes_schedule_mangle"); # save key n+1
447 &call ("_vpaes_schedule_round");
448 &dec ($round);
449 &jz (&label("schedule_mangle_last"));
450 &call ("_vpaes_schedule_mangle"); # save key n+2
451 &call ("_vpaes_schedule_192_smear");
452 &jmp (&label("loop_schedule_192"));
453
454##
455## .aes_schedule_256
456##
457## 256-bit specific part of key schedule.
458##
459## The structure here is very similar to the 128-bit
460## schedule, but with an additional "low side" in
461## %xmm6. The low side's rounds are the same as the
462## high side's, except no rcon and no rotation.
463##
464&set_label("schedule_256",16);
465 &movdqu ("xmm0",&QWP(16,$inp)); # load key part 2 (unaligned)
466 &call ("_vpaes_schedule_transform"); # input transform
467 &mov ($round,7);
468
469&set_label("loop_schedule_256");
470 &call ("_vpaes_schedule_mangle"); # output low result
471 &movdqa ("xmm6","xmm0"); # save cur_lo in xmm6
472
473 # high round
474 &call ("_vpaes_schedule_round");
475 &dec ($round);
476 &jz (&label("schedule_mangle_last"));
477 &call ("_vpaes_schedule_mangle");
478
479 # low round. swap xmm7 and xmm6
480 &pshufd ("xmm0","xmm0",0xFF);
481 &movdqa (&QWP(20,"esp"),"xmm7");
482 &movdqa ("xmm7","xmm6");
483 &call ("_vpaes_schedule_low_round");
484 &movdqa ("xmm7",&QWP(20,"esp"));
485
486 &jmp (&label("loop_schedule_256"));
487
488##
489## .aes_schedule_mangle_last
490##
491## Mangler for last round of key schedule
492## Mangles %xmm0
493## when encrypting, outputs out(%xmm0) ^ 63
494## when decrypting, outputs unskew(%xmm0)
495##
496## Always called right before return... jumps to cleanup and exits
497##
498&set_label("schedule_mangle_last",16);
499 # schedule last round key from xmm0
500 &lea ($base,&DWP($k_deskew,$const));
501 &test ($out,$out);
502 &jnz (&label("schedule_mangle_last_dec"));
503
504 # encrypting
505 &movdqa ("xmm1",&QWP($k_sr,$const,$magic));
506 &pshufb ("xmm0","xmm1"); # output permute
507 &lea ($base,&DWP($k_opt,$const)); # prepare to output transform
508 &add ($key,32);
509
510&set_label("schedule_mangle_last_dec");
511 &add ($key,-16);
512 &pxor ("xmm0",&QWP($k_s63,$const));
513 &call ("_vpaes_schedule_transform"); # output transform
514 &movdqu (&QWP(0,$key),"xmm0"); # save last key
515
516 # cleanup
517 &pxor ("xmm0","xmm0");
518 &pxor ("xmm1","xmm1");
519 &pxor ("xmm2","xmm2");
520 &pxor ("xmm3","xmm3");
521 &pxor ("xmm4","xmm4");
522 &pxor ("xmm5","xmm5");
523 &pxor ("xmm6","xmm6");
524 &pxor ("xmm7","xmm7");
525 &ret ();
526&function_end_B("_vpaes_schedule_core");
527
528##
529## .aes_schedule_192_smear
530##
531## Smear the short, low side in the 192-bit key schedule.
532##
533## Inputs:
534## %xmm7: high side, b a x y
535## %xmm6: low side, d c 0 0
536## %xmm13: 0
537##
538## Outputs:
539## %xmm6: b+c+d b+c 0 0
540## %xmm0: b+c+d b+c b a
541##
542&function_begin_B("_vpaes_schedule_192_smear");
543 &pshufd ("xmm0","xmm6",0x80); # d c 0 0 -> c 0 0 0
544 &pxor ("xmm6","xmm0"); # -> c+d c 0 0
545 &pshufd ("xmm0","xmm7",0xFE); # b a _ _ -> b b b a
546 &pxor ("xmm6","xmm0"); # -> b+c+d b+c b a
547 &movdqa ("xmm0","xmm6");
548 &pxor ("xmm1","xmm1");
549 &movhlps("xmm6","xmm1"); # clobber low side with zeros
550 &ret ();
551&function_end_B("_vpaes_schedule_192_smear");
552
553##
554## .aes_schedule_round
555##
556## Runs one main round of the key schedule on %xmm0, %xmm7
557##
558## Specifically, runs subbytes on the high dword of %xmm0
559## then rotates it by one byte and xors into the low dword of
560## %xmm7.
561##
562## Adds rcon from low byte of %xmm8, then rotates %xmm8 for
563## next rcon.
564##
565## Smears the dwords of %xmm7 by xoring the low into the
566## second low, result into third, result into highest.
567##
568## Returns results in %xmm7 = %xmm0.
569## Clobbers %xmm1-%xmm5.
570##
571&function_begin_B("_vpaes_schedule_round");
572 # extract rcon from xmm8
573 &movdqa ("xmm2",&QWP(8,"esp")); # xmm8
574 &pxor ("xmm1","xmm1");
575 &palignr("xmm1","xmm2",15);
576 &palignr("xmm2","xmm2",15);
577 &pxor ("xmm7","xmm1");
578
579 # rotate
580 &pshufd ("xmm0","xmm0",0xFF);
581 &palignr("xmm0","xmm0",1);
582
583 # fall through...
584 &movdqa (&QWP(8,"esp"),"xmm2"); # xmm8
585
586 # low round: same as high round, but no rotation and no rcon.
587&set_label("_vpaes_schedule_low_round");
588 # smear xmm7
589 &movdqa ("xmm1","xmm7");
590 &pslldq ("xmm7",4);
591 &pxor ("xmm7","xmm1");
592 &movdqa ("xmm1","xmm7");
593 &pslldq ("xmm7",8);
594 &pxor ("xmm7","xmm1");
595 &pxor ("xmm7",&QWP($k_s63,$const));
596
597 # subbyte
598 &movdqa ("xmm4",&QWP($k_s0F,$const));
599 &movdqa ("xmm5",&QWP($k_inv,$const)); # 4 : 1/j
600 &movdqa ("xmm1","xmm4");
601 &pandn ("xmm1","xmm0");
602 &psrld ("xmm1",4); # 1 = i
603 &pand ("xmm0","xmm4"); # 0 = k
604 &movdqa ("xmm2",&QWP($k_inv+16,$const));# 2 : a/k
605 &pshufb ("xmm2","xmm0"); # 2 = a/k
606 &pxor ("xmm0","xmm1"); # 0 = j
607 &movdqa ("xmm3","xmm5"); # 3 : 1/i
608 &pshufb ("xmm3","xmm1"); # 3 = 1/i
609 &pxor ("xmm3","xmm2"); # 3 = iak = 1/i + a/k
610 &movdqa ("xmm4","xmm5"); # 4 : 1/j
611 &pshufb ("xmm4","xmm0"); # 4 = 1/j
612 &pxor ("xmm4","xmm2"); # 4 = jak = 1/j + a/k
613 &movdqa ("xmm2","xmm5"); # 2 : 1/iak
614 &pshufb ("xmm2","xmm3"); # 2 = 1/iak
615 &pxor ("xmm2","xmm0"); # 2 = io
616 &movdqa ("xmm3","xmm5"); # 3 : 1/jak
617 &pshufb ("xmm3","xmm4"); # 3 = 1/jak
618 &pxor ("xmm3","xmm1"); # 3 = jo
619 &movdqa ("xmm4",&QWP($k_sb1,$const)); # 4 : sbou
620 &pshufb ("xmm4","xmm2"); # 4 = sbou
621 &movdqa ("xmm0",&QWP($k_sb1+16,$const));# 0 : sbot
622 &pshufb ("xmm0","xmm3"); # 0 = sb1t
623 &pxor ("xmm0","xmm4"); # 0 = sbox output
624
625 # add in smeared stuff
626 &pxor ("xmm0","xmm7");
627 &movdqa ("xmm7","xmm0");
628 &ret ();
629&function_end_B("_vpaes_schedule_round");
630
631##
632## .aes_schedule_transform
633##
634## Linear-transform %xmm0 according to tables at (%ebx)
635##
636## Output in %xmm0
637## Clobbers %xmm1, %xmm2
638##
639&function_begin_B("_vpaes_schedule_transform");
640 &movdqa ("xmm2",&QWP($k_s0F,$const));
641 &movdqa ("xmm1","xmm2");
642 &pandn ("xmm1","xmm0");
643 &psrld ("xmm1",4);
644 &pand ("xmm0","xmm2");
645 &movdqa ("xmm2",&QWP(0,$base));
646 &pshufb ("xmm2","xmm0");
647 &movdqa ("xmm0",&QWP(16,$base));
648 &pshufb ("xmm0","xmm1");
649 &pxor ("xmm0","xmm2");
650 &ret ();
651&function_end_B("_vpaes_schedule_transform");
652
653##
654## .aes_schedule_mangle
655##
656## Mangle xmm0 from (basis-transformed) standard version
657## to our version.
658##
659## On encrypt,
660## xor with 0x63
661## multiply by circulant 0,1,1,1
662## apply shiftrows transform
663##
664## On decrypt,
665## xor with 0x63
666## multiply by "inverse mixcolumns" circulant E,B,D,9
667## deskew
668## apply shiftrows transform
669##
670##
671## Writes out to (%edx), and increments or decrements it
672## Keeps track of round number mod 4 in %ecx
673## Preserves xmm0
674## Clobbers xmm1-xmm5
675##
676&function_begin_B("_vpaes_schedule_mangle");
677 &movdqa ("xmm4","xmm0"); # save xmm0 for later
678 &movdqa ("xmm5",&QWP($k_mc_forward,$const));
679 &test ($out,$out);
680 &jnz (&label("schedule_mangle_dec"));
681
682 # encrypting
683 &add ($key,16);
684 &pxor ("xmm4",&QWP($k_s63,$const));
685 &pshufb ("xmm4","xmm5");
686 &movdqa ("xmm3","xmm4");
687 &pshufb ("xmm4","xmm5");
688 &pxor ("xmm3","xmm4");
689 &pshufb ("xmm4","xmm5");
690 &pxor ("xmm3","xmm4");
691
692 &jmp (&label("schedule_mangle_both"));
693
694&set_label("schedule_mangle_dec",16);
695 # inverse mix columns
696 &movdqa ("xmm2",&QWP($k_s0F,$const));
697 &lea ($inp,&DWP($k_dksd,$const));
698 &movdqa ("xmm1","xmm2");
699 &pandn ("xmm1","xmm4");
700 &psrld ("xmm1",4); # 1 = hi
701 &pand ("xmm4","xmm2"); # 4 = lo
702
703 &movdqa ("xmm2",&QWP(0,$inp));
704 &pshufb ("xmm2","xmm4");
705 &movdqa ("xmm3",&QWP(0x10,$inp));
706 &pshufb ("xmm3","xmm1");
707 &pxor ("xmm3","xmm2");
708 &pshufb ("xmm3","xmm5");
709
710 &movdqa ("xmm2",&QWP(0x20,$inp));
711 &pshufb ("xmm2","xmm4");
712 &pxor ("xmm2","xmm3");
713 &movdqa ("xmm3",&QWP(0x30,$inp));
714 &pshufb ("xmm3","xmm1");
715 &pxor ("xmm3","xmm2");
716 &pshufb ("xmm3","xmm5");
717
718 &movdqa ("xmm2",&QWP(0x40,$inp));
719 &pshufb ("xmm2","xmm4");
720 &pxor ("xmm2","xmm3");
721 &movdqa ("xmm3",&QWP(0x50,$inp));
722 &pshufb ("xmm3","xmm1");
723 &pxor ("xmm3","xmm2");
724 &pshufb ("xmm3","xmm5");
725
726 &movdqa ("xmm2",&QWP(0x60,$inp));
727 &pshufb ("xmm2","xmm4");
728 &pxor ("xmm2","xmm3");
729 &movdqa ("xmm3",&QWP(0x70,$inp));
730 &pshufb ("xmm3","xmm1");
731 &pxor ("xmm3","xmm2");
732
733 &add ($key,-16);
734
735&set_label("schedule_mangle_both");
736 &movdqa ("xmm1",&QWP($k_sr,$const,$magic));
737 &pshufb ("xmm3","xmm1");
738 &add ($magic,-16);
739 &and ($magic,0x30);
740 &movdqu (&QWP(0,$key),"xmm3");
741 &ret ();
742&function_end_B("_vpaes_schedule_mangle");
743
744#
745# Interface to OpenSSL
746#
747&function_begin("${PREFIX}_set_encrypt_key");
748 &mov ($inp,&wparam(0)); # inp
749 &lea ($base,&DWP(-56,"esp"));
750 &mov ($round,&wparam(1)); # bits
751 &and ($base,-16);
752 &mov ($key,&wparam(2)); # key
753 &xchg ($base,"esp"); # alloca
754 &mov (&DWP(48,"esp"),$base);
755
756 &mov ($base,$round);
757 &shr ($base,5);
758 &add ($base,5);
759 &mov (&DWP(240,$key),$base); # AES_KEY->rounds = nbits/32+5;
760 &mov ($magic,0x30);
761 &mov ($out,0);
762
763 &picsetup($const);
764 &picsymbol($const, &label("_vpaes_consts"), $const);
765 &lea ($const,&DWP(0x30,$const))
766
767 &call ("_vpaes_schedule_core");
768
769 &mov ("esp",&DWP(48,"esp"));
770 &xor ("eax","eax");
771&function_end("${PREFIX}_set_encrypt_key");
772
773&function_begin("${PREFIX}_set_decrypt_key");
774 &mov ($inp,&wparam(0)); # inp
775 &lea ($base,&DWP(-56,"esp"));
776 &mov ($round,&wparam(1)); # bits
777 &and ($base,-16);
778 &mov ($key,&wparam(2)); # key
779 &xchg ($base,"esp"); # alloca
780 &mov (&DWP(48,"esp"),$base);
781
782 &mov ($base,$round);
783 &shr ($base,5);
784 &add ($base,5);
785 &mov (&DWP(240,$key),$base); # AES_KEY->rounds = nbits/32+5;
786 &shl ($base,4);
787 &lea ($key,&DWP(16,$key,$base));
788
789 &mov ($out,1);
790 &mov ($magic,$round);
791 &shr ($magic,1);
792 &and ($magic,32);
793 &xor ($magic,32); # nbist==192?0:32;
794
795 &picsetup($const);
796 &picsymbol($const, &label("_vpaes_consts"), $const);
797 &lea ($const,&DWP(0x30,$const))
798
799 &call ("_vpaes_schedule_core");
800
801 &mov ("esp",&DWP(48,"esp"));
802 &xor ("eax","eax");
803&function_end("${PREFIX}_set_decrypt_key");
804
805&function_begin("${PREFIX}_encrypt");
806 &picsetup($const);
807 &picsymbol($const, &label("_vpaes_consts"), $const);
808 &lea ($const,&DWP(0x30,$const))
809
810 &call ("_vpaes_preheat");
811 &mov ($inp,&wparam(0)); # inp
812 &lea ($base,&DWP(-56,"esp"));
813 &mov ($out,&wparam(1)); # out
814 &and ($base,-16);
815 &mov ($key,&wparam(2)); # key
816 &xchg ($base,"esp"); # alloca
817 &mov (&DWP(48,"esp"),$base);
818
819 &movdqu ("xmm0",&QWP(0,$inp));
820 &call ("_vpaes_encrypt_core");
821 &movdqu (&QWP(0,$out),"xmm0");
822
823 &mov ("esp",&DWP(48,"esp"));
824&function_end("${PREFIX}_encrypt");
825
826&function_begin("${PREFIX}_decrypt");
827 &picsetup($const);
828 &picsymbol($const, &label("_vpaes_consts"), $const);
829 &lea ($const,&DWP(0x30,$const))
830
831 &call ("_vpaes_preheat");
832 &mov ($inp,&wparam(0)); # inp
833 &lea ($base,&DWP(-56,"esp"));
834 &mov ($out,&wparam(1)); # out
835 &and ($base,-16);
836 &mov ($key,&wparam(2)); # key
837 &xchg ($base,"esp"); # alloca
838 &mov (&DWP(48,"esp"),$base);
839
840 &movdqu ("xmm0",&QWP(0,$inp));
841 &call ("_vpaes_decrypt_core");
842 &movdqu (&QWP(0,$out),"xmm0");
843
844 &mov ("esp",&DWP(48,"esp"));
845&function_end("${PREFIX}_decrypt");
846
847&function_begin("${PREFIX}_cbc_encrypt");
848 &mov ($inp,&wparam(0)); # inp
849 &mov ($out,&wparam(1)); # out
850 &mov ($round,&wparam(2)); # len
851 &mov ($key,&wparam(3)); # key
852 &sub ($round,16);
853 &jc (&label("cbc_abort"));
854 &lea ($base,&DWP(-56,"esp"));
855 &mov ($const,&wparam(4)); # ivp
856 &and ($base,-16);
857 &mov ($magic,&wparam(5)); # enc
858 &xchg ($base,"esp"); # alloca
859 &movdqu ("xmm1",&QWP(0,$const)); # load IV
860 &sub ($out,$inp);
861 &mov (&DWP(48,"esp"),$base);
862
863 &mov (&DWP(0,"esp"),$out); # save out
864 &mov (&DWP(4,"esp"),$key) # save key
865 &mov (&DWP(8,"esp"),$const); # save ivp
866 &mov ($out,$round); # $out works as $len
867
868 &picsetup($const);
869 &picsymbol($const, &label("_vpaes_consts"), $const);
870 &lea ($const,&DWP(0x30,$const))
871
872 &call ("_vpaes_preheat");
873 &cmp ($magic,0);
874 &je (&label("cbc_dec_loop"));
875 &jmp (&label("cbc_enc_loop"));
876
877&set_label("cbc_enc_loop",16);
878 &movdqu ("xmm0",&QWP(0,$inp)); # load input
879 &pxor ("xmm0","xmm1"); # inp^=iv
880 &call ("_vpaes_encrypt_core");
881 &mov ($base,&DWP(0,"esp")); # restore out
882 &mov ($key,&DWP(4,"esp")); # restore key
883 &movdqa ("xmm1","xmm0");
884 &movdqu (&QWP(0,$base,$inp),"xmm0"); # write output
885 &lea ($inp,&DWP(16,$inp));
886 &sub ($out,16);
887 &jnc (&label("cbc_enc_loop"));
888 &jmp (&label("cbc_done"));
889
890&set_label("cbc_dec_loop",16);
891 &movdqu ("xmm0",&QWP(0,$inp)); # load input
892 &movdqa (&QWP(16,"esp"),"xmm1"); # save IV
893 &movdqa (&QWP(32,"esp"),"xmm0"); # save future IV
894 &call ("_vpaes_decrypt_core");
895 &mov ($base,&DWP(0,"esp")); # restore out
896 &mov ($key,&DWP(4,"esp")); # restore key
897 &pxor ("xmm0",&QWP(16,"esp")); # out^=iv
898 &movdqa ("xmm1",&QWP(32,"esp")); # load next IV
899 &movdqu (&QWP(0,$base,$inp),"xmm0"); # write output
900 &lea ($inp,&DWP(16,$inp));
901 &sub ($out,16);
902 &jnc (&label("cbc_dec_loop"));
903
904&set_label("cbc_done");
905 &mov ($base,&DWP(8,"esp")); # restore ivp
906 &mov ("esp",&DWP(48,"esp"));
907 &movdqu (&QWP(0,$base),"xmm1"); # write IV
908&set_label("cbc_abort");
909&function_end("${PREFIX}_cbc_encrypt");
910
911&asm_finish();
diff --git a/src/lib/libcrypto/aes/asm/vpaes-x86_64.pl b/src/lib/libcrypto/aes/asm/vpaes-x86_64.pl
deleted file mode 100644
index 7d92e8d8ca..0000000000
--- a/src/lib/libcrypto/aes/asm/vpaes-x86_64.pl
+++ /dev/null
@@ -1,1222 +0,0 @@
1#!/usr/bin/env perl
2
3######################################################################
4## Constant-time SSSE3 AES core implementation.
5## version 0.1
6##
7## By Mike Hamburg (Stanford University), 2009
8## Public domain.
9##
10## For details see http://shiftleft.org/papers/vector_aes/ and
11## http://crypto.stanford.edu/vpaes/.
12
13######################################################################
14# September 2011.
15#
16# Interface to OpenSSL as "almost" drop-in replacement for
17# aes-x86_64.pl. "Almost" refers to the fact that AES_cbc_encrypt
18# doesn't handle partial vectors (doesn't have to if called from
19# EVP only). "Drop-in" implies that this module doesn't share key
20# schedule structure with the original nor does it make assumption
21# about its alignment...
22#
23# Performance summary. aes-x86_64.pl column lists large-block CBC
24# encrypt/decrypt/with-hyper-threading-off(*) results in cycles per
25# byte processed with 128-bit key, and vpaes-x86_64.pl column -
26# [also large-block CBC] encrypt/decrypt.
27#
28# aes-x86_64.pl vpaes-x86_64.pl
29#
30# Core 2(**) 30.5/43.7/14.3 21.8/25.7(***)
31# Nehalem 30.5/42.2/14.6 9.8/11.8
32# Atom 63.9/79.0/32.1 64.0/84.8(***)
33#
34# (*) "Hyper-threading" in the context refers rather to cache shared
35# among multiple cores, than to specifically Intel HTT. As vast
36# majority of contemporary cores share cache, slower code path
37# is common place. In other words "with-hyper-threading-off"
38# results are presented mostly for reference purposes.
39#
40# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe.
41#
42# (***) Less impressive improvement on Core 2 and Atom is due to slow
43# pshufb, yet it's respectable +40%/78% improvement on Core 2
44# (as implied, over "hyper-threading-safe" code path).
45#
46# <appro@openssl.org>
47
48$flavour = shift;
49$output = shift;
50if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
51
52$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
53
54$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
55( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or
56( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
57die "can't locate x86_64-xlate.pl";
58
59open OUT,"| \"$^X\" $xlate $flavour $output";
60*STDOUT=*OUT;
61
62$PREFIX="vpaes";
63
64$code.=<<___;
65.text
66
67##
68## _aes_encrypt_core
69##
70## AES-encrypt %xmm0.
71##
72## Inputs:
73## %xmm0 = input
74## %xmm9-%xmm15 as in _vpaes_preheat
75## (%rdx) = scheduled keys
76##
77## Output in %xmm0
78## Clobbers %xmm1-%xmm5, %r9, %r10, %r11, %rax
79## Preserves %xmm6 - %xmm8 so you get some local vectors
80##
81##
82.type _vpaes_encrypt_core,\@abi-omnipotent
83.align 16
84_vpaes_encrypt_core:
85 _CET_ENDBR
86 mov %rdx, %r9
87 mov \$16, %r11
88 mov 240(%rdx),%eax
89 movdqa %xmm9, %xmm1
90 movdqa .Lk_ipt(%rip), %xmm2 # iptlo
91 pandn %xmm0, %xmm1
92 movdqu (%r9), %xmm5 # round0 key
93 psrld \$4, %xmm1
94 pand %xmm9, %xmm0
95 pshufb %xmm0, %xmm2
96 movdqa .Lk_ipt+16(%rip), %xmm0 # ipthi
97 pshufb %xmm1, %xmm0
98 pxor %xmm5, %xmm2
99 pxor %xmm2, %xmm0
100 add \$16, %r9
101 lea .Lk_mc_backward(%rip),%r10
102 jmp .Lenc_entry
103
104.align 16
105.Lenc_loop:
106 # middle of middle round
107 movdqa %xmm13, %xmm4 # 4 : sb1u
108 pshufb %xmm2, %xmm4 # 4 = sb1u
109 pxor %xmm5, %xmm4 # 4 = sb1u + k
110 movdqa %xmm12, %xmm0 # 0 : sb1t
111 pshufb %xmm3, %xmm0 # 0 = sb1t
112 pxor %xmm4, %xmm0 # 0 = A
113 movdqa %xmm15, %xmm5 # 4 : sb2u
114 pshufb %xmm2, %xmm5 # 4 = sb2u
115 movdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[]
116 movdqa %xmm14, %xmm2 # 2 : sb2t
117 pshufb %xmm3, %xmm2 # 2 = sb2t
118 pxor %xmm5, %xmm2 # 2 = 2A
119 movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[]
120 movdqa %xmm0, %xmm3 # 3 = A
121 pshufb %xmm1, %xmm0 # 0 = B
122 add \$16, %r9 # next key
123 pxor %xmm2, %xmm0 # 0 = 2A+B
124 pshufb %xmm4, %xmm3 # 3 = D
125 add \$16, %r11 # next mc
126 pxor %xmm0, %xmm3 # 3 = 2A+B+D
127 pshufb %xmm1, %xmm0 # 0 = 2B+C
128 and \$0x30, %r11 # ... mod 4
129 pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D
130 sub \$1,%rax # nr--
131
132.Lenc_entry:
133 # top of round
134 movdqa %xmm9, %xmm1 # 1 : i
135 pandn %xmm0, %xmm1 # 1 = i<<4
136 psrld \$4, %xmm1 # 1 = i
137 pand %xmm9, %xmm0 # 0 = k
138 movdqa %xmm11, %xmm5 # 2 : a/k
139 pshufb %xmm0, %xmm5 # 2 = a/k
140 pxor %xmm1, %xmm0 # 0 = j
141 movdqa %xmm10, %xmm3 # 3 : 1/i
142 pshufb %xmm1, %xmm3 # 3 = 1/i
143 pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k
144 movdqa %xmm10, %xmm4 # 4 : 1/j
145 pshufb %xmm0, %xmm4 # 4 = 1/j
146 pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k
147 movdqa %xmm10, %xmm2 # 2 : 1/iak
148 pshufb %xmm3, %xmm2 # 2 = 1/iak
149 pxor %xmm0, %xmm2 # 2 = io
150 movdqa %xmm10, %xmm3 # 3 : 1/jak
151 movdqu (%r9), %xmm5
152 pshufb %xmm4, %xmm3 # 3 = 1/jak
153 pxor %xmm1, %xmm3 # 3 = jo
154 jnz .Lenc_loop
155
156 # middle of last round
157 movdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo
158 movdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16
159 pshufb %xmm2, %xmm4 # 4 = sbou
160 pxor %xmm5, %xmm4 # 4 = sb1u + k
161 pshufb %xmm3, %xmm0 # 0 = sb1t
162 movdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[]
163 pxor %xmm4, %xmm0 # 0 = A
164 pshufb %xmm1, %xmm0
165 ret
166.size _vpaes_encrypt_core,.-_vpaes_encrypt_core
167
168##
169## Decryption core
170##
171## Same API as encryption core.
172##
173.type _vpaes_decrypt_core,\@abi-omnipotent
174.align 16
175_vpaes_decrypt_core:
176 _CET_ENDBR
177 mov %rdx, %r9 # load key
178 mov 240(%rdx),%eax
179 movdqa %xmm9, %xmm1
180 movdqa .Lk_dipt(%rip), %xmm2 # iptlo
181 pandn %xmm0, %xmm1
182 mov %rax, %r11
183 psrld \$4, %xmm1
184 movdqu (%r9), %xmm5 # round0 key
185 shl \$4, %r11
186 pand %xmm9, %xmm0
187 pshufb %xmm0, %xmm2
188 movdqa .Lk_dipt+16(%rip), %xmm0 # ipthi
189 xor \$0x30, %r11
190 lea .Lk_dsbd(%rip),%r10
191 pshufb %xmm1, %xmm0
192 and \$0x30, %r11
193 pxor %xmm5, %xmm2
194 movdqa .Lk_mc_forward+48(%rip), %xmm5
195 pxor %xmm2, %xmm0
196 add \$16, %r9
197 add %r10, %r11
198 jmp .Ldec_entry
199
200.align 16
201.Ldec_loop:
202##
203## Inverse mix columns
204##
205 movdqa -0x20(%r10),%xmm4 # 4 : sb9u
206 pshufb %xmm2, %xmm4 # 4 = sb9u
207 pxor %xmm0, %xmm4
208 movdqa -0x10(%r10),%xmm0 # 0 : sb9t
209 pshufb %xmm3, %xmm0 # 0 = sb9t
210 pxor %xmm4, %xmm0 # 0 = ch
211 add \$16, %r9 # next round key
212
213 pshufb %xmm5, %xmm0 # MC ch
214 movdqa 0x00(%r10),%xmm4 # 4 : sbdu
215 pshufb %xmm2, %xmm4 # 4 = sbdu
216 pxor %xmm0, %xmm4 # 4 = ch
217 movdqa 0x10(%r10),%xmm0 # 0 : sbdt
218 pshufb %xmm3, %xmm0 # 0 = sbdt
219 pxor %xmm4, %xmm0 # 0 = ch
220 sub \$1,%rax # nr--
221
222 pshufb %xmm5, %xmm0 # MC ch
223 movdqa 0x20(%r10),%xmm4 # 4 : sbbu
224 pshufb %xmm2, %xmm4 # 4 = sbbu
225 pxor %xmm0, %xmm4 # 4 = ch
226 movdqa 0x30(%r10),%xmm0 # 0 : sbbt
227 pshufb %xmm3, %xmm0 # 0 = sbbt
228 pxor %xmm4, %xmm0 # 0 = ch
229
230 pshufb %xmm5, %xmm0 # MC ch
231 movdqa 0x40(%r10),%xmm4 # 4 : sbeu
232 pshufb %xmm2, %xmm4 # 4 = sbeu
233 pxor %xmm0, %xmm4 # 4 = ch
234 movdqa 0x50(%r10),%xmm0 # 0 : sbet
235 pshufb %xmm3, %xmm0 # 0 = sbet
236 pxor %xmm4, %xmm0 # 0 = ch
237
238 palignr \$12, %xmm5, %xmm5
239
240.Ldec_entry:
241 # top of round
242 movdqa %xmm9, %xmm1 # 1 : i
243 pandn %xmm0, %xmm1 # 1 = i<<4
244 psrld \$4, %xmm1 # 1 = i
245 pand %xmm9, %xmm0 # 0 = k
246 movdqa %xmm11, %xmm2 # 2 : a/k
247 pshufb %xmm0, %xmm2 # 2 = a/k
248 pxor %xmm1, %xmm0 # 0 = j
249 movdqa %xmm10, %xmm3 # 3 : 1/i
250 pshufb %xmm1, %xmm3 # 3 = 1/i
251 pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
252 movdqa %xmm10, %xmm4 # 4 : 1/j
253 pshufb %xmm0, %xmm4 # 4 = 1/j
254 pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k
255 movdqa %xmm10, %xmm2 # 2 : 1/iak
256 pshufb %xmm3, %xmm2 # 2 = 1/iak
257 pxor %xmm0, %xmm2 # 2 = io
258 movdqa %xmm10, %xmm3 # 3 : 1/jak
259 pshufb %xmm4, %xmm3 # 3 = 1/jak
260 pxor %xmm1, %xmm3 # 3 = jo
261 movdqu (%r9), %xmm0
262 jnz .Ldec_loop
263
264 # middle of last round
265 movdqa 0x60(%r10), %xmm4 # 3 : sbou
266 pshufb %xmm2, %xmm4 # 4 = sbou
267 pxor %xmm0, %xmm4 # 4 = sb1u + k
268 movdqa 0x70(%r10), %xmm0 # 0 : sbot
269 movdqa -0x160(%r11), %xmm2 # .Lk_sr-.Lk_dsbd=-0x160
270 pshufb %xmm3, %xmm0 # 0 = sb1t
271 pxor %xmm4, %xmm0 # 0 = A
272 pshufb %xmm2, %xmm0
273 ret
274.size _vpaes_decrypt_core,.-_vpaes_decrypt_core
275
276########################################################
277## ##
278## AES key schedule ##
279## ##
280########################################################
281.type _vpaes_schedule_core,\@abi-omnipotent
282.align 16
283_vpaes_schedule_core:
284 _CET_ENDBR
285 # rdi = key
286 # rsi = size in bits
287 # rdx = buffer
288 # rcx = direction. 0=encrypt, 1=decrypt
289
290 call _vpaes_preheat # load the tables
291 movdqa .Lk_rcon(%rip), %xmm8 # load rcon
292 movdqu (%rdi), %xmm0 # load key (unaligned)
293
294 # input transform
295 movdqa %xmm0, %xmm3
296 lea .Lk_ipt(%rip), %r11
297 call _vpaes_schedule_transform
298 movdqa %xmm0, %xmm7
299
300 lea .Lk_sr(%rip),%r10
301 test %rcx, %rcx
302 jnz .Lschedule_am_decrypting
303
304 # encrypting, output zeroth round key after transform
305 movdqu %xmm0, (%rdx)
306 jmp .Lschedule_go
307
308.Lschedule_am_decrypting:
309 # decrypting, output zeroth round key after shiftrows
310 movdqa (%r8,%r10),%xmm1
311 pshufb %xmm1, %xmm3
312 movdqu %xmm3, (%rdx)
313 xor \$0x30, %r8
314
315.Lschedule_go:
316 cmp \$192, %esi
317 ja .Lschedule_256
318 je .Lschedule_192
319 # 128: fall though
320
321##
322## .schedule_128
323##
324## 128-bit specific part of key schedule.
325##
326## This schedule is really simple, because all its parts
327## are accomplished by the subroutines.
328##
329.Lschedule_128:
330 mov \$10, %esi
331
332.Loop_schedule_128:
333 call _vpaes_schedule_round
334 dec %rsi
335 jz .Lschedule_mangle_last
336 call _vpaes_schedule_mangle # write output
337 jmp .Loop_schedule_128
338
339##
340## .aes_schedule_192
341##
342## 192-bit specific part of key schedule.
343##
344## The main body of this schedule is the same as the 128-bit
345## schedule, but with more smearing. The long, high side is
346## stored in %xmm7 as before, and the short, low side is in
347## the high bits of %xmm6.
348##
349## This schedule is somewhat nastier, however, because each
350## round produces 192 bits of key material, or 1.5 round keys.
351## Therefore, on each cycle we do 2 rounds and produce 3 round
352## keys.
353##
354.align 16
355.Lschedule_192:
356 movdqu 8(%rdi),%xmm0 # load key part 2 (very unaligned)
357 call _vpaes_schedule_transform # input transform
358 movdqa %xmm0, %xmm6 # save short part
359 pxor %xmm4, %xmm4 # clear 4
360 movhlps %xmm4, %xmm6 # clobber low side with zeros
361 mov \$4, %esi
362
363.Loop_schedule_192:
364 call _vpaes_schedule_round
365 palignr \$8,%xmm6,%xmm0
366 call _vpaes_schedule_mangle # save key n
367 call _vpaes_schedule_192_smear
368 call _vpaes_schedule_mangle # save key n+1
369 call _vpaes_schedule_round
370 dec %rsi
371 jz .Lschedule_mangle_last
372 call _vpaes_schedule_mangle # save key n+2
373 call _vpaes_schedule_192_smear
374 jmp .Loop_schedule_192
375
376##
377## .aes_schedule_256
378##
379## 256-bit specific part of key schedule.
380##
381## The structure here is very similar to the 128-bit
382## schedule, but with an additional "low side" in
383## %xmm6. The low side's rounds are the same as the
384## high side's, except no rcon and no rotation.
385##
386.align 16
387.Lschedule_256:
388 movdqu 16(%rdi),%xmm0 # load key part 2 (unaligned)
389 call _vpaes_schedule_transform # input transform
390 mov \$7, %esi
391
392.Loop_schedule_256:
393 call _vpaes_schedule_mangle # output low result
394 movdqa %xmm0, %xmm6 # save cur_lo in xmm6
395
396 # high round
397 call _vpaes_schedule_round
398 dec %rsi
399 jz .Lschedule_mangle_last
400 call _vpaes_schedule_mangle
401
402 # low round. swap xmm7 and xmm6
403 pshufd \$0xFF, %xmm0, %xmm0
404 movdqa %xmm7, %xmm5
405 movdqa %xmm6, %xmm7
406 call _vpaes_schedule_low_round
407 movdqa %xmm5, %xmm7
408
409 jmp .Loop_schedule_256
410
411
412##
413## .aes_schedule_mangle_last
414##
415## Mangler for last round of key schedule
416## Mangles %xmm0
417## when encrypting, outputs out(%xmm0) ^ 63
418## when decrypting, outputs unskew(%xmm0)
419##
420## Always called right before return... jumps to cleanup and exits
421##
422.align 16
423.Lschedule_mangle_last:
424 # schedule last round key from xmm0
425 lea .Lk_deskew(%rip),%r11 # prepare to deskew
426 test %rcx, %rcx
427 jnz .Lschedule_mangle_last_dec
428
429 # encrypting
430 movdqa (%r8,%r10),%xmm1
431 pshufb %xmm1, %xmm0 # output permute
432 lea .Lk_opt(%rip), %r11 # prepare to output transform
433 add \$32, %rdx
434
435.Lschedule_mangle_last_dec:
436 add \$-16, %rdx
437 pxor .Lk_s63(%rip), %xmm0
438 call _vpaes_schedule_transform # output transform
439 movdqu %xmm0, (%rdx) # save last key
440
441 # cleanup
442 pxor %xmm0, %xmm0
443 pxor %xmm1, %xmm1
444 pxor %xmm2, %xmm2
445 pxor %xmm3, %xmm3
446 pxor %xmm4, %xmm4
447 pxor %xmm5, %xmm5
448 pxor %xmm6, %xmm6
449 pxor %xmm7, %xmm7
450 ret
451.size _vpaes_schedule_core,.-_vpaes_schedule_core
452
453##
454## .aes_schedule_192_smear
455##
456## Smear the short, low side in the 192-bit key schedule.
457##
458## Inputs:
459## %xmm7: high side, b a x y
460## %xmm6: low side, d c 0 0
461## %xmm13: 0
462##
463## Outputs:
464## %xmm6: b+c+d b+c 0 0
465## %xmm0: b+c+d b+c b a
466##
467.type _vpaes_schedule_192_smear,\@abi-omnipotent
468.align 16
469_vpaes_schedule_192_smear:
470 _CET_ENDBR
471 pshufd \$0x80, %xmm6, %xmm0 # d c 0 0 -> c 0 0 0
472 pxor %xmm0, %xmm6 # -> c+d c 0 0
473 pshufd \$0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a
474 pxor %xmm0, %xmm6 # -> b+c+d b+c b a
475 movdqa %xmm6, %xmm0
476 pxor %xmm1, %xmm1
477 movhlps %xmm1, %xmm6 # clobber low side with zeros
478 ret
479.size _vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear
480
481##
482## .aes_schedule_round
483##
484## Runs one main round of the key schedule on %xmm0, %xmm7
485##
486## Specifically, runs subbytes on the high dword of %xmm0
487## then rotates it by one byte and xors into the low dword of
488## %xmm7.
489##
490## Adds rcon from low byte of %xmm8, then rotates %xmm8 for
491## next rcon.
492##
493## Smears the dwords of %xmm7 by xoring the low into the
494## second low, result into third, result into highest.
495##
496## Returns results in %xmm7 = %xmm0.
497## Clobbers %xmm1-%xmm4, %r11.
498##
499.type _vpaes_schedule_round,\@abi-omnipotent
500.align 16
501_vpaes_schedule_round:
502 _CET_ENDBR
503 # extract rcon from xmm8
504 pxor %xmm1, %xmm1
505 palignr \$15, %xmm8, %xmm1
506 palignr \$15, %xmm8, %xmm8
507 pxor %xmm1, %xmm7
508
509 # rotate
510 pshufd \$0xFF, %xmm0, %xmm0
511 palignr \$1, %xmm0, %xmm0
512
513 # fall through...
514
515 # low round: same as high round, but no rotation and no rcon.
516_vpaes_schedule_low_round:
517 # smear xmm7
518 movdqa %xmm7, %xmm1
519 pslldq \$4, %xmm7
520 pxor %xmm1, %xmm7
521 movdqa %xmm7, %xmm1
522 pslldq \$8, %xmm7
523 pxor %xmm1, %xmm7
524 pxor .Lk_s63(%rip), %xmm7
525
526 # subbytes
527 movdqa %xmm9, %xmm1
528 pandn %xmm0, %xmm1
529 psrld \$4, %xmm1 # 1 = i
530 pand %xmm9, %xmm0 # 0 = k
531 movdqa %xmm11, %xmm2 # 2 : a/k
532 pshufb %xmm0, %xmm2 # 2 = a/k
533 pxor %xmm1, %xmm0 # 0 = j
534 movdqa %xmm10, %xmm3 # 3 : 1/i
535 pshufb %xmm1, %xmm3 # 3 = 1/i
536 pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
537 movdqa %xmm10, %xmm4 # 4 : 1/j
538 pshufb %xmm0, %xmm4 # 4 = 1/j
539 pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k
540 movdqa %xmm10, %xmm2 # 2 : 1/iak
541 pshufb %xmm3, %xmm2 # 2 = 1/iak
542 pxor %xmm0, %xmm2 # 2 = io
543 movdqa %xmm10, %xmm3 # 3 : 1/jak
544 pshufb %xmm4, %xmm3 # 3 = 1/jak
545 pxor %xmm1, %xmm3 # 3 = jo
546 movdqa %xmm13, %xmm4 # 4 : sbou
547 pshufb %xmm2, %xmm4 # 4 = sbou
548 movdqa %xmm12, %xmm0 # 0 : sbot
549 pshufb %xmm3, %xmm0 # 0 = sb1t
550 pxor %xmm4, %xmm0 # 0 = sbox output
551
552 # add in smeared stuff
553 pxor %xmm7, %xmm0
554 movdqa %xmm0, %xmm7
555 ret
556.size _vpaes_schedule_round,.-_vpaes_schedule_round
557
558##
559## .aes_schedule_transform
560##
561## Linear-transform %xmm0 according to tables at (%r11)
562##
563## Requires that %xmm9 = 0x0F0F... as in preheat
564## Output in %xmm0
565## Clobbers %xmm1, %xmm2
566##
567.type _vpaes_schedule_transform,\@abi-omnipotent
568.align 16
569_vpaes_schedule_transform:
570 _CET_ENDBR
571 movdqa %xmm9, %xmm1
572 pandn %xmm0, %xmm1
573 psrld \$4, %xmm1
574 pand %xmm9, %xmm0
575 movdqa (%r11), %xmm2 # lo
576 pshufb %xmm0, %xmm2
577 movdqa 16(%r11), %xmm0 # hi
578 pshufb %xmm1, %xmm0
579 pxor %xmm2, %xmm0
580 ret
581.size _vpaes_schedule_transform,.-_vpaes_schedule_transform
582
583##
584## .aes_schedule_mangle
585##
586## Mangle xmm0 from (basis-transformed) standard version
587## to our version.
588##
589## On encrypt,
590## xor with 0x63
591## multiply by circulant 0,1,1,1
592## apply shiftrows transform
593##
594## On decrypt,
595## xor with 0x63
596## multiply by "inverse mixcolumns" circulant E,B,D,9
597## deskew
598## apply shiftrows transform
599##
600##
601## Writes out to (%rdx), and increments or decrements it
602## Keeps track of round number mod 4 in %r8
603## Preserves xmm0
604## Clobbers xmm1-xmm5
605##
606.type _vpaes_schedule_mangle,\@abi-omnipotent
607.align 16
608_vpaes_schedule_mangle:
609 _CET_ENDBR
610 movdqa %xmm0, %xmm4 # save xmm0 for later
611 movdqa .Lk_mc_forward(%rip),%xmm5
612 test %rcx, %rcx
613 jnz .Lschedule_mangle_dec
614
615 # encrypting
616 add \$16, %rdx
617 pxor .Lk_s63(%rip),%xmm4
618 pshufb %xmm5, %xmm4
619 movdqa %xmm4, %xmm3
620 pshufb %xmm5, %xmm4
621 pxor %xmm4, %xmm3
622 pshufb %xmm5, %xmm4
623 pxor %xmm4, %xmm3
624
625 jmp .Lschedule_mangle_both
626.align 16
627.Lschedule_mangle_dec:
628 # inverse mix columns
629 lea .Lk_dksd(%rip),%r11
630 movdqa %xmm9, %xmm1
631 pandn %xmm4, %xmm1
632 psrld \$4, %xmm1 # 1 = hi
633 pand %xmm9, %xmm4 # 4 = lo
634
635 movdqa 0x00(%r11), %xmm2
636 pshufb %xmm4, %xmm2
637 movdqa 0x10(%r11), %xmm3
638 pshufb %xmm1, %xmm3
639 pxor %xmm2, %xmm3
640 pshufb %xmm5, %xmm3
641
642 movdqa 0x20(%r11), %xmm2
643 pshufb %xmm4, %xmm2
644 pxor %xmm3, %xmm2
645 movdqa 0x30(%r11), %xmm3
646 pshufb %xmm1, %xmm3
647 pxor %xmm2, %xmm3
648 pshufb %xmm5, %xmm3
649
650 movdqa 0x40(%r11), %xmm2
651 pshufb %xmm4, %xmm2
652 pxor %xmm3, %xmm2
653 movdqa 0x50(%r11), %xmm3
654 pshufb %xmm1, %xmm3
655 pxor %xmm2, %xmm3
656 pshufb %xmm5, %xmm3
657
658 movdqa 0x60(%r11), %xmm2
659 pshufb %xmm4, %xmm2
660 pxor %xmm3, %xmm2
661 movdqa 0x70(%r11), %xmm3
662 pshufb %xmm1, %xmm3
663 pxor %xmm2, %xmm3
664
665 add \$-16, %rdx
666
667.Lschedule_mangle_both:
668 movdqa (%r8,%r10),%xmm1
669 pshufb %xmm1,%xmm3
670 add \$-16, %r8
671 and \$0x30, %r8
672 movdqu %xmm3, (%rdx)
673 ret
674.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle
675
676#
677# Interface to OpenSSL
678#
679.globl ${PREFIX}_set_encrypt_key
680.type ${PREFIX}_set_encrypt_key,\@function,3
681.align 16
682${PREFIX}_set_encrypt_key:
683 _CET_ENDBR
684___
685$code.=<<___ if ($win64);
686 lea -0xb8(%rsp),%rsp
687 movaps %xmm6,0x10(%rsp)
688 movaps %xmm7,0x20(%rsp)
689 movaps %xmm8,0x30(%rsp)
690 movaps %xmm9,0x40(%rsp)
691 movaps %xmm10,0x50(%rsp)
692 movaps %xmm11,0x60(%rsp)
693 movaps %xmm12,0x70(%rsp)
694 movaps %xmm13,0x80(%rsp)
695 movaps %xmm14,0x90(%rsp)
696 movaps %xmm15,0xa0(%rsp)
697.Lenc_key_body:
698___
699$code.=<<___;
700 mov %esi,%eax
701 shr \$5,%eax
702 add \$5,%eax
703 mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5;
704
705 mov \$0,%ecx
706 mov \$0x30,%r8d
707 call _vpaes_schedule_core
708___
709$code.=<<___ if ($win64);
710 movaps 0x10(%rsp),%xmm6
711 movaps 0x20(%rsp),%xmm7
712 movaps 0x30(%rsp),%xmm8
713 movaps 0x40(%rsp),%xmm9
714 movaps 0x50(%rsp),%xmm10
715 movaps 0x60(%rsp),%xmm11
716 movaps 0x70(%rsp),%xmm12
717 movaps 0x80(%rsp),%xmm13
718 movaps 0x90(%rsp),%xmm14
719 movaps 0xa0(%rsp),%xmm15
720 lea 0xb8(%rsp),%rsp
721.Lenc_key_epilogue:
722___
723$code.=<<___;
724 xor %eax,%eax
725 ret
726.size ${PREFIX}_set_encrypt_key,.-${PREFIX}_set_encrypt_key
727
728.globl ${PREFIX}_set_decrypt_key
729.type ${PREFIX}_set_decrypt_key,\@function,3
730.align 16
731${PREFIX}_set_decrypt_key:
732 _CET_ENDBR
733___
734$code.=<<___ if ($win64);
735 lea -0xb8(%rsp),%rsp
736 movaps %xmm6,0x10(%rsp)
737 movaps %xmm7,0x20(%rsp)
738 movaps %xmm8,0x30(%rsp)
739 movaps %xmm9,0x40(%rsp)
740 movaps %xmm10,0x50(%rsp)
741 movaps %xmm11,0x60(%rsp)
742 movaps %xmm12,0x70(%rsp)
743 movaps %xmm13,0x80(%rsp)
744 movaps %xmm14,0x90(%rsp)
745 movaps %xmm15,0xa0(%rsp)
746.Ldec_key_body:
747___
748$code.=<<___;
749 mov %esi,%eax
750 shr \$5,%eax
751 add \$5,%eax
752 mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5;
753 shl \$4,%eax
754 lea 16(%rdx,%rax),%rdx
755
756 mov \$1,%ecx
757 mov %esi,%r8d
758 shr \$1,%r8d
759 and \$32,%r8d
760 xor \$32,%r8d # nbits==192?0:32
761 call _vpaes_schedule_core
762___
763$code.=<<___ if ($win64);
764 movaps 0x10(%rsp),%xmm6
765 movaps 0x20(%rsp),%xmm7
766 movaps 0x30(%rsp),%xmm8
767 movaps 0x40(%rsp),%xmm9
768 movaps 0x50(%rsp),%xmm10
769 movaps 0x60(%rsp),%xmm11
770 movaps 0x70(%rsp),%xmm12
771 movaps 0x80(%rsp),%xmm13
772 movaps 0x90(%rsp),%xmm14
773 movaps 0xa0(%rsp),%xmm15
774 lea 0xb8(%rsp),%rsp
775.Ldec_key_epilogue:
776___
777$code.=<<___;
778 xor %eax,%eax
779 ret
780.size ${PREFIX}_set_decrypt_key,.-${PREFIX}_set_decrypt_key
781
782.globl ${PREFIX}_encrypt
783.type ${PREFIX}_encrypt,\@function,3
784.align 16
785${PREFIX}_encrypt:
786 _CET_ENDBR
787___
788$code.=<<___ if ($win64);
789 lea -0xb8(%rsp),%rsp
790 movaps %xmm6,0x10(%rsp)
791 movaps %xmm7,0x20(%rsp)
792 movaps %xmm8,0x30(%rsp)
793 movaps %xmm9,0x40(%rsp)
794 movaps %xmm10,0x50(%rsp)
795 movaps %xmm11,0x60(%rsp)
796 movaps %xmm12,0x70(%rsp)
797 movaps %xmm13,0x80(%rsp)
798 movaps %xmm14,0x90(%rsp)
799 movaps %xmm15,0xa0(%rsp)
800.Lenc_body:
801___
802$code.=<<___;
803 movdqu (%rdi),%xmm0
804 call _vpaes_preheat
805 call _vpaes_encrypt_core
806 movdqu %xmm0,(%rsi)
807___
808$code.=<<___ if ($win64);
809 movaps 0x10(%rsp),%xmm6
810 movaps 0x20(%rsp),%xmm7
811 movaps 0x30(%rsp),%xmm8
812 movaps 0x40(%rsp),%xmm9
813 movaps 0x50(%rsp),%xmm10
814 movaps 0x60(%rsp),%xmm11
815 movaps 0x70(%rsp),%xmm12
816 movaps 0x80(%rsp),%xmm13
817 movaps 0x90(%rsp),%xmm14
818 movaps 0xa0(%rsp),%xmm15
819 lea 0xb8(%rsp),%rsp
820.Lenc_epilogue:
821___
822$code.=<<___;
823 ret
824.size ${PREFIX}_encrypt,.-${PREFIX}_encrypt
825
826.globl ${PREFIX}_decrypt
827.type ${PREFIX}_decrypt,\@function,3
828.align 16
829${PREFIX}_decrypt:
830 _CET_ENDBR
831___
832$code.=<<___ if ($win64);
833 lea -0xb8(%rsp),%rsp
834 movaps %xmm6,0x10(%rsp)
835 movaps %xmm7,0x20(%rsp)
836 movaps %xmm8,0x30(%rsp)
837 movaps %xmm9,0x40(%rsp)
838 movaps %xmm10,0x50(%rsp)
839 movaps %xmm11,0x60(%rsp)
840 movaps %xmm12,0x70(%rsp)
841 movaps %xmm13,0x80(%rsp)
842 movaps %xmm14,0x90(%rsp)
843 movaps %xmm15,0xa0(%rsp)
844.Ldec_body:
845___
846$code.=<<___;
847 movdqu (%rdi),%xmm0
848 call _vpaes_preheat
849 call _vpaes_decrypt_core
850 movdqu %xmm0,(%rsi)
851___
852$code.=<<___ if ($win64);
853 movaps 0x10(%rsp),%xmm6
854 movaps 0x20(%rsp),%xmm7
855 movaps 0x30(%rsp),%xmm8
856 movaps 0x40(%rsp),%xmm9
857 movaps 0x50(%rsp),%xmm10
858 movaps 0x60(%rsp),%xmm11
859 movaps 0x70(%rsp),%xmm12
860 movaps 0x80(%rsp),%xmm13
861 movaps 0x90(%rsp),%xmm14
862 movaps 0xa0(%rsp),%xmm15
863 lea 0xb8(%rsp),%rsp
864.Ldec_epilogue:
865___
866$code.=<<___;
867 ret
868.size ${PREFIX}_decrypt,.-${PREFIX}_decrypt
869___
870{
871my ($inp,$out,$len,$key,$ivp,$enc)=("%rdi","%rsi","%rdx","%rcx","%r8","%r9");
872# void AES_cbc_encrypt (const void char *inp, unsigned char *out,
873# size_t length, const AES_KEY *key,
874# unsigned char *ivp,const int enc);
875$code.=<<___;
876.globl ${PREFIX}_cbc_encrypt
877.type ${PREFIX}_cbc_encrypt,\@function,6
878.align 16
879${PREFIX}_cbc_encrypt:
880 _CET_ENDBR
881 xchg $key,$len
882___
883($len,$key)=($key,$len);
884$code.=<<___;
885 sub \$16,$len
886 jc .Lcbc_abort
887___
888$code.=<<___ if ($win64);
889 lea -0xb8(%rsp),%rsp
890 movaps %xmm6,0x10(%rsp)
891 movaps %xmm7,0x20(%rsp)
892 movaps %xmm8,0x30(%rsp)
893 movaps %xmm9,0x40(%rsp)
894 movaps %xmm10,0x50(%rsp)
895 movaps %xmm11,0x60(%rsp)
896 movaps %xmm12,0x70(%rsp)
897 movaps %xmm13,0x80(%rsp)
898 movaps %xmm14,0x90(%rsp)
899 movaps %xmm15,0xa0(%rsp)
900.Lcbc_body:
901___
902$code.=<<___;
903 movdqu ($ivp),%xmm6 # load IV
904 sub $inp,$out
905 call _vpaes_preheat
906 cmp \$0,${enc}d
907 je .Lcbc_dec_loop
908 jmp .Lcbc_enc_loop
909.align 16
910.Lcbc_enc_loop:
911 movdqu ($inp),%xmm0
912 pxor %xmm6,%xmm0
913 call _vpaes_encrypt_core
914 movdqa %xmm0,%xmm6
915 movdqu %xmm0,($out,$inp)
916 lea 16($inp),$inp
917 sub \$16,$len
918 jnc .Lcbc_enc_loop
919 jmp .Lcbc_done
920.align 16
921.Lcbc_dec_loop:
922 movdqu ($inp),%xmm0
923 movdqa %xmm0,%xmm7
924 call _vpaes_decrypt_core
925 pxor %xmm6,%xmm0
926 movdqa %xmm7,%xmm6
927 movdqu %xmm0,($out,$inp)
928 lea 16($inp),$inp
929 sub \$16,$len
930 jnc .Lcbc_dec_loop
931.Lcbc_done:
932 movdqu %xmm6,($ivp) # save IV
933___
934$code.=<<___ if ($win64);
935 movaps 0x10(%rsp),%xmm6
936 movaps 0x20(%rsp),%xmm7
937 movaps 0x30(%rsp),%xmm8
938 movaps 0x40(%rsp),%xmm9
939 movaps 0x50(%rsp),%xmm10
940 movaps 0x60(%rsp),%xmm11
941 movaps 0x70(%rsp),%xmm12
942 movaps 0x80(%rsp),%xmm13
943 movaps 0x90(%rsp),%xmm14
944 movaps 0xa0(%rsp),%xmm15
945 lea 0xb8(%rsp),%rsp
946.Lcbc_epilogue:
947___
948$code.=<<___;
949.Lcbc_abort:
950 ret
951.size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
952___
953}
954$code.=<<___;
955##
956## _aes_preheat
957##
958## Fills register %r10 -> .aes_consts (so you can -fPIC)
959## and %xmm9-%xmm15 as specified below.
960##
961.type _vpaes_preheat,\@abi-omnipotent
962.align 16
963_vpaes_preheat:
964 _CET_ENDBR
965 lea .Lk_s0F(%rip), %r10
966 movdqa -0x20(%r10), %xmm10 # .Lk_inv
967 movdqa -0x10(%r10), %xmm11 # .Lk_inv+16
968 movdqa 0x00(%r10), %xmm9 # .Lk_s0F
969 movdqa 0x30(%r10), %xmm13 # .Lk_sb1
970 movdqa 0x40(%r10), %xmm12 # .Lk_sb1+16
971 movdqa 0x50(%r10), %xmm15 # .Lk_sb2
972 movdqa 0x60(%r10), %xmm14 # .Lk_sb2+16
973 ret
974.size _vpaes_preheat,.-_vpaes_preheat
975########################################################
976## ##
977## Constants ##
978## ##
979########################################################
980.section .rodata
981.type _vpaes_consts,\@object
982.align 64
983_vpaes_consts:
984.Lk_inv: # inv, inva
985 .quad 0x0E05060F0D080180, 0x040703090A0B0C02
986 .quad 0x01040A060F0B0780, 0x030D0E0C02050809
987
988.Lk_s0F: # s0F
989 .quad 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F
990
991.Lk_ipt: # input transform (lo, hi)
992 .quad 0xC2B2E8985A2A7000, 0xCABAE09052227808
993 .quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81
994
995.Lk_sb1: # sb1u, sb1t
996 .quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544
997 .quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF
998.Lk_sb2: # sb2u, sb2t
999 .quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD
1000 .quad 0x69EB88400AE12900, 0xC2A163C8AB82234A
1001.Lk_sbo: # sbou, sbot
1002 .quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878
1003 .quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA
1004
1005.Lk_mc_forward: # mc_forward
1006 .quad 0x0407060500030201, 0x0C0F0E0D080B0A09
1007 .quad 0x080B0A0904070605, 0x000302010C0F0E0D
1008 .quad 0x0C0F0E0D080B0A09, 0x0407060500030201
1009 .quad 0x000302010C0F0E0D, 0x080B0A0904070605
1010
1011.Lk_mc_backward:# mc_backward
1012 .quad 0x0605040702010003, 0x0E0D0C0F0A09080B
1013 .quad 0x020100030E0D0C0F, 0x0A09080B06050407
1014 .quad 0x0E0D0C0F0A09080B, 0x0605040702010003
1015 .quad 0x0A09080B06050407, 0x020100030E0D0C0F
1016
1017.Lk_sr: # sr
1018 .quad 0x0706050403020100, 0x0F0E0D0C0B0A0908
1019 .quad 0x030E09040F0A0500, 0x0B06010C07020D08
1020 .quad 0x0F060D040B020900, 0x070E050C030A0108
1021 .quad 0x0B0E0104070A0D00, 0x0306090C0F020508
1022
1023.Lk_rcon: # rcon
1024 .quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81
1025
1026.Lk_s63: # s63: all equal to 0x63 transformed
1027 .quad 0x5B5B5B5B5B5B5B5B, 0x5B5B5B5B5B5B5B5B
1028
1029.Lk_opt: # output transform
1030 .quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808
1031 .quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0
1032
1033.Lk_deskew: # deskew tables: inverts the sbox's "skew"
1034 .quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A
1035 .quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77
1036
1037##
1038## Decryption stuff
1039## Key schedule constants
1040##
1041.Lk_dksd: # decryption key schedule: invskew x*D
1042 .quad 0xFEB91A5DA3E44700, 0x0740E3A45A1DBEF9
1043 .quad 0x41C277F4B5368300, 0x5FDC69EAAB289D1E
1044.Lk_dksb: # decryption key schedule: invskew x*B
1045 .quad 0x9A4FCA1F8550D500, 0x03D653861CC94C99
1046 .quad 0x115BEDA7B6FC4A00, 0xD993256F7E3482C8
1047.Lk_dkse: # decryption key schedule: invskew x*E + 0x63
1048 .quad 0xD5031CCA1FC9D600, 0x53859A4C994F5086
1049 .quad 0xA23196054FDC7BE8, 0xCD5EF96A20B31487
1050.Lk_dks9: # decryption key schedule: invskew x*9
1051 .quad 0xB6116FC87ED9A700, 0x4AED933482255BFC
1052 .quad 0x4576516227143300, 0x8BB89FACE9DAFDCE
1053
1054##
1055## Decryption stuff
1056## Round function constants
1057##
1058.Lk_dipt: # decryption input transform
1059 .quad 0x0F505B040B545F00, 0x154A411E114E451A
1060 .quad 0x86E383E660056500, 0x12771772F491F194
1061
1062.Lk_dsb9: # decryption sbox output *9*u, *9*t
1063 .quad 0x851C03539A86D600, 0xCAD51F504F994CC9
1064 .quad 0xC03B1789ECD74900, 0x725E2C9EB2FBA565
1065.Lk_dsbd: # decryption sbox output *D*u, *D*t
1066 .quad 0x7D57CCDFE6B1A200, 0xF56E9B13882A4439
1067 .quad 0x3CE2FAF724C6CB00, 0x2931180D15DEEFD3
1068.Lk_dsbb: # decryption sbox output *B*u, *B*t
1069 .quad 0xD022649296B44200, 0x602646F6B0F2D404
1070 .quad 0xC19498A6CD596700, 0xF3FF0C3E3255AA6B
1071.Lk_dsbe: # decryption sbox output *E*u, *E*t
1072 .quad 0x46F2929626D4D000, 0x2242600464B4F6B0
1073 .quad 0x0C55A6CDFFAAC100, 0x9467F36B98593E32
1074.Lk_dsbo: # decryption sbox final output
1075 .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D
1076 .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C
1077.align 64
1078.size _vpaes_consts,.-_vpaes_consts
1079.text
1080___
1081
1082if ($win64) {
1083# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
1084# CONTEXT *context,DISPATCHER_CONTEXT *disp)
1085$rec="%rcx";
1086$frame="%rdx";
1087$context="%r8";
1088$disp="%r9";
1089
1090$code.=<<___;
1091.extern __imp_RtlVirtualUnwind
1092.type se_handler,\@abi-omnipotent
1093.align 16
1094se_handler:
1095 _CET_ENDBR
1096 push %rsi
1097 push %rdi
1098 push %rbx
1099 push %rbp
1100 push %r12
1101 push %r13
1102 push %r14
1103 push %r15
1104 pushfq
1105 sub \$64,%rsp
1106
1107 mov 120($context),%rax # pull context->Rax
1108 mov 248($context),%rbx # pull context->Rip
1109
1110 mov 8($disp),%rsi # disp->ImageBase
1111 mov 56($disp),%r11 # disp->HandlerData
1112
1113 mov 0(%r11),%r10d # HandlerData[0]
1114 lea (%rsi,%r10),%r10 # prologue label
1115 cmp %r10,%rbx # context->Rip<prologue label
1116 jb .Lin_prologue
1117
1118 mov 152($context),%rax # pull context->Rsp
1119
1120 mov 4(%r11),%r10d # HandlerData[1]
1121 lea (%rsi,%r10),%r10 # epilogue label
1122 cmp %r10,%rbx # context->Rip>=epilogue label
1123 jae .Lin_prologue
1124
1125 lea 16(%rax),%rsi # %xmm save area
1126 lea 512($context),%rdi # &context.Xmm6
1127 mov \$20,%ecx # 10*sizeof(%xmm0)/sizeof(%rax)
1128 .long 0xa548f3fc # cld; rep movsq
1129 lea 0xb8(%rax),%rax # adjust stack pointer
1130
1131.Lin_prologue:
1132 mov 8(%rax),%rdi
1133 mov 16(%rax),%rsi
1134 mov %rax,152($context) # restore context->Rsp
1135 mov %rsi,168($context) # restore context->Rsi
1136 mov %rdi,176($context) # restore context->Rdi
1137
1138 mov 40($disp),%rdi # disp->ContextRecord
1139 mov $context,%rsi # context
1140 mov \$`1232/8`,%ecx # sizeof(CONTEXT)
1141 .long 0xa548f3fc # cld; rep movsq
1142
1143 mov $disp,%rsi
1144 xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER
1145 mov 8(%rsi),%rdx # arg2, disp->ImageBase
1146 mov 0(%rsi),%r8 # arg3, disp->ControlPc
1147 mov 16(%rsi),%r9 # arg4, disp->FunctionEntry
1148 mov 40(%rsi),%r10 # disp->ContextRecord
1149 lea 56(%rsi),%r11 # &disp->HandlerData
1150 lea 24(%rsi),%r12 # &disp->EstablisherFrame
1151 mov %r10,32(%rsp) # arg5
1152 mov %r11,40(%rsp) # arg6
1153 mov %r12,48(%rsp) # arg7
1154 mov %rcx,56(%rsp) # arg8, (NULL)
1155 call *__imp_RtlVirtualUnwind(%rip)
1156
1157 mov \$1,%eax # ExceptionContinueSearch
1158 add \$64,%rsp
1159 popfq
1160 pop %r15
1161 pop %r14
1162 pop %r13
1163 pop %r12
1164 pop %rbp
1165 pop %rbx
1166 pop %rdi
1167 pop %rsi
1168 ret
1169.size se_handler,.-se_handler
1170
1171.section .pdata
1172.align 4
1173 .rva .LSEH_begin_${PREFIX}_set_encrypt_key
1174 .rva .LSEH_end_${PREFIX}_set_encrypt_key
1175 .rva .LSEH_info_${PREFIX}_set_encrypt_key
1176
1177 .rva .LSEH_begin_${PREFIX}_set_decrypt_key
1178 .rva .LSEH_end_${PREFIX}_set_decrypt_key
1179 .rva .LSEH_info_${PREFIX}_set_decrypt_key
1180
1181 .rva .LSEH_begin_${PREFIX}_encrypt
1182 .rva .LSEH_end_${PREFIX}_encrypt
1183 .rva .LSEH_info_${PREFIX}_encrypt
1184
1185 .rva .LSEH_begin_${PREFIX}_decrypt
1186 .rva .LSEH_end_${PREFIX}_decrypt
1187 .rva .LSEH_info_${PREFIX}_decrypt
1188
1189 .rva .LSEH_begin_${PREFIX}_cbc_encrypt
1190 .rva .LSEH_end_${PREFIX}_cbc_encrypt
1191 .rva .LSEH_info_${PREFIX}_cbc_encrypt
1192
1193.section .xdata
1194.align 8
1195.LSEH_info_${PREFIX}_set_encrypt_key:
1196 .byte 9,0,0,0
1197 .rva se_handler
1198 .rva .Lenc_key_body,.Lenc_key_epilogue # HandlerData[]
1199.LSEH_info_${PREFIX}_set_decrypt_key:
1200 .byte 9,0,0,0
1201 .rva se_handler
1202 .rva .Ldec_key_body,.Ldec_key_epilogue # HandlerData[]
1203.LSEH_info_${PREFIX}_encrypt:
1204 .byte 9,0,0,0
1205 .rva se_handler
1206 .rva .Lenc_body,.Lenc_epilogue # HandlerData[]
1207.LSEH_info_${PREFIX}_decrypt:
1208 .byte 9,0,0,0
1209 .rva se_handler
1210 .rva .Ldec_body,.Ldec_epilogue # HandlerData[]
1211.LSEH_info_${PREFIX}_cbc_encrypt:
1212 .byte 9,0,0,0
1213 .rva se_handler
1214 .rva .Lcbc_body,.Lcbc_epilogue # HandlerData[]
1215___
1216}
1217
1218$code =~ s/\`([^\`]*)\`/eval($1)/gem;
1219
1220print $code;
1221
1222close STDOUT;
diff --git a/src/lib/libcrypto/arch/aarch64/Makefile.inc b/src/lib/libcrypto/arch/aarch64/Makefile.inc
index d93cb815ef..d1f22d87cd 100644
--- a/src/lib/libcrypto/arch/aarch64/Makefile.inc
+++ b/src/lib/libcrypto/arch/aarch64/Makefile.inc
@@ -1,9 +1,11 @@
1# $OpenBSD: Makefile.inc,v 1.16 2025/03/12 14:13:41 jsing Exp $ 1# $OpenBSD: Makefile.inc,v 1.17 2025/06/28 12:51:08 jsing Exp $
2 2
3# aarch64-specific libcrypto build rules 3# aarch64-specific libcrypto build rules
4 4
5SRCS += crypto_cpu_caps.c 5SRCS += crypto_cpu_caps.c
6 6
7SRCS += sha1_aarch64.c
8SRCS += sha1_aarch64_ce.S
7SRCS += sha256_aarch64.c 9SRCS += sha256_aarch64.c
8SRCS += sha256_aarch64_ce.S 10SRCS += sha256_aarch64_ce.S
9SRCS += sha512_aarch64.c 11SRCS += sha512_aarch64.c
diff --git a/src/lib/libcrypto/arch/aarch64/crypto_arch.h b/src/lib/libcrypto/arch/aarch64/crypto_arch.h
index 35ecba9394..51c8d79e2d 100644
--- a/src/lib/libcrypto/arch/aarch64/crypto_arch.h
+++ b/src/lib/libcrypto/arch/aarch64/crypto_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_arch.h,v 1.4 2025/03/12 14:13:41 jsing Exp $ */ 1/* $OpenBSD: crypto_arch.h,v 1.5 2025/06/28 12:51:08 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -35,6 +35,7 @@ extern uint64_t crypto_cpu_caps_aarch64;
35 35
36#ifndef OPENSSL_NO_ASM 36#ifndef OPENSSL_NO_ASM
37 37
38#define HAVE_SHA1_BLOCK_DATA_ORDER
38#define HAVE_SHA256_BLOCK_DATA_ORDER 39#define HAVE_SHA256_BLOCK_DATA_ORDER
39#define HAVE_SHA512_BLOCK_DATA_ORDER 40#define HAVE_SHA512_BLOCK_DATA_ORDER
40 41
diff --git a/src/lib/libcrypto/arch/aarch64/opensslconf.h b/src/lib/libcrypto/arch/aarch64/opensslconf.h
index 731b06aecc..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/aarch64/opensslconf.h
+++ b/src/lib/libcrypto/arch/aarch64/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#define RC4_CHUNK unsigned long
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#undef BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#define SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#undef THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#undef DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/alpha/opensslconf.h b/src/lib/libcrypto/arch/alpha/opensslconf.h
index 0ec9c25891..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/alpha/opensslconf.h
+++ b/src/lib/libcrypto/arch/alpha/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,137 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#define RC4_CHUNK unsigned long
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#undef BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#define SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#undef THIRTY_TWO_BIT
74#endif
75
76#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
77#define CONFIG_HEADER_BF_LOCL_H
78#define 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#define DES_PTR
88#endif
89
90/* This helps C compiler generate the correct code for multiple functional
91 * units. It reduces register dependencies at the expense of 2 more
92 * registers */
93#ifndef DES_RISC1
94#undef DES_RISC1
95#endif
96
97#ifndef DES_RISC2
98#define DES_RISC2
99#endif
100
101#if defined(DES_RISC1) && defined(DES_RISC2)
102YOU 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 much CPU dependent */
107#ifndef DES_UNROLL
108#undef 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/arch/amd64/Makefile.inc b/src/lib/libcrypto/arch/amd64/Makefile.inc
index b03aad782f..de9666afdb 100644
--- a/src/lib/libcrypto/arch/amd64/Makefile.inc
+++ b/src/lib/libcrypto/arch/amd64/Makefile.inc
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile.inc,v 1.38 2025/04/18 13:19:39 jsing Exp $ 1# $OpenBSD: Makefile.inc,v 1.42 2025/08/14 15:12:53 jsing Exp $
2 2
3# amd64-specific libcrypto build rules 3# amd64-specific libcrypto build rules
4 4
@@ -11,8 +11,9 @@ SRCS += crypto_cpu_caps.c
11CFLAGS+= -DAES_ASM 11CFLAGS+= -DAES_ASM
12SSLASM+= aes aes-x86_64 12SSLASM+= aes aes-x86_64
13SSLASM+= aes aesni-x86_64 13SSLASM+= aes aesni-x86_64
14SRCS += aes_amd64.c
15
14# bn 16# bn
15CFLAGS+= -DOPENSSL_IA32_SSE2
16CFLAGS+= -DRSA_ASM 17CFLAGS+= -DRSA_ASM
17SSLASM+= bn modexp512-x86_64 18SSLASM+= bn modexp512-x86_64
18CFLAGS+= -DOPENSSL_BN_ASM_MONT 19CFLAGS+= -DOPENSSL_BN_ASM_MONT
@@ -25,11 +26,21 @@ SRCS += bn_arch.c
25SRCS += bignum_add.S 26SRCS += bignum_add.S
26SRCS += bignum_cmadd.S 27SRCS += bignum_cmadd.S
27SRCS += bignum_cmul.S 28SRCS += bignum_cmul.S
29SRCS += bignum_modadd.S
30SRCS += bignum_modsub.S
28SRCS += bignum_mul.S 31SRCS += bignum_mul.S
32SRCS += bignum_mul_4_8.S
29SRCS += bignum_mul_4_8_alt.S 33SRCS += bignum_mul_4_8_alt.S
34SRCS += bignum_mul_6_12.S
35SRCS += bignum_mul_6_12_alt.S
36SRCS += bignum_mul_8_16.S
30SRCS += bignum_mul_8_16_alt.S 37SRCS += bignum_mul_8_16_alt.S
31SRCS += bignum_sqr.S 38SRCS += bignum_sqr.S
39SRCS += bignum_sqr_4_8.S
32SRCS += bignum_sqr_4_8_alt.S 40SRCS += bignum_sqr_4_8_alt.S
41SRCS += bignum_sqr_6_12.S
42SRCS += bignum_sqr_6_12_alt.S
43SRCS += bignum_sqr_8_16.S
33SRCS += bignum_sqr_8_16_alt.S 44SRCS += bignum_sqr_8_16_alt.S
34SRCS += bignum_sub.S 45SRCS += bignum_sub.S
35SRCS += word_clz.S 46SRCS += word_clz.S
@@ -37,11 +48,15 @@ SRCS += word_clz.S
37# md5 48# md5
38CFLAGS+= -DMD5_ASM 49CFLAGS+= -DMD5_ASM
39SRCS+= md5_amd64_generic.S 50SRCS+= md5_amd64_generic.S
51
40# modes 52# modes
41CFLAGS+= -DGHASH_ASM 53CFLAGS+= -DGHASH_ASM
42SSLASM+= modes ghash-x86_64 54SSLASM+= modes ghash-x86_64
55SRCS += gcm128_amd64.c
56
43# rc4 57# rc4
44SSLASM+= rc4 rc4-x86_64 58SSLASM+= rc4 rc4-x86_64
59
45# ripemd 60# ripemd
46# sha 61# sha
47SRCS+= sha1_amd64.c 62SRCS+= sha1_amd64.c
diff --git a/src/lib/libcrypto/arch/amd64/crypto_arch.h b/src/lib/libcrypto/arch/amd64/crypto_arch.h
index 951374250d..a8f64cf235 100644
--- a/src/lib/libcrypto/arch/amd64/crypto_arch.h
+++ b/src/lib/libcrypto/arch/amd64/crypto_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_arch.h,v 1.5 2025/02/14 12:01:58 jsing Exp $ */ 1/* $OpenBSD: crypto_arch.h,v 1.14 2025/08/14 15:11:01 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -21,21 +21,29 @@
21#define HEADER_CRYPTO_ARCH_H 21#define HEADER_CRYPTO_ARCH_H
22 22
23#define HAVE_CRYPTO_CPU_CAPS_INIT 23#define HAVE_CRYPTO_CPU_CAPS_INIT
24#define HAVE_CRYPTO_CPU_CAPS_IA32
25 24
26#ifndef __ASSEMBLER__ 25#ifndef __ASSEMBLER__
27extern uint64_t crypto_cpu_caps_amd64; 26extern uint64_t crypto_cpu_caps_amd64;
28#endif 27#endif
29 28
30#define CRYPTO_CPU_CAPS_AMD64_SHA (1ULL << 0) 29#define CRYPTO_CPU_CAPS_AMD64_ADX (1ULL << 0)
30#define CRYPTO_CPU_CAPS_AMD64_AES (1ULL << 1)
31#define CRYPTO_CPU_CAPS_AMD64_CLMUL (1ULL << 2)
32#define CRYPTO_CPU_CAPS_AMD64_SHA (1ULL << 3)
31 33
32#ifndef OPENSSL_NO_ASM 34#ifndef OPENSSL_NO_ASM
33 35
34#define HAVE_AES_CBC_ENCRYPT_INTERNAL
35#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL 36#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL
36#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL 37#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL
37#define HAVE_AES_ENCRYPT_INTERNAL 38#define HAVE_AES_ENCRYPT_INTERNAL
38#define HAVE_AES_DECRYPT_INTERNAL 39#define HAVE_AES_DECRYPT_INTERNAL
40#define HAVE_AES_CBC_ENCRYPT_INTERNAL
41#define HAVE_AES_CCM64_ENCRYPT_INTERNAL
42#define HAVE_AES_CTR32_ENCRYPT_INTERNAL
43#define HAVE_AES_ECB_ENCRYPT_INTERNAL
44#define HAVE_AES_XTS_ENCRYPT_INTERNAL
45
46#define HAVE_GCM128_INIT
39 47
40#define HAVE_RC4_INTERNAL 48#define HAVE_RC4_INTERNAL
41#define HAVE_RC4_SET_KEY_INTERNAL 49#define HAVE_RC4_SET_KEY_INTERNAL
diff --git a/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c b/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
index 63b7b64cda..51a2da4616 100644
--- a/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
+++ b/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_cpu_caps.c,v 1.4 2024/11/16 13:05:35 jsing Exp $ */ 1/* $OpenBSD: crypto_cpu_caps.c,v 1.8 2025/08/14 15:11:01 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -98,10 +98,14 @@ crypto_cpu_caps_init(void)
98 if ((edx & IA32CAP_MASK0_SSE2) != 0) 98 if ((edx & IA32CAP_MASK0_SSE2) != 0)
99 caps |= CPUCAP_MASK_SSE2; 99 caps |= CPUCAP_MASK_SSE2;
100 100
101 if ((ecx & IA32CAP_MASK1_AESNI) != 0) 101 if ((ecx & IA32CAP_MASK1_AESNI) != 0) {
102 caps |= CPUCAP_MASK_AESNI; 102 caps |= CPUCAP_MASK_AESNI;
103 if ((ecx & IA32CAP_MASK1_PCLMUL) != 0) 103 crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_AES;
104 }
105 if ((ecx & IA32CAP_MASK1_PCLMUL) != 0) {
104 caps |= CPUCAP_MASK_PCLMUL; 106 caps |= CPUCAP_MASK_PCLMUL;
107 crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_CLMUL;
108 }
105 if ((ecx & IA32CAP_MASK1_SSSE3) != 0) 109 if ((ecx & IA32CAP_MASK1_SSSE3) != 0)
106 caps |= CPUCAP_MASK_SSSE3; 110 caps |= CPUCAP_MASK_SSSE3;
107 111
@@ -115,6 +119,10 @@ crypto_cpu_caps_init(void)
115 if (max_cpuid >= 7) { 119 if (max_cpuid >= 7) {
116 cpuid(7, NULL, &ebx, NULL, NULL); 120 cpuid(7, NULL, &ebx, NULL, NULL);
117 121
122 /* Intel ADX feature bit - ebx[19]. */
123 if (((ebx >> 19) & 1) != 0)
124 crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_ADX;
125
118 /* Intel SHA extensions feature bit - ebx[29]. */ 126 /* Intel SHA extensions feature bit - ebx[29]. */
119 if (((ebx >> 29) & 1) != 0) 127 if (((ebx >> 29) & 1) != 0)
120 crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_SHA; 128 crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_SHA;
@@ -126,9 +134,3 @@ crypto_cpu_caps_init(void)
126 134
127 OPENSSL_ia32cap_P = caps; 135 OPENSSL_ia32cap_P = caps;
128} 136}
129
130uint64_t
131crypto_cpu_caps_ia32(void)
132{
133 return OPENSSL_ia32cap_P;
134}
diff --git a/src/lib/libcrypto/arch/amd64/opensslconf.h b/src/lib/libcrypto/arch/amd64/opensslconf.h
index cc193762f1..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/amd64/opensslconf.h
+++ b/src/lib/libcrypto/arch/amd64/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,134 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#define RC4_CHUNK unsigned long
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#undef BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68#define SIXTY_FOUR_BIT_LONG
69#undef SIXTY_FOUR_BIT
70#undef THIRTY_TWO_BIT
71#endif
72
73#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
74#define CONFIG_HEADER_BF_LOCL_H
75#undef BF_PTR
76#endif /* HEADER_BF_LOCL_H */
77
78#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
79#define CONFIG_HEADER_DES_LOCL_H
80#ifndef DES_DEFAULT_OPTIONS
81/* the following is tweaked from a config script, that is why it is a
82 * protected undef/define */
83#ifndef DES_PTR
84#undef DES_PTR
85#endif
86
87/* This helps C compiler generate the correct code for multiple functional
88 * units. It reduces register dependencies at the expense of 2 more
89 * registers */
90#ifndef DES_RISC1
91#undef DES_RISC1
92#endif
93
94#ifndef DES_RISC2
95#undef DES_RISC2
96#endif
97
98#if defined(DES_RISC1) && defined(DES_RISC2)
99YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
100#endif
101
102/* Unroll the inner loop, this sometimes helps, sometimes hinders.
103 * Very much CPU dependent */
104#ifndef DES_UNROLL
105#define DES_UNROLL
106#endif
107
108/* These default values were supplied by
109 * Peter Gutman <pgut001@cs.auckland.ac.nz>
110 * They are only used if nothing else has been defined */
111#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
112/* Special defines which change the way the code is built depending on the
113 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
114 even newer MIPS CPU's, but at the moment one size fits all for
115 optimization options. Older Sparc's work better with only UNROLL, but
116 there's no way to tell at compile time what it is you're running on */
117
118#if defined( sun ) /* Newer Sparc's */
119# define DES_PTR
120# define DES_RISC1
121# define DES_UNROLL
122#elif defined( __ultrix ) /* Older MIPS */
123# define DES_PTR
124# define DES_RISC2
125# define DES_UNROLL
126#elif defined( __osf1__ ) /* Alpha */
127# define DES_PTR
128# define DES_RISC2
129#elif defined ( _AIX ) /* RS6000 */
130 /* Unknown */
131#elif defined( __hpux ) /* HP-PA */
132 /* Unknown */
133#elif defined( __aux ) /* 68K */
134 /* Unknown */
135#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
136# define DES_UNROLL
137#elif defined( __sgi ) /* Newer MIPS */
138# define DES_PTR
139# define DES_RISC2
140# define DES_UNROLL
141#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
142# define DES_PTR
143# define DES_RISC1
144# define DES_UNROLL
145#endif /* Systems-specific speed defines */
146#endif
147
148#endif /* DES_DEFAULT_OPTIONS */
149#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/arm/Makefile.inc b/src/lib/libcrypto/arch/arm/Makefile.inc
index e078c51d98..271dff04f6 100644
--- a/src/lib/libcrypto/arch/arm/Makefile.inc
+++ b/src/lib/libcrypto/arch/arm/Makefile.inc
@@ -1,28 +1,3 @@
1# $oPenBSD: Makefile.inc,v 1.2 2014/05/02 18:21:39 miod Exp $ 1# $OpenBSD: Makefile.inc,v 1.20 2025/05/24 07:07:18 jsing Exp $
2 2
3# arm-specific libcrypto build rules 3# arm-specific libcrypto build rules
4
5# aes
6CFLAGS+= -DAES_ASM
7SSLASM+= aes aes-armv4
8# bn
9CFLAGS+= -DOPENSSL_BN_ASM_MONT
10SSLASM+= bn armv4-mont
11# modes
12CFLAGS+= -DGHASH_ASM
13SSLASM+= modes ghash-armv4
14# sha
15SSLASM+= sha sha1-armv4-large
16SSLASM+= sha sha256-armv4
17SSLASM+= sha sha512-armv4
18
19.for dir f in ${SSLASM}
20SRCS+= ${f}.S
21GENERATED+=${f}.S
22${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl
23 /usr/bin/perl \
24 ${LCRYPTO_SRC}/${dir}/asm/${f}.pl void ${.TARGET} > ${.TARGET}
25.endfor
26
27CFLAGS+= -DOPENSSL_CPUID_OBJ
28SRCS+= armv4cpuid.S armcap.c
diff --git a/src/lib/libcrypto/arch/arm/arm_arch.h b/src/lib/libcrypto/arch/arm/arm_arch.h
deleted file mode 100644
index 5ac3b935f1..0000000000
--- a/src/lib/libcrypto/arch/arm/arm_arch.h
+++ /dev/null
@@ -1,59 +0,0 @@
1/* $OpenBSD: arm_arch.h,v 1.1 2022/03/23 15:13:31 tb Exp $ */
2#ifndef __ARM_ARCH_H__
3#define __ARM_ARCH_H__
4
5#if !defined(__ARM_ARCH__)
6# if defined(__CC_ARM)
7# define __ARM_ARCH__ __TARGET_ARCH_ARM
8# if defined(__BIG_ENDIAN)
9# define __ARMEB__
10# else
11# define __ARMEL__
12# endif
13# elif defined(__GNUC__)
14 /*
15 * Why doesn't gcc define __ARM_ARCH__? Instead it defines
16 * bunch of below macros. See all_architectures[] table in
17 * gcc/config/arm/arm.c. On a side note it defines
18 * __ARMEL__/__ARMEB__ for little-/big-endian.
19 */
20# if defined(__ARM_ARCH)
21# define __ARM_ARCH__ __ARM_ARCH
22# elif defined(__ARM_ARCH_8A__)
23# define __ARM_ARCH__ 8
24# elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
25 defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
26 defined(__ARM_ARCH_7EM__)
27# define __ARM_ARCH__ 7
28# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
29 defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \
30 defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \
31 defined(__ARM_ARCH_6T2__)
32# define __ARM_ARCH__ 6
33# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
34 defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \
35 defined(__ARM_ARCH_5TEJ__)
36# define __ARM_ARCH__ 5
37# elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
38# define __ARM_ARCH__ 4
39# else
40# error "unsupported ARM architecture"
41# endif
42# endif
43#endif
44
45#if !defined(__ASSEMBLER__)
46extern unsigned int OPENSSL_armcap_P;
47
48#define ARMV7_NEON (1<<0)
49#define ARMV8_AES (1<<1)
50#define ARMV8_SHA1 (1<<2)
51#define ARMV8_SHA256 (1<<3)
52#define ARMV8_PMULL (1<<4)
53#endif
54
55#if defined(__OpenBSD__)
56#define __STRICT_ALIGNMENT
57#endif
58
59#endif
diff --git a/src/lib/libcrypto/arch/arm/armcap.c b/src/lib/libcrypto/arch/arm/armcap.c
deleted file mode 100644
index 0238195397..0000000000
--- a/src/lib/libcrypto/arch/arm/armcap.c
+++ /dev/null
@@ -1,88 +0,0 @@
1/* $OpenBSD: armcap.c,v 1.3 2024/08/29 03:30:05 deraadt Exp $ */
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <setjmp.h>
6#include <signal.h>
7#include <openssl/crypto.h>
8
9#include "arm_arch.h"
10
11unsigned int OPENSSL_armcap_P;
12
13#if __ARM_ARCH__ >= 7
14static sigset_t all_masked;
15
16static sigjmp_buf ill_jmp;
17
18static void
19ill_handler(int sig)
20{
21 siglongjmp(ill_jmp, sig);
22}
23
24/*
25 * Following subroutines could have been inlined, but it's not all
26 * ARM compilers support inline assembler...
27 */
28void _armv7_neon_probe(void);
29void _armv8_aes_probe(void);
30void _armv8_sha1_probe(void);
31void _armv8_sha256_probe(void);
32void _armv8_pmull_probe(void);
33#endif
34
35void
36OPENSSL_cpuid_setup(void)
37{
38#if __ARM_ARCH__ >= 7
39 struct sigaction ill_oact, ill_act;
40 sigset_t oset;
41#endif
42 static int trigger = 0;
43
44 if (trigger)
45 return;
46 trigger = 1;
47
48 OPENSSL_armcap_P = 0;
49
50#if __ARM_ARCH__ >= 7
51 sigfillset(&all_masked);
52 sigdelset(&all_masked, SIGILL);
53 sigdelset(&all_masked, SIGTRAP);
54 sigdelset(&all_masked, SIGFPE);
55 sigdelset(&all_masked, SIGBUS);
56 sigdelset(&all_masked, SIGSEGV);
57
58 memset(&ill_act, 0, sizeof(ill_act));
59 ill_act.sa_handler = ill_handler;
60 ill_act.sa_mask = all_masked;
61
62 sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
63 sigaction(SIGILL, &ill_act, &ill_oact);
64
65 if (sigsetjmp(ill_jmp, 1) == 0) {
66 _armv7_neon_probe();
67 OPENSSL_armcap_P |= ARMV7_NEON;
68 if (sigsetjmp(ill_jmp, 1) == 0) {
69 _armv8_pmull_probe();
70 OPENSSL_armcap_P |= ARMV8_PMULL | ARMV8_AES;
71 } else if (sigsetjmp(ill_jmp, 1) == 0) {
72 _armv8_aes_probe();
73 OPENSSL_armcap_P |= ARMV8_AES;
74 }
75 if (sigsetjmp(ill_jmp, 1) == 0) {
76 _armv8_sha1_probe();
77 OPENSSL_armcap_P |= ARMV8_SHA1;
78 }
79 if (sigsetjmp(ill_jmp, 1) == 0) {
80 _armv8_sha256_probe();
81 OPENSSL_armcap_P |= ARMV8_SHA256;
82 }
83 }
84
85 sigaction (SIGILL, &ill_oact, NULL);
86 sigprocmask(SIG_SETMASK, &oset, NULL);
87#endif
88}
diff --git a/src/lib/libcrypto/arch/arm/armv4cpuid.S b/src/lib/libcrypto/arch/arm/armv4cpuid.S
deleted file mode 100644
index db0b54e496..0000000000
--- a/src/lib/libcrypto/arch/arm/armv4cpuid.S
+++ /dev/null
@@ -1,69 +0,0 @@
1#include "arm_arch.h"
2
3.text
4#if defined(__thumb2__) && !defined(__APPLE__)
5.syntax unified
6.thumb
7#else
8.code 32
9#undef __thumb2__
10#endif
11
12#if __ARM_ARCH__>=7
13.arch armv7-a
14.fpu neon
15
16.align 5
17.globl _armv7_neon_probe
18.type _armv7_neon_probe,%function
19_armv7_neon_probe:
20 vorr q0,q0,q0
21 bx lr
22.size _armv7_neon_probe,.-_armv7_neon_probe
23
24.globl _armv8_aes_probe
25.type _armv8_aes_probe,%function
26_armv8_aes_probe:
27#if defined(__thumb2__) && !defined(__APPLE__)
28.byte 0xb0,0xff,0x00,0x03 @ aese.8 q0,q0
29#else
30.byte 0x00,0x03,0xb0,0xf3 @ aese.8 q0,q0
31#endif
32 bx lr
33.size _armv8_aes_probe,.-_armv8_aes_probe
34
35.globl _armv8_sha1_probe
36.type _armv8_sha1_probe,%function
37_armv8_sha1_probe:
38#if defined(__thumb2__) && !defined(__APPLE__)
39.byte 0x00,0xef,0x40,0x0c @ sha1c.32 q0,q0,q0
40#else
41.byte 0x40,0x0c,0x00,0xf2 @ sha1c.32 q0,q0,q0
42#endif
43 bx lr
44.size _armv8_sha1_probe,.-_armv8_sha1_probe
45
46.globl _armv8_sha256_probe
47.type _armv8_sha256_probe,%function
48_armv8_sha256_probe:
49#if defined(__thumb2__) && !defined(__APPLE__)
50.byte 0x00,0xff,0x40,0x0c @ sha256h.32 q0,q0,q0
51#else
52.byte 0x40,0x0c,0x00,0xf3 @ sha256h.32 q0,q0,q0
53#endif
54 bx lr
55.size _armv8_sha256_probe,.-_armv8_sha256_probe
56.globl _armv8_pmull_probe
57.type _armv8_pmull_probe,%function
58_armv8_pmull_probe:
59#if defined(__thumb2__) && !defined(__APPLE__)
60.byte 0xa0,0xef,0x00,0x0e @ vmull.p64 q0,d0,d0
61#else
62.byte 0x00,0x0e,0xa0,0xf2 @ vmull.p64 q0,d0,d0
63#endif
64 bx lr
65.size _armv8_pmull_probe,.-_armv8_pmull_probe
66#endif
67
68.comm OPENSSL_armcap_P,4,4
69.hidden OPENSSL_armcap_P
diff --git a/src/lib/libcrypto/arch/arm/crypto_arch.h b/src/lib/libcrypto/arch/arm/crypto_arch.h
index 07d7829fe3..732a59cf72 100644
--- a/src/lib/libcrypto/arch/arm/crypto_arch.h
+++ b/src/lib/libcrypto/arch/arm/crypto_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_arch.h,v 1.2 2025/02/14 12:01:58 jsing Exp $ */ 1/* $OpenBSD: crypto_arch.h,v 1.3 2025/05/24 07:07:18 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -20,20 +20,6 @@
20 20
21#ifndef OPENSSL_NO_ASM 21#ifndef OPENSSL_NO_ASM
22 22
23#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL
24#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL
25#define HAVE_AES_ENCRYPT_INTERNAL
26#define HAVE_AES_DECRYPT_INTERNAL
27
28#define HAVE_SHA1_BLOCK_DATA_ORDER
29#define HAVE_SHA1_BLOCK_GENERIC
30
31#define HAVE_SHA256_BLOCK_DATA_ORDER
32#define HAVE_SHA256_BLOCK_GENERIC
33
34#define HAVE_SHA512_BLOCK_DATA_ORDER
35#define HAVE_SHA512_BLOCK_GENERIC
36
37#endif 23#endif
38 24
39#endif 25#endif
diff --git a/src/lib/libcrypto/arch/arm/opensslconf.h b/src/lib/libcrypto/arch/arm/opensslconf.h
index a5d26b6fdc..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/arm/opensslconf.h
+++ b/src/lib/libcrypto/arch/arm/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#undef RC4_CHUNK
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#define BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#undef SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#define THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#undef DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/hppa/opensslconf.h b/src/lib/libcrypto/arch/hppa/opensslconf.h
index a5d26b6fdc..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/hppa/opensslconf.h
+++ b/src/lib/libcrypto/arch/hppa/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#undef RC4_CHUNK
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#define BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#undef SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#define THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#undef DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/i386/Makefile.inc b/src/lib/libcrypto/arch/i386/Makefile.inc
index 4bcf8e2bbc..bfc701687e 100644
--- a/src/lib/libcrypto/arch/i386/Makefile.inc
+++ b/src/lib/libcrypto/arch/i386/Makefile.inc
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile.inc,v 1.28 2025/04/18 13:19:39 jsing Exp $ 1# $OpenBSD: Makefile.inc,v 1.31 2025/06/28 12:39:10 jsing Exp $
2 2
3# i386-specific libcrypto build rules 3# i386-specific libcrypto build rules
4 4
@@ -11,20 +11,26 @@ SRCS += crypto_cpu_caps.c
11CFLAGS+= -DAES_ASM 11CFLAGS+= -DAES_ASM
12SSLASM+= aes aes-586 12SSLASM+= aes aes-586
13SSLASM+= aes aesni-x86 13SSLASM+= aes aesni-x86
14SRCS += aes_i386.c
15
14# bn 16# bn
15CFLAGS+= -DOPENSSL_IA32_SSE2
16SSLASM+= bn bn-586 17SSLASM+= bn bn-586
17SSLASM+= bn co-586 18SSLASM+= bn co-586
18CFLAGS+= -DOPENSSL_BN_ASM_MONT 19CFLAGS+= -DOPENSSL_BN_ASM_MONT
19SSLASM+= bn x86-mont 20SSLASM+= bn x86-mont
21
20# md5 22# md5
21CFLAGS+= -DMD5_ASM 23CFLAGS+= -DMD5_ASM
22SSLASM+= md5 md5-586 24SSLASM+= md5 md5-586
25
23# modes 26# modes
24CFLAGS+= -DGHASH_ASM 27CFLAGS+= -DGHASH_ASM
25SSLASM+= modes ghash-x86 28SSLASM+= modes ghash-x86
29SRCS += gcm128_i386.c
30
26# rc4 31# rc4
27SSLASM+= rc4 rc4-586 32SSLASM+= rc4 rc4-586
33
28# sha 34# sha
29SSLASM+= sha sha1-586 35SSLASM+= sha sha1-586
30SSLASM+= sha sha256-586 36SSLASM+= sha sha256-586
diff --git a/src/lib/libcrypto/arch/i386/crypto_arch.h b/src/lib/libcrypto/arch/i386/crypto_arch.h
index 3df3963d0b..d2faa36e2e 100644
--- a/src/lib/libcrypto/arch/i386/crypto_arch.h
+++ b/src/lib/libcrypto/arch/i386/crypto_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_arch.h,v 1.4 2025/02/14 12:01:58 jsing Exp $ */ 1/* $OpenBSD: crypto_arch.h,v 1.12 2025/07/22 09:18:02 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -15,19 +15,34 @@
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */ 16 */
17 17
18#include <stdint.h>
19
18#ifndef HEADER_CRYPTO_ARCH_H 20#ifndef HEADER_CRYPTO_ARCH_H
19#define HEADER_CRYPTO_ARCH_H 21#define HEADER_CRYPTO_ARCH_H
20 22
21#define HAVE_CRYPTO_CPU_CAPS_INIT 23#define HAVE_CRYPTO_CPU_CAPS_INIT
22#define HAVE_CRYPTO_CPU_CAPS_IA32 24
25#ifndef __ASSEMBLER__
26extern uint64_t crypto_cpu_caps_i386;
27#endif
28
29#define CRYPTO_CPU_CAPS_I386_AES (1ULL << 0)
30#define CRYPTO_CPU_CAPS_I386_CLMUL (1ULL << 1)
31#define CRYPTO_CPU_CAPS_I386_MMX (1ULL << 2)
23 32
24#ifndef OPENSSL_NO_ASM 33#ifndef OPENSSL_NO_ASM
25 34
26#define HAVE_AES_CBC_ENCRYPT_INTERNAL
27#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL 35#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL
28#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL 36#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL
29#define HAVE_AES_ENCRYPT_INTERNAL 37#define HAVE_AES_ENCRYPT_INTERNAL
30#define HAVE_AES_DECRYPT_INTERNAL 38#define HAVE_AES_DECRYPT_INTERNAL
39#define HAVE_AES_CBC_ENCRYPT_INTERNAL
40#define HAVE_AES_CCM64_ENCRYPT_INTERNAL
41#define HAVE_AES_CTR32_ENCRYPT_INTERNAL
42#define HAVE_AES_ECB_ENCRYPT_INTERNAL
43#define HAVE_AES_XTS_ENCRYPT_INTERNAL
44
45#define HAVE_GCM128_INIT
31 46
32#define HAVE_RC4_INTERNAL 47#define HAVE_RC4_INTERNAL
33#define HAVE_RC4_SET_KEY_INTERNAL 48#define HAVE_RC4_SET_KEY_INTERNAL
diff --git a/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c b/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c
index 6bb77411af..07d60f9a3f 100644
--- a/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c
+++ b/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_cpu_caps.c,v 1.3 2024/11/12 13:14:57 jsing Exp $ */ 1/* $OpenBSD: crypto_cpu_caps.c,v 1.6 2025/07/22 09:18:02 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -19,11 +19,15 @@
19 19
20#include <openssl/crypto.h> 20#include <openssl/crypto.h>
21 21
22#include "crypto_arch.h"
22#include "x86_arch.h" 23#include "x86_arch.h"
23 24
24/* Legacy architecture specific capabilities, used by perlasm. */ 25/* Legacy architecture specific capabilities, used by perlasm. */
25uint64_t OPENSSL_ia32cap_P; 26uint64_t OPENSSL_ia32cap_P;
26 27
28/* Machine dependent CPU capabilities. */
29uint64_t crypto_cpu_caps_i386;
30
27/* Machine independent CPU capabilities. */ 31/* Machine independent CPU capabilities. */
28extern uint64_t crypto_cpu_caps; 32extern uint64_t crypto_cpu_caps;
29 33
@@ -85,17 +89,23 @@ crypto_cpu_caps_init(void)
85 caps |= CPUCAP_MASK_FXSR; 89 caps |= CPUCAP_MASK_FXSR;
86 if ((edx & IA32CAP_MASK0_HT) != 0) 90 if ((edx & IA32CAP_MASK0_HT) != 0)
87 caps |= CPUCAP_MASK_HT; 91 caps |= CPUCAP_MASK_HT;
88 if ((edx & IA32CAP_MASK0_MMX) != 0) 92 if ((edx & IA32CAP_MASK0_MMX) != 0) {
89 caps |= CPUCAP_MASK_MMX; 93 caps |= CPUCAP_MASK_MMX;
94 crypto_cpu_caps_i386 |= CRYPTO_CPU_CAPS_I386_MMX;
95 }
90 if ((edx & IA32CAP_MASK0_SSE) != 0) 96 if ((edx & IA32CAP_MASK0_SSE) != 0)
91 caps |= CPUCAP_MASK_SSE; 97 caps |= CPUCAP_MASK_SSE;
92 if ((edx & IA32CAP_MASK0_SSE2) != 0) 98 if ((edx & IA32CAP_MASK0_SSE2) != 0)
93 caps |= CPUCAP_MASK_SSE2; 99 caps |= CPUCAP_MASK_SSE2;
94 100
95 if ((ecx & IA32CAP_MASK1_AESNI) != 0) 101 if ((ecx & IA32CAP_MASK1_AESNI) != 0) {
96 caps |= CPUCAP_MASK_AESNI; 102 caps |= CPUCAP_MASK_AESNI;
97 if ((ecx & IA32CAP_MASK1_PCLMUL) != 0) 103 crypto_cpu_caps_i386 |= CRYPTO_CPU_CAPS_I386_AES;
104 }
105 if ((ecx & IA32CAP_MASK1_PCLMUL) != 0) {
98 caps |= CPUCAP_MASK_PCLMUL; 106 caps |= CPUCAP_MASK_PCLMUL;
107 crypto_cpu_caps_i386 |= CRYPTO_CPU_CAPS_I386_CLMUL;
108 }
99 if ((ecx & IA32CAP_MASK1_SSSE3) != 0) 109 if ((ecx & IA32CAP_MASK1_SSSE3) != 0)
100 caps |= CPUCAP_MASK_SSSE3; 110 caps |= CPUCAP_MASK_SSSE3;
101 111
@@ -112,9 +122,3 @@ crypto_cpu_caps_init(void)
112 122
113 OPENSSL_ia32cap_P = caps; 123 OPENSSL_ia32cap_P = caps;
114} 124}
115
116uint64_t
117crypto_cpu_caps_ia32(void)
118{
119 return OPENSSL_ia32cap_P;
120}
diff --git a/src/lib/libcrypto/arch/i386/opensslconf.h b/src/lib/libcrypto/arch/i386/opensslconf.h
index 03cf31b940..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/i386/opensslconf.h
+++ b/src/lib/libcrypto/arch/i386/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#undef RC4_CHUNK
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned long
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#define BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#undef SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#define THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#define DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#define DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/m88k/opensslconf.h b/src/lib/libcrypto/arch/m88k/opensslconf.h
index a5d26b6fdc..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/m88k/opensslconf.h
+++ b/src/lib/libcrypto/arch/m88k/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#undef RC4_CHUNK
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#define BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#undef SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#define THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#undef DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/mips64/opensslconf.h b/src/lib/libcrypto/arch/mips64/opensslconf.h
index 36cdd2840b..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/mips64/opensslconf.h
+++ b/src/lib/libcrypto/arch/mips64/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#define RC4_CHUNK unsigned long
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#undef BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#define SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#undef THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#define BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#define DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#define DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#undef DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/powerpc/opensslconf.h b/src/lib/libcrypto/arch/powerpc/opensslconf.h
index a5d26b6fdc..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/powerpc/opensslconf.h
+++ b/src/lib/libcrypto/arch/powerpc/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#undef RC4_CHUNK
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#define BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#undef SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#define THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#undef DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/powerpc64/opensslconf.h b/src/lib/libcrypto/arch/powerpc64/opensslconf.h
index cc193762f1..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/powerpc64/opensslconf.h
+++ b/src/lib/libcrypto/arch/powerpc64/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,134 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#define RC4_CHUNK unsigned long
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#undef BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68#define SIXTY_FOUR_BIT_LONG
69#undef SIXTY_FOUR_BIT
70#undef THIRTY_TWO_BIT
71#endif
72
73#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
74#define CONFIG_HEADER_BF_LOCL_H
75#undef BF_PTR
76#endif /* HEADER_BF_LOCL_H */
77
78#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
79#define CONFIG_HEADER_DES_LOCL_H
80#ifndef DES_DEFAULT_OPTIONS
81/* the following is tweaked from a config script, that is why it is a
82 * protected undef/define */
83#ifndef DES_PTR
84#undef DES_PTR
85#endif
86
87/* This helps C compiler generate the correct code for multiple functional
88 * units. It reduces register dependencies at the expense of 2 more
89 * registers */
90#ifndef DES_RISC1
91#undef DES_RISC1
92#endif
93
94#ifndef DES_RISC2
95#undef DES_RISC2
96#endif
97
98#if defined(DES_RISC1) && defined(DES_RISC2)
99YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
100#endif
101
102/* Unroll the inner loop, this sometimes helps, sometimes hinders.
103 * Very much CPU dependent */
104#ifndef DES_UNROLL
105#define DES_UNROLL
106#endif
107
108/* These default values were supplied by
109 * Peter Gutman <pgut001@cs.auckland.ac.nz>
110 * They are only used if nothing else has been defined */
111#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
112/* Special defines which change the way the code is built depending on the
113 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
114 even newer MIPS CPU's, but at the moment one size fits all for
115 optimization options. Older Sparc's work better with only UNROLL, but
116 there's no way to tell at compile time what it is you're running on */
117
118#if defined( sun ) /* Newer Sparc's */
119# define DES_PTR
120# define DES_RISC1
121# define DES_UNROLL
122#elif defined( __ultrix ) /* Older MIPS */
123# define DES_PTR
124# define DES_RISC2
125# define DES_UNROLL
126#elif defined( __osf1__ ) /* Alpha */
127# define DES_PTR
128# define DES_RISC2
129#elif defined ( _AIX ) /* RS6000 */
130 /* Unknown */
131#elif defined( __hpux ) /* HP-PA */
132 /* Unknown */
133#elif defined( __aux ) /* 68K */
134 /* Unknown */
135#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
136# define DES_UNROLL
137#elif defined( __sgi ) /* Newer MIPS */
138# define DES_PTR
139# define DES_RISC2
140# define DES_UNROLL
141#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
142# define DES_PTR
143# define DES_RISC1
144# define DES_UNROLL
145#endif /* Systems-specific speed defines */
146#endif
147
148#endif /* DES_DEFAULT_OPTIONS */
149#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/riscv64/opensslconf.h b/src/lib/libcrypto/arch/riscv64/opensslconf.h
index 731b06aecc..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/riscv64/opensslconf.h
+++ b/src/lib/libcrypto/arch/riscv64/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#define RC4_CHUNK unsigned long
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#undef BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#define SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#undef THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#undef DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/sh/opensslconf.h b/src/lib/libcrypto/arch/sh/opensslconf.h
index a5d26b6fdc..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/sh/opensslconf.h
+++ b/src/lib/libcrypto/arch/sh/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#undef RC4_CHUNK
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#define BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#undef SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#define THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#undef BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#undef DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#undef DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#define DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/arch/sparc64/opensslconf.h b/src/lib/libcrypto/arch/sparc64/opensslconf.h
index 36cdd2840b..c31bcc01ad 100644
--- a/src/lib/libcrypto/arch/sparc64/opensslconf.h
+++ b/src/lib/libcrypto/arch/sparc64/opensslconf.h
@@ -1,9 +1,4 @@
1#include <openssl/opensslfeatures.h> 1#include <openssl/opensslfeatures.h>
2/* crypto/opensslconf.h.in */
3
4#if defined(HEADER_CRYPTO_LOCAL_H) && !defined(OPENSSLDIR)
5#define OPENSSLDIR "/etc/ssl"
6#endif
7 2
8#undef OPENSSL_EXPORT_VAR_AS_FUNCTION 3#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
9 4
@@ -16,139 +11,3 @@
16#define OPENSSL_LINE __LINE__ 11#define OPENSSL_LINE __LINE__
17#endif 12#endif
18#endif 13#endif
19
20#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
21#define IDEA_INT unsigned int
22#endif
23
24#if defined(HEADER_MD2_H) && !defined(MD2_INT)
25#define MD2_INT unsigned int
26#endif
27
28#if defined(HEADER_RC2_H) && !defined(RC2_INT)
29/* I need to put in a mod for the alpha - eay */
30#define RC2_INT unsigned int
31#endif
32
33#if defined(HEADER_RC4_H)
34#if !defined(RC4_INT)
35/* using int types make the structure larger but make the code faster
36 * on most boxes I have tested - up to %20 faster. */
37/*
38 * I don't know what does "most" mean, but declaring "int" is a must on:
39 * - Intel P6 because partial register stalls are very expensive;
40 * - elder Alpha because it lacks byte load/store instructions;
41 */
42#define RC4_INT unsigned int
43#endif
44#if !defined(RC4_CHUNK)
45/*
46 * This enables code handling data aligned at natural CPU word
47 * boundary. See crypto/rc4/rc4_enc.c for further details.
48 */
49#define RC4_CHUNK unsigned long
50#endif
51#endif
52
53#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
54/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
55 * %20 speed up (longs are 8 bytes, int's are 4). */
56#ifndef DES_LONG
57#define DES_LONG unsigned int
58#endif
59#endif
60
61#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
62#define CONFIG_HEADER_BN_H
63#undef BN_LLONG
64
65/* Should we define BN_DIV2W here? */
66
67/* Only one for the following should be defined */
68/* The prime number generation stuff may not work when
69 * EIGHT_BIT but I don't care since I've only used this mode
70 * for debugging the bignum libraries */
71#define SIXTY_FOUR_BIT_LONG
72#undef SIXTY_FOUR_BIT
73#undef THIRTY_TWO_BIT
74#undef SIXTEEN_BIT
75#undef EIGHT_BIT
76#endif
77
78#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
79#define CONFIG_HEADER_BF_LOCL_H
80#define BF_PTR
81#endif /* HEADER_BF_LOCL_H */
82
83#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
84#define CONFIG_HEADER_DES_LOCL_H
85#ifndef DES_DEFAULT_OPTIONS
86/* the following is tweaked from a config script, that is why it is a
87 * protected undef/define */
88#ifndef DES_PTR
89#define DES_PTR
90#endif
91
92/* This helps C compiler generate the correct code for multiple functional
93 * units. It reduces register dependencies at the expense of 2 more
94 * registers */
95#ifndef DES_RISC1
96#undef DES_RISC1
97#endif
98
99#ifndef DES_RISC2
100#define DES_RISC2
101#endif
102
103#if defined(DES_RISC1) && defined(DES_RISC2)
104YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
105#endif
106
107/* Unroll the inner loop, this sometimes helps, sometimes hinders.
108 * Very much CPU dependent */
109#ifndef DES_UNROLL
110#undef DES_UNROLL
111#endif
112
113/* These default values were supplied by
114 * Peter Gutman <pgut001@cs.auckland.ac.nz>
115 * They are only used if nothing else has been defined */
116#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
117/* Special defines which change the way the code is built depending on the
118 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
119 even newer MIPS CPU's, but at the moment one size fits all for
120 optimization options. Older Sparc's work better with only UNROLL, but
121 there's no way to tell at compile time what it is you're running on */
122
123#if defined( sun ) /* Newer Sparc's */
124# define DES_PTR
125# define DES_RISC1
126# define DES_UNROLL
127#elif defined( __ultrix ) /* Older MIPS */
128# define DES_PTR
129# define DES_RISC2
130# define DES_UNROLL
131#elif defined( __osf1__ ) /* Alpha */
132# define DES_PTR
133# define DES_RISC2
134#elif defined ( _AIX ) /* RS6000 */
135 /* Unknown */
136#elif defined( __hpux ) /* HP-PA */
137 /* Unknown */
138#elif defined( __aux ) /* 68K */
139 /* Unknown */
140#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
141# define DES_UNROLL
142#elif defined( __sgi ) /* Newer MIPS */
143# define DES_PTR
144# define DES_RISC2
145# define DES_UNROLL
146#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
147# define DES_PTR
148# define DES_RISC1
149# define DES_UNROLL
150#endif /* Systems-specific speed defines */
151#endif
152
153#endif /* DES_DEFAULT_OPTIONS */
154#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index d5d00c4d44..3d1e49c49a 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_bitstr.c,v 1.43 2024/07/08 14:52:31 beck Exp $ */ 1/* $OpenBSD: a_bitstr.c,v 1.44 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,10 +63,10 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/conf.h> 65#include <openssl/conf.h>
66#include <openssl/err.h>
67#include <openssl/x509v3.h> 66#include <openssl/x509v3.h>
68 67
69#include "bytestring.h" 68#include "bytestring.h"
69#include "err_local.h"
70 70
71const ASN1_ITEM ASN1_BIT_STRING_it = { 71const ASN1_ITEM ASN1_BIT_STRING_it = {
72 .itype = ASN1_ITYPE_PRIMITIVE, 72 .itype = ASN1_ITYPE_PRIMITIVE,
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index 5d3a3dd0c7..ac5033ea8a 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_enum.c,v 1.30 2024/07/08 14:52:31 beck Exp $ */ 1/* $OpenBSD: a_enum.c,v 1.31 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,10 +63,10 @@
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/buffer.h> 65#include <openssl/buffer.h>
66#include <openssl/err.h>
67 66
68#include "asn1_local.h" 67#include "asn1_local.h"
69#include "bytestring.h" 68#include "bytestring.h"
69#include "err_local.h"
70 70
71/* 71/*
72 * Code for ENUMERATED type: identical to INTEGER apart from a different tag. 72 * Code for ENUMERATED type: identical to INTEGER apart from a different tag.
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index 0d9b6577d7..f171e330f6 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_int.c,v 1.48 2024/07/08 14:52:31 beck Exp $ */ 1/* $OpenBSD: a_int.c,v 1.49 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -64,9 +64,9 @@
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/bn.h> 65#include <openssl/bn.h>
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#include <openssl/err.h>
68 67
69#include "bytestring.h" 68#include "bytestring.h"
69#include "err_local.h"
70 70
71const ASN1_ITEM ASN1_INTEGER_it = { 71const ASN1_ITEM ASN1_INTEGER_it = {
72 .itype = ASN1_ITYPE_PRIMITIVE, 72 .itype = ASN1_ITYPE_PRIMITIVE,
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
index f050f97539..38398ad1d1 100644
--- a/src/lib/libcrypto/asn1/a_mbstr.c
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_mbstr.c,v 1.27 2023/07/05 21:23:36 beck Exp $ */ 1/* $OpenBSD: a_mbstr.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -61,9 +61,9 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/err.h>
65 64
66#include "asn1_local.h" 65#include "asn1_local.h"
66#include "err_local.h"
67 67
68static int traverse_string(const unsigned char *p, int len, int inform, 68static int traverse_string(const unsigned char *p, int len, int inform,
69 int (*rfunc)(unsigned long value, void *in), void *arg); 69 int (*rfunc)(unsigned long value, void *in), void *arg);
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c
index 2f3ca1398f..333ac60348 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_object.c,v 1.55 2024/07/08 14:52:31 beck Exp $ */ 1/* $OpenBSD: a_object.c,v 1.56 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,11 +62,11 @@
62 62
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/err.h>
66#include <openssl/buffer.h> 65#include <openssl/buffer.h>
67#include <openssl/objects.h> 66#include <openssl/objects.h>
68 67
69#include "asn1_local.h" 68#include "asn1_local.h"
69#include "err_local.h"
70 70
71const ASN1_ITEM ASN1_OBJECT_it = { 71const ASN1_ITEM ASN1_OBJECT_it = {
72 .itype = ASN1_ITYPE_PRIMITIVE, 72 .itype = ASN1_ITYPE_PRIMITIVE,
diff --git a/src/lib/libcrypto/asn1/a_pkey.c b/src/lib/libcrypto/asn1/a_pkey.c
index a730728076..636b602377 100644
--- a/src/lib/libcrypto/asn1/a_pkey.c
+++ b/src/lib/libcrypto/asn1/a_pkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_pkey.c,v 1.8 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: a_pkey.c,v 1.9 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,12 +62,12 @@
62 62
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/err.h>
66#include <openssl/evp.h> 65#include <openssl/evp.h>
67#include <openssl/objects.h> 66#include <openssl/objects.h>
68#include <openssl/x509.h> 67#include <openssl/x509.h>
69 68
70#include "asn1_local.h" 69#include "asn1_local.h"
70#include "err_local.h"
71#include "evp_local.h" 71#include "evp_local.h"
72 72
73EVP_PKEY * 73EVP_PKEY *
diff --git a/src/lib/libcrypto/asn1/a_pubkey.c b/src/lib/libcrypto/asn1/a_pubkey.c
index 544f3d2cf0..f846b6cda5 100644
--- a/src/lib/libcrypto/asn1/a_pubkey.c
+++ b/src/lib/libcrypto/asn1/a_pubkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_pubkey.c,v 1.7 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: a_pubkey.c,v 1.8 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,7 +62,6 @@
62 62
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/err.h>
66#include <openssl/evp.h> 65#include <openssl/evp.h>
67#include <openssl/objects.h> 66#include <openssl/objects.h>
68 67
@@ -76,6 +75,7 @@
76#include <openssl/rsa.h> 75#include <openssl/rsa.h>
77#endif 76#endif
78 77
78#include "err_local.h"
79#include "evp_local.h" 79#include "evp_local.h"
80 80
81EVP_PKEY * 81EVP_PKEY *
diff --git a/src/lib/libcrypto/asn1/a_string.c b/src/lib/libcrypto/asn1/a_string.c
index ec492e71f0..70e9c95f22 100644
--- a/src/lib/libcrypto/asn1/a_string.c
+++ b/src/lib/libcrypto/asn1/a_string.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_string.c,v 1.17 2023/08/15 18:05:15 tb Exp $ */ 1/* $OpenBSD: a_string.c,v 1.18 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,9 +61,9 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/err.h>
65 64
66#include "asn1_local.h" 65#include "asn1_local.h"
66#include "err_local.h"
67 67
68ASN1_STRING * 68ASN1_STRING *
69ASN1_STRING_new(void) 69ASN1_STRING_new(void)
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index 5fa60b9ce7..3519d6725d 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_strnid.c,v 1.31 2024/03/02 08:54:02 tb Exp $ */ 1/* $OpenBSD: a_strnid.c,v 1.32 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -62,7 +62,6 @@
62#include <string.h> 62#include <string.h>
63 63
64#include <openssl/asn1.h> 64#include <openssl/asn1.h>
65#include <openssl/err.h>
66#include <openssl/objects.h> 65#include <openssl/objects.h>
67 66
68/* 67/*
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index 15ac1af5c4..3deff56eda 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_time.c,v 1.38 2024/07/08 14:52:31 beck Exp $ */ 1/* $OpenBSD: a_time.c,v 1.39 2025/05/10 05:54:38 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -65,7 +65,6 @@
65#include <time.h> 65#include <time.h>
66 66
67#include <openssl/asn1t.h> 67#include <openssl/asn1t.h>
68#include <openssl/err.h>
69 68
70#include "asn1_local.h" 69#include "asn1_local.h"
71 70
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c
index a1f329be96..dd2893167f 100644
--- a/src/lib/libcrypto/asn1/a_time_tm.c
+++ b/src/lib/libcrypto/asn1/a_time_tm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_time_tm.c,v 1.42 2024/05/03 18:33:27 tb Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.43 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -22,10 +22,10 @@
22#include <time.h> 22#include <time.h>
23 23
24#include <openssl/asn1t.h> 24#include <openssl/asn1t.h>
25#include <openssl/err.h>
26 25
27#include "bytestring.h"
28#include "asn1_local.h" 26#include "asn1_local.h"
27#include "bytestring.h"
28#include "err_local.h"
29 29
30#define RFC5280 0 30#define RFC5280 0
31#define GENTIME_LENGTH 15 31#define GENTIME_LENGTH 15
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c
index ef0a76e810..502db42a73 100644
--- a/src/lib/libcrypto/asn1/a_type.c
+++ b/src/lib/libcrypto/asn1/a_type.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_type.c,v 1.27 2023/07/28 10:00:10 tb Exp $ */ 1/* $OpenBSD: a_type.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,10 +59,10 @@
59#include <string.h> 59#include <string.h>
60 60
61#include <openssl/asn1t.h> 61#include <openssl/asn1t.h>
62#include <openssl/err.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64 63
65#include "asn1_local.h" 64#include "asn1_local.h"
65#include "err_local.h"
66 66
67typedef struct { 67typedef struct {
68 ASN1_INTEGER *num; 68 ASN1_INTEGER *num;
diff --git a/src/lib/libcrypto/asn1/asn1_gen.c b/src/lib/libcrypto/asn1/asn1_gen.c
index edd6743993..b409e83c7d 100644
--- a/src/lib/libcrypto/asn1/asn1_gen.c
+++ b/src/lib/libcrypto/asn1/asn1_gen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_gen.c,v 1.27 2025/03/06 07:25:01 tb Exp $ */ 1/* $OpenBSD: asn1_gen.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -59,11 +59,11 @@
59#include <string.h> 59#include <string.h>
60 60
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/err.h>
63#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
64 63
65#include "asn1_local.h" 64#include "asn1_local.h"
66#include "conf_local.h" 65#include "conf_local.h"
66#include "err_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
69#define ASN1_GEN_FLAG 0x10000 69#define ASN1_GEN_FLAG 0x10000
diff --git a/src/lib/libcrypto/asn1/asn1_item.c b/src/lib/libcrypto/asn1/asn1_item.c
index 86c800e3ad..621d65711b 100644
--- a/src/lib/libcrypto/asn1/asn1_item.c
+++ b/src/lib/libcrypto/asn1/asn1_item.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_item.c,v 1.21 2024/04/09 13:55:02 beck Exp $ */ 1/* $OpenBSD: asn1_item.c,v 1.22 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -112,11 +112,11 @@
112#include <limits.h> 112#include <limits.h>
113 113
114#include <openssl/buffer.h> 114#include <openssl/buffer.h>
115#include <openssl/err.h>
116#include <openssl/evp.h> 115#include <openssl/evp.h>
117#include <openssl/x509.h> 116#include <openssl/x509.h>
118 117
119#include "asn1_local.h" 118#include "asn1_local.h"
119#include "err_local.h"
120#include "evp_local.h" 120#include "evp_local.h"
121#include "x509_local.h" 121#include "x509_local.h"
122 122
diff --git a/src/lib/libcrypto/asn1/asn1_old.c b/src/lib/libcrypto/asn1/asn1_old.c
index 7992fccdef..c47ea8e74a 100644
--- a/src/lib/libcrypto/asn1/asn1_old.c
+++ b/src/lib/libcrypto/asn1/asn1_old.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_old.c,v 1.6 2024/04/10 14:55:12 beck Exp $ */ 1/* $OpenBSD: asn1_old.c,v 1.7 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,9 +61,9 @@
61 61
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h>
65 64
66#include "asn1_local.h" 65#include "asn1_local.h"
66#include "err_local.h"
67 67
68#ifndef NO_OLD_ASN1 68#ifndef NO_OLD_ASN1
69 69
diff --git a/src/lib/libcrypto/asn1/asn1_old_lib.c b/src/lib/libcrypto/asn1/asn1_old_lib.c
index 80362ae689..541ac7b615 100644
--- a/src/lib/libcrypto/asn1/asn1_old_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_old_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_old_lib.c,v 1.6 2023/07/05 21:23:36 beck Exp $ */ 1/* $OpenBSD: asn1_old_lib.c,v 1.7 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,9 +61,9 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/err.h>
65 64
66#include "asn1_local.h" 65#include "asn1_local.h"
66#include "err_local.h"
67 67
68static void asn1_put_length(unsigned char **pp, int length); 68static void asn1_put_length(unsigned char **pp, int length);
69 69
diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c
index 3995fc547c..d42dd8663e 100644
--- a/src/lib/libcrypto/asn1/asn_mime.c
+++ b/src/lib/libcrypto/asn1/asn_mime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn_mime.c,v 1.35 2025/01/17 05:02:18 tb Exp $ */ 1/* $OpenBSD: asn_mime.c,v 1.37 2025/06/02 12:18:21 jsg Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -59,10 +59,10 @@
59 59
60#include <openssl/asn1.h> 60#include <openssl/asn1.h>
61#include <openssl/asn1t.h> 61#include <openssl/asn1t.h>
62#include <openssl/err.h>
63#include <openssl/x509.h> 62#include <openssl/x509.h>
64 63
65#include "asn1_local.h" 64#include "asn1_local.h"
65#include "err_local.h"
66#include "evp_local.h" 66#include "evp_local.h"
67 67
68/* Generalised MIME like utilities for streaming ASN1. Although many 68/* Generalised MIME like utilities for streaming ASN1. Although many
@@ -507,8 +507,9 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
507 *bcont = sk_BIO_value(parts, 0); 507 *bcont = sk_BIO_value(parts, 0);
508 BIO_free(asnin); 508 BIO_free(asnin);
509 sk_BIO_free(parts); 509 sk_BIO_free(parts);
510 } else sk_BIO_pop_free(parts, BIO_vfree); 510 } else
511 return val; 511 sk_BIO_pop_free(parts, BIO_vfree);
512 return val;
512 } 513 }
513 514
514 /* OK, if not multipart/signed try opaque signature */ 515 /* OK, if not multipart/signed try opaque signature */
diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c
index e3c7d09446..a9a752cc38 100644
--- a/src/lib/libcrypto/asn1/asn_moid.c
+++ b/src/lib/libcrypto/asn1/asn_moid.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn_moid.c,v 1.18 2024/08/31 09:26:18 tb Exp $ */ 1/* $OpenBSD: asn_moid.c,v 1.20 2025/05/10 11:51:01 tb Exp $ */
2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -60,13 +60,13 @@
60#include <stdio.h> 60#include <stdio.h>
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/err.h>
64#include <openssl/conf.h> 63#include <openssl/conf.h>
65#include <openssl/crypto.h> 64#include <openssl/crypto.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67 66
68#include "asn1_local.h" 67#include "asn1_local.h"
69#include "conf_local.h" 68#include "conf_local.h"
69#include "err_local.h"
70 70
71/* Simple ASN1 OID module: add all objects in a given section */ 71/* Simple ASN1 OID module: add all objects in a given section */
72 72
diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c
index 98bb1cd197..d001ffb0ae 100644
--- a/src/lib/libcrypto/asn1/bio_ndef.c
+++ b/src/lib/libcrypto/asn1/bio_ndef.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_ndef.c,v 1.24 2023/07/28 09:58:30 tb Exp $ */ 1/* $OpenBSD: bio_ndef.c,v 1.25 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -57,9 +57,9 @@
57#include <openssl/asn1.h> 57#include <openssl/asn1.h>
58#include <openssl/asn1t.h> 58#include <openssl/asn1t.h>
59#include <openssl/bio.h> 59#include <openssl/bio.h>
60#include <openssl/err.h>
61 60
62#include "asn1_local.h" 61#include "asn1_local.h"
62#include "err_local.h"
63 63
64int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, asn1_ps_func *prefix_free); 64int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, asn1_ps_func *prefix_free);
65int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, asn1_ps_func *suffix_free); 65int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, asn1_ps_func *suffix_free);
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c
index 582d2d9a9b..668bf5d7c1 100644
--- a/src/lib/libcrypto/asn1/p5_pbe.c
+++ b/src/lib/libcrypto/asn1/p5_pbe.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p5_pbe.c,v 1.28 2024/07/08 14:48:49 beck Exp $ */ 1/* $OpenBSD: p5_pbe.c,v 1.30 2025/05/24 02:57:14 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -61,11 +61,14 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/err.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
66#include "err_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
69/* RFC 8018, section 6.1 specifies an eight-octet salt for PBES1. */
70#define PKCS5_PBE1_SALT_LEN 8
71
69/* PKCS#5 password based encryption structure */ 72/* PKCS#5 password based encryption structure */
70 73
71static const ASN1_TEMPLATE PBEPARAM_seq_tt[] = { 74static const ASN1_TEMPLATE PBEPARAM_seq_tt[] = {
@@ -139,7 +142,7 @@ PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
139 goto err; 142 goto err;
140 } 143 }
141 if (!saltlen) 144 if (!saltlen)
142 saltlen = PKCS5_SALT_LEN; 145 saltlen = PKCS5_PBE1_SALT_LEN;
143 if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) { 146 if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) {
144 ASN1error(ERR_R_MALLOC_FAILURE); 147 ASN1error(ERR_R_MALLOC_FAILURE);
145 goto err; 148 goto err;
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 76872a8dec..64924d9b38 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p5_pbev2.c,v 1.35 2024/03/26 07:03:10 tb Exp $ */ 1/* $OpenBSD: p5_pbev2.c,v 1.38 2025/05/24 02:57:14 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999-2004. 3 * project 1999-2004.
4 */ 4 */
@@ -61,12 +61,18 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/err.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
66#include "err_local.h"
67#include "evp_local.h" 67#include "evp_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70/*
71 * RFC 8018, sections 6.2 and 4 specify at least 64 bits for PBES2, apparently
72 * FIPS will require at least 128 bits in the future, OpenSSL does that.
73 */
74#define PKCS5_PBE2_SALT_LEN 16
75
70/* PKCS#5 v2.0 password based encryption structures */ 76/* PKCS#5 v2.0 password based encryption structures */
71 77
72static const ASN1_TEMPLATE PBE2PARAM_seq_tt[] = { 78static const ASN1_TEMPLATE PBE2PARAM_seq_tt[] = {
@@ -187,7 +193,7 @@ PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, unsigned char *salt,
187 int saltlen) 193 int saltlen)
188{ 194{
189 X509_ALGOR *scheme = NULL, *kalg = NULL, *ret = NULL; 195 X509_ALGOR *scheme = NULL, *kalg = NULL, *ret = NULL;
190 int prf_nid = NID_hmacWithSHA1; 196 int prf_nid = NID_hmacWithSHA256;
191 int alg_nid, keylen; 197 int alg_nid, keylen;
192 EVP_CIPHER_CTX ctx; 198 EVP_CIPHER_CTX ctx;
193 unsigned char iv[EVP_MAX_IV_LENGTH]; 199 unsigned char iv[EVP_MAX_IV_LENGTH];
@@ -292,7 +298,7 @@ PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, int prf_nid,
292 kdf->salt->type = V_ASN1_OCTET_STRING; 298 kdf->salt->type = V_ASN1_OCTET_STRING;
293 299
294 if (!saltlen) 300 if (!saltlen)
295 saltlen = PKCS5_SALT_LEN; 301 saltlen = PKCS5_PBE2_SALT_LEN;
296 if (!(osalt->data = malloc (saltlen))) 302 if (!(osalt->data = malloc (saltlen)))
297 goto merr; 303 goto merr;
298 304
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index 6449e7f199..295ab6c050 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_crl.c,v 1.26 2024/05/03 02:52:00 tb Exp $ */ 1/* $OpenBSD: t_crl.c,v 1.27 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -61,11 +61,11 @@
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h>
65#include <openssl/objects.h> 64#include <openssl/objects.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67#include <openssl/x509v3.h> 66#include <openssl/x509v3.h>
68 67
68#include "err_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
70 70
71int 71int
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index 1d4be9865d..51e4b4f651 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_req.c,v 1.28 2024/05/03 02:52:00 tb Exp $ */ 1/* $OpenBSD: t_req.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,7 +62,6 @@
62 62
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/buffer.h> 64#include <openssl/buffer.h>
65#include <openssl/err.h>
66#include <openssl/objects.h> 65#include <openssl/objects.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68#include <openssl/x509v3.h> 67#include <openssl/x509v3.h>
@@ -74,6 +73,7 @@
74#include <openssl/rsa.h> 73#include <openssl/rsa.h>
75#endif 74#endif
76 75
76#include "err_local.h"
77#include "x509_local.h" 77#include "x509_local.h"
78 78
79int 79int
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 7cf4557314..71f97a8214 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_x509.c,v 1.51 2025/02/08 03:41:36 tb Exp $ */ 1/* $OpenBSD: t_x509.c,v 1.54 2025/07/01 06:46:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -65,13 +65,13 @@
65 65
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/bio.h> 67#include <openssl/bio.h>
68#include <openssl/err.h>
69#include <openssl/evp.h> 68#include <openssl/evp.h>
70#include <openssl/objects.h> 69#include <openssl/objects.h>
71#include <openssl/sha.h> 70#include <openssl/sha.h>
72#include <openssl/x509.h> 71#include <openssl/x509.h>
73#include <openssl/x509v3.h> 72#include <openssl/x509v3.h>
74 73
74#include "err_local.h"
75#include "evp_local.h" 75#include "evp_local.h"
76#include "x509_local.h" 76#include "x509_local.h"
77 77
@@ -106,6 +106,28 @@ X509_print(BIO *bp, X509 *x)
106} 106}
107LCRYPTO_ALIAS(X509_print); 107LCRYPTO_ALIAS(X509_print);
108 108
109static int
110x509_print_uids(BIO *bp, const X509 *x, int indent)
111{
112 const ASN1_BIT_STRING *issuerUID = NULL, *subjectUID = NULL;
113
114 X509_get0_uids(x, &issuerUID, &subjectUID);
115 if (issuerUID != NULL) {
116 if (BIO_printf(bp, "%*sIssuer Unique ID: ", indent, "") <= 0)
117 return 0;
118 if (!X509_signature_dump(bp, issuerUID, indent + 4))
119 return 0;
120 }
121 if (subjectUID != NULL) {
122 if (BIO_printf(bp, "%*sSubject Unique ID: ", indent, "") <= 0)
123 return 0;
124 if (!X509_signature_dump(bp, subjectUID, indent + 4))
125 return 0;
126 }
127
128 return 1;
129}
130
109int 131int
110X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) 132X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
111{ 133{
@@ -127,9 +149,9 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
127 149
128 ci = x->cert_info; 150 ci = x->cert_info;
129 if (!(cflag & X509_FLAG_NO_HEADER)) { 151 if (!(cflag & X509_FLAG_NO_HEADER)) {
130 if (BIO_write(bp, "Certificate:\n", 13) <= 0) 152 if (BIO_printf(bp, "Certificate:\n") <= 0)
131 goto err; 153 goto err;
132 if (BIO_write(bp, " Data:\n", 10) <= 0) 154 if (BIO_printf(bp, " Data:\n") <= 0)
133 goto err; 155 goto err;
134 } 156 }
135 if (!(cflag & X509_FLAG_NO_VERSION)) { 157 if (!(cflag & X509_FLAG_NO_VERSION)) {
@@ -145,7 +167,7 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
145 } 167 }
146 } 168 }
147 if (!(cflag & X509_FLAG_NO_SERIAL)) { 169 if (!(cflag & X509_FLAG_NO_SERIAL)) {
148 if (BIO_write(bp, " Serial Number:", 22) <= 0) 170 if (BIO_printf(bp, " Serial Number:") <= 0)
149 goto err; 171 goto err;
150 172
151 bs = X509_get_serialNumber(x); 173 bs = X509_get_serialNumber(x);
@@ -196,21 +218,21 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
196 if (X509_NAME_print_ex(bp, X509_get_issuer_name(x), 218 if (X509_NAME_print_ex(bp, X509_get_issuer_name(x),
197 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0)) 219 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0))
198 goto err; 220 goto err;
199 if (BIO_write(bp, "\n", 1) <= 0) 221 if (BIO_printf(bp, "\n") <= 0)
200 goto err; 222 goto err;
201 } 223 }
202 if (!(cflag & X509_FLAG_NO_VALIDITY)) { 224 if (!(cflag & X509_FLAG_NO_VALIDITY)) {
203 if (BIO_write(bp, " Validity\n", 17) <= 0) 225 if (BIO_printf(bp, " Validity\n") <= 0)
204 goto err; 226 goto err;
205 if (BIO_write(bp, " Not Before: ", 24) <= 0) 227 if (BIO_printf(bp, " Not Before: ") <= 0)
206 goto err; 228 goto err;
207 if (!ASN1_TIME_print(bp, X509_get_notBefore(x))) 229 if (!ASN1_TIME_print(bp, X509_get_notBefore(x)))
208 goto err; 230 goto err;
209 if (BIO_write(bp, "\n Not After : ", 25) <= 0) 231 if (BIO_printf(bp, "\n Not After : ") <= 0)
210 goto err; 232 goto err;
211 if (!ASN1_TIME_print(bp, X509_get_notAfter(x))) 233 if (!ASN1_TIME_print(bp, X509_get_notAfter(x)))
212 goto err; 234 goto err;
213 if (BIO_write(bp, "\n", 1) <= 0) 235 if (BIO_printf(bp, "\n") <= 0)
214 goto err; 236 goto err;
215 } 237 }
216 if (!(cflag & X509_FLAG_NO_SUBJECT)) { 238 if (!(cflag & X509_FLAG_NO_SUBJECT)) {
@@ -219,12 +241,11 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
219 if (X509_NAME_print_ex(bp, X509_get_subject_name(x), 241 if (X509_NAME_print_ex(bp, X509_get_subject_name(x),
220 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0)) 242 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0))
221 goto err; 243 goto err;
222 if (BIO_write(bp, "\n", 1) <= 0) 244 if (BIO_printf(bp, "\n") <= 0)
223 goto err; 245 goto err;
224 } 246 }
225 if (!(cflag & X509_FLAG_NO_PUBKEY)) { 247 if (!(cflag & X509_FLAG_NO_PUBKEY)) {
226 if (BIO_write(bp, " Subject Public Key Info:\n", 248 if (BIO_printf(bp, " Subject Public Key Info:\n") <= 0)
227 33) <= 0)
228 goto err; 249 goto err;
229 if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) 250 if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0)
230 goto err; 251 goto err;
@@ -243,6 +264,11 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
243 } 264 }
244 } 265 }
245 266
267 if (!(cflag & X509_FLAG_NO_IDS)) {
268 if (!x509_print_uids(bp, x, 8))
269 goto err;
270 }
271
246 if (!(cflag & X509_FLAG_NO_EXTENSIONS)) 272 if (!(cflag & X509_FLAG_NO_EXTENSIONS))
247 X509V3_extensions_print(bp, "X509v3 extensions", 273 X509V3_extensions_print(bp, "X509v3 extensions",
248 ci->extensions, cflag, 8); 274 ci->extensions, cflag, 8);
@@ -325,7 +351,7 @@ X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent)
325 s = sig->data; 351 s = sig->data;
326 for (i = 0; i < n; i++) { 352 for (i = 0; i < n; i++) {
327 if ((i % 18) == 0) { 353 if ((i % 18) == 0) {
328 if (BIO_write(bp, "\n", 1) <= 0) 354 if (BIO_printf(bp, "\n") <= 0)
329 return 0; 355 return 0;
330 if (BIO_indent(bp, indent, indent) <= 0) 356 if (BIO_indent(bp, indent, indent) <= 0)
331 return 0; 357 return 0;
@@ -334,7 +360,7 @@ X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent)
334 ((i + 1) == n) ? "" : ":") <= 0) 360 ((i + 1) == n) ? "" : ":") <= 0)
335 return 0; 361 return 0;
336 } 362 }
337 if (BIO_write(bp, "\n", 1) != 1) 363 if (BIO_printf(bp, "\n") != 1)
338 return 0; 364 return 0;
339 365
340 return 1; 366 return 1;
@@ -375,7 +401,7 @@ ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
375 return ASN1_UTCTIME_print(bp, tm); 401 return ASN1_UTCTIME_print(bp, tm);
376 if (tm->type == V_ASN1_GENERALIZEDTIME) 402 if (tm->type == V_ASN1_GENERALIZEDTIME)
377 return ASN1_GENERALIZEDTIME_print(bp, tm); 403 return ASN1_GENERALIZEDTIME_print(bp, tm);
378 BIO_write(bp, "Bad time value", 14); 404 BIO_printf(bp, "Bad time value");
379 return (0); 405 return (0);
380} 406}
381LCRYPTO_ALIAS(ASN1_TIME_print); 407LCRYPTO_ALIAS(ASN1_TIME_print);
@@ -435,7 +461,7 @@ ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
435 return (1); 461 return (1);
436 462
437 err: 463 err:
438 BIO_write(bp, "Bad time value", 14); 464 BIO_printf(bp, "Bad time value");
439 return (0); 465 return (0);
440} 466}
441LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_print); 467LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_print);
@@ -479,7 +505,7 @@ ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)
479 return (1); 505 return (1);
480 506
481 err: 507 err:
482 BIO_write(bp, "Bad time value", 14); 508 BIO_printf(bp, "Bad time value");
483 return (0); 509 return (0);
484} 510}
485LCRYPTO_ALIAS(ASN1_UTCTIME_print); 511LCRYPTO_ALIAS(ASN1_UTCTIME_print);
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 31b9efee54..1bffae8a94 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_dec.c,v 1.88 2023/07/28 10:00:10 tb Exp $ */ 1/* $OpenBSD: tasn_dec.c,v 1.89 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -63,11 +63,11 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/buffer.h> 65#include <openssl/buffer.h>
66#include <openssl/err.h>
67#include <openssl/objects.h> 66#include <openssl/objects.h>
68 67
69#include "asn1_local.h" 68#include "asn1_local.h"
70#include "bytestring.h" 69#include "bytestring.h"
70#include "err_local.h"
71 71
72/* 72/*
73 * Constructed types with a recursive definition (such as can be found in PKCS7) 73 * Constructed types with a recursive definition (such as can be found in PKCS7)
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index b71993a139..a65fb5b7e7 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_enc.c,v 1.33 2023/07/28 10:00:10 tb Exp $ */ 1/* $OpenBSD: tasn_enc.c,v 1.34 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -61,10 +61,10 @@
61 61
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/err.h>
65#include <openssl/objects.h> 64#include <openssl/objects.h>
66 65
67#include "asn1_local.h" 66#include "asn1_local.h"
67#include "err_local.h"
68 68
69static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, 69static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
70 const ASN1_ITEM *it, int tag, int aclass); 70 const ASN1_ITEM *it, int tag, int aclass);
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index 0e259a13ab..c3de668483 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_fre.c,v 1.24 2024/12/11 11:22:06 tb Exp $ */ 1/* $OpenBSD: tasn_fre.c,v 1.25 2025/08/14 19:02:17 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -147,8 +147,9 @@ asn1_item_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
147 return; 147 return;
148 } 148 }
149 asn1_enc_cleanup(pval, it); 149 asn1_enc_cleanup(pval, it);
150 /* If we free up as normal we will invalidate any 150 /*
151 * ANY DEFINED BY field and we wont be able to 151 * If we free up as normal, we will invalidate any
152 * ANY DEFINED BY field and we won't be able to
152 * determine the type of the field it defines. So 153 * determine the type of the field it defines. So
153 * free up in reverse order. 154 * free up in reverse order.
154 */ 155 */
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index 10c1137dbf..e17810b832 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_new.c,v 1.25 2023/07/28 10:00:10 tb Exp $ */ 1/* $OpenBSD: tasn_new.c,v 1.26 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -60,11 +60,11 @@
60#include <stddef.h> 60#include <stddef.h>
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/err.h>
64#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
65#include <string.h> 64#include <string.h>
66 65
67#include "asn1_local.h" 66#include "asn1_local.h"
67#include "err_local.h"
68 68
69static int asn1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); 69static int asn1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
70static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); 70static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index 07764fc091..4db6d61111 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_prn.c,v 1.27 2024/03/02 09:04:07 tb Exp $ */ 1/* $OpenBSD: tasn_prn.c,v 1.29 2025/06/07 09:28:00 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -61,7 +61,6 @@
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/asn1t.h> 62#include <openssl/asn1t.h>
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h>
65#include <openssl/objects.h> 64#include <openssl/objects.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
@@ -411,7 +410,7 @@ asn1_primitive_print(BIO *out, ASN1_VALUE **fld, const ASN1_ITEM *it,
411 if (!asn1_print_fsname(out, indent, fname, sname, pctx)) 410 if (!asn1_print_fsname(out, indent, fname, sname, pctx))
412 return 0; 411 return 0;
413 412
414 if (it != NULL && it->funcs != NULL) { 413 if (it->funcs != NULL) {
415 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; 414 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
416 415
417 if (pf->prim_print == NULL) 416 if (pf->prim_print == NULL)
diff --git a/src/lib/libcrypto/asn1/tasn_utl.c b/src/lib/libcrypto/asn1/tasn_utl.c
index ae546edd4b..178a364c89 100644
--- a/src/lib/libcrypto/asn1/tasn_utl.c
+++ b/src/lib/libcrypto/asn1/tasn_utl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_utl.c,v 1.18 2022/12/26 07:18:51 jmc Exp $ */ 1/* $OpenBSD: tasn_utl.c,v 1.19 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -63,9 +63,9 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/objects.h> 65#include <openssl/objects.h>
66#include <openssl/err.h>
67 66
68#include "bytestring.h" 67#include "bytestring.h"
68#include "err_local.h"
69 69
70/* Utility functions for manipulating fields and offsets */ 70/* Utility functions for manipulating fields and offsets */
71 71
diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c
index 7ad8350f3d..19caf56cec 100644
--- a/src/lib/libcrypto/asn1/x_crl.c
+++ b/src/lib/libcrypto/asn1/x_crl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_crl.c,v 1.48 2025/02/27 20:13:41 tb Exp $ */ 1/* $OpenBSD: x_crl.c,v 1.50 2025/07/10 18:48:31 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,11 +61,11 @@
61#include <openssl/opensslconf.h> 61#include <openssl/opensslconf.h>
62 62
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/err.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
68#include "asn1_local.h" 67#include "asn1_local.h"
68#include "err_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
70 70
71static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); 71static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp);
@@ -540,6 +540,12 @@ LCRYPTO_ALIAS(X509_CRL_add0_revoked);
540int 540int
541X509_CRL_verify(X509_CRL *crl, EVP_PKEY *pkey) 541X509_CRL_verify(X509_CRL *crl, EVP_PKEY *pkey)
542{ 542{
543 /*
544 * The CertificateList's signature AlgorithmIdentifier must match
545 * the one inside the TBSCertList, see RFC 5280, 5.1.1.2, 5.1.2.2.
546 */
547 if (X509_ALGOR_cmp(crl->sig_alg, crl->crl->sig_alg) != 0)
548 return 0;
543 return ASN1_item_verify(&X509_CRL_INFO_it, crl->sig_alg, crl->signature, 549 return ASN1_item_verify(&X509_CRL_INFO_it, crl->sig_alg, crl->signature,
544 crl->crl, pkey); 550 crl->crl, pkey);
545} 551}
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c
deleted file mode 100644
index d2c4bcfe7a..0000000000
--- a/src/lib/libcrypto/asn1/x_info.c
+++ /dev/null
@@ -1,96 +0,0 @@
1/* $OpenBSD: x_info.c,v 1.22 2024/12/11 10:28:03 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60
61#include <openssl/asn1.h>
62#include <openssl/err.h>
63#include <openssl/x509.h>
64
65X509_INFO *
66X509_INFO_new(void)
67{
68 X509_INFO *ret;
69
70 if ((ret = calloc(1, sizeof(X509_INFO))) == NULL) {
71 ASN1error(ERR_R_MALLOC_FAILURE);
72 return NULL;
73 }
74 ret->references = 1;
75
76 return ret;
77}
78LCRYPTO_ALIAS(X509_INFO_new);
79
80void
81X509_INFO_free(X509_INFO *x)
82{
83 if (x == NULL)
84 return;
85
86 if (CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_INFO) > 0)
87 return;
88
89 X509_free(x->x509);
90 X509_CRL_free(x->crl);
91 X509_PKEY_free(x->x_pkey);
92 free(x->enc_data);
93
94 free(x);
95}
96LCRYPTO_ALIAS(X509_INFO_free);
diff --git a/src/lib/libcrypto/asn1/x_long.c b/src/lib/libcrypto/asn1/x_long.c
index 5e673f4521..a72411f30c 100644
--- a/src/lib/libcrypto/asn1/x_long.c
+++ b/src/lib/libcrypto/asn1/x_long.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_long.c,v 1.21 2024/07/08 16:24:22 beck Exp $ */ 1/* $OpenBSD: x_long.c,v 1.22 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -61,9 +61,9 @@
61 61
62#include <openssl/asn1t.h> 62#include <openssl/asn1t.h>
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/err.h>
65 64
66#include "asn1_local.h" 65#include "asn1_local.h"
66#include "err_local.h"
67 67
68/* 68/*
69 * Custom primitive type for long handling. This converts between an 69 * Custom primitive type for long handling. This converts between an
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c
index c60714b74f..09536666fc 100644
--- a/src/lib/libcrypto/asn1/x_name.c
+++ b/src/lib/libcrypto/asn1/x_name.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_name.c,v 1.45 2025/03/20 09:41:47 tb Exp $ */ 1/* $OpenBSD: x_name.c,v 1.46 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,10 +61,10 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/err.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
67#include "asn1_local.h" 66#include "asn1_local.h"
67#include "err_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY; 70typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
diff --git a/src/lib/libcrypto/asn1/x_pkey.c b/src/lib/libcrypto/asn1/x_pkey.c
deleted file mode 100644
index 5c96c13ab9..0000000000
--- a/src/lib/libcrypto/asn1/x_pkey.c
+++ /dev/null
@@ -1,123 +0,0 @@
1/* $OpenBSD: x_pkey.c,v 1.24 2024/04/09 13:55:02 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <string.h>
61
62#include <openssl/err.h>
63#include <openssl/evp.h>
64#include <openssl/objects.h>
65#include <openssl/x509.h>
66
67X509_PKEY *
68X509_PKEY_new(void)
69{
70 X509_PKEY *ret = NULL;
71
72 if ((ret = malloc(sizeof(X509_PKEY))) == NULL) {
73 ASN1error(ERR_R_MALLOC_FAILURE);
74 goto err;
75 }
76 ret->version = 0;
77 if ((ret->enc_algor = X509_ALGOR_new()) == NULL) {
78 ASN1error(ERR_R_MALLOC_FAILURE);
79 goto err;
80 }
81 if ((ret->enc_pkey = ASN1_OCTET_STRING_new()) == NULL) {
82 ASN1error(ERR_R_MALLOC_FAILURE);
83 goto err;
84 }
85 ret->dec_pkey = NULL;
86 ret->key_length = 0;
87 ret->key_data = NULL;
88 ret->key_free = 0;
89 ret->cipher.cipher = NULL;
90 memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
91 ret->references = 1;
92 return (ret);
93
94 err:
95 if (ret) {
96 X509_ALGOR_free(ret->enc_algor);
97 free(ret);
98 }
99 return NULL;
100}
101LCRYPTO_ALIAS(X509_PKEY_new);
102
103void
104X509_PKEY_free(X509_PKEY *x)
105{
106 int i;
107
108 if (x == NULL)
109 return;
110
111 i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_PKEY);
112 if (i > 0)
113 return;
114
115 if (x->enc_algor != NULL)
116 X509_ALGOR_free(x->enc_algor);
117 ASN1_OCTET_STRING_free(x->enc_pkey);
118 EVP_PKEY_free(x->dec_pkey);
119 if ((x->key_data != NULL) && (x->key_free))
120 free(x->key_data);
121 free(x);
122}
123LCRYPTO_ALIAS(X509_PKEY_free);
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c
index 1e772a3458..ec847861ea 100644
--- a/src/lib/libcrypto/asn1/x_pubkey.c
+++ b/src/lib/libcrypto/asn1/x_pubkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_pubkey.c,v 1.37 2024/07/08 14:48:49 beck Exp $ */ 1/* $OpenBSD: x_pubkey.c,v 1.38 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,7 +61,6 @@
61#include <openssl/opensslconf.h> 61#include <openssl/opensslconf.h>
62 62
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/err.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
67#ifndef OPENSSL_NO_DSA 66#ifndef OPENSSL_NO_DSA
@@ -72,6 +71,7 @@
72#endif 71#endif
73 72
74#include "asn1_local.h" 73#include "asn1_local.h"
74#include "err_local.h"
75#include "evp_local.h" 75#include "evp_local.h"
76#include "x509_local.h" 76#include "x509_local.h"
77 77
diff --git a/src/lib/libcrypto/bf/bf_local.h b/src/lib/libcrypto/bf/bf_local.h
index 8fc5a5dbd8..2fe65eb85c 100644
--- a/src/lib/libcrypto/bf/bf_local.h
+++ b/src/lib/libcrypto/bf/bf_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bf_local.h,v 1.3 2024/03/27 11:54:29 jsing Exp $ */ 1/* $OpenBSD: bf_local.h,v 1.4 2025/06/11 04:08:16 tb Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,11 +56,11 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <openssl/opensslconf.h> /* BF_PTR */
60
61#ifndef HEADER_BF_LOCL_H 59#ifndef HEADER_BF_LOCL_H
62#define HEADER_BF_LOCL_H 60#define HEADER_BF_LOCL_H
63 61
62#include <openssl/opensslconf.h>
63
64/* NOTE - c is not incremented as per n2l */ 64/* NOTE - c is not incremented as per n2l */
65#define n2ln(c,l1,l2,n) { \ 65#define n2ln(c,l1,l2,n) { \
66 c+=n; \ 66 c+=n; \
@@ -104,46 +104,6 @@
104 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ 104 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
105 *((c)++)=(unsigned char)(((l) )&0xff)) 105 *((c)++)=(unsigned char)(((l) )&0xff))
106 106
107/* This is actually a big endian algorithm, the most significant byte
108 * is used to lookup array 0 */
109
110#if defined(BF_PTR)
111
112#ifndef BF_LONG_LOG2
113#define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */
114#endif
115#define BF_M (0xFF<<BF_LONG_LOG2)
116#define BF_0 (24-BF_LONG_LOG2)
117#define BF_1 (16-BF_LONG_LOG2)
118#define BF_2 ( 8-BF_LONG_LOG2)
119#define BF_3 BF_LONG_LOG2 /* left shift */
120
121/*
122 * This is normally very good on RISC platforms where normally you
123 * have to explicitly "multiply" array index by sizeof(BF_LONG)
124 * in order to calculate the effective address. This implementation
125 * excuses CPU from this extra work. Power[PC] uses should have most
126 * fun as (R>>BF_i)&BF_M gets folded into a single instruction, namely
127 * rlwinm. So let'em double-check if their compiler does it.
128 */
129
130#define BF_ENC(LL,R,S,P) ( \
131 LL^=P, \
132 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
133 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
134 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
135 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M))) \
136 )
137#else
138
139/*
140 * This is a *generic* version. Seem to perform best on platforms that
141 * offer explicit support for extraction of 8-bit nibbles preferably
142 * complemented with "multiplying" of array index by sizeof(BF_LONG).
143 * For the moment of this writing the list comprises Alpha CPU featuring
144 * extbl and s[48]addq instructions.
145 */
146
147#define BF_ENC(LL,R,S,P) ( \ 107#define BF_ENC(LL,R,S,P) ( \
148 LL^=P, \ 108 LL^=P, \
149 LL^=((( S[ ((int)(R>>24)&0xff)] + \ 109 LL^=((( S[ ((int)(R>>24)&0xff)] + \
@@ -151,6 +111,5 @@
151 S[0x0200+((int)(R>> 8)&0xff)])+ \ 111 S[0x0200+((int)(R>> 8)&0xff)])+ \
152 S[0x0300+((int)(R )&0xff)])&0xffffffffL \ 112 S[0x0300+((int)(R )&0xff)])&0xffffffffL \
153 ) 113 )
154#endif
155 114
156#endif 115#endif
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c
index 4dcf710bbe..3f673205c1 100644
--- a/src/lib/libcrypto/bio/b_dump.c
+++ b/src/lib/libcrypto/bio/b_dump.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_dump.c,v 1.30 2024/03/02 09:21:24 tb Exp $ */ 1/* $OpenBSD: b_dump.c,v 1.31 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,7 +62,6 @@
62#include <string.h> 62#include <string.h>
63 63
64#include <openssl/bio.h> 64#include <openssl/bio.h>
65#include <openssl/err.h>
66 65
67#include "bytestring.h" 66#include "bytestring.h"
68 67
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 00bbe9c37e..9ef9953b95 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.71 2023/07/05 21:23:37 beck Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.72 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2017 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -32,7 +32,8 @@
32 32
33#include <openssl/bio.h> 33#include <openssl/bio.h>
34#include <openssl/buffer.h> 34#include <openssl/buffer.h>
35#include <openssl/err.h> 35
36#include "err_local.h"
36 37
37int 38int
38BIO_get_host_ip(const char *str, unsigned char *ip) 39BIO_get_host_ip(const char *str, unsigned char *ip)
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c
index 226c16835a..36b6fabde3 100644
--- a/src/lib/libcrypto/bio/bf_buff.c
+++ b/src/lib/libcrypto/bio/bf_buff.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bf_buff.c,v 1.28 2023/07/05 21:23:37 beck Exp $ */ 1/* $OpenBSD: bf_buff.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,9 +61,9 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/err.h>
65 64
66#include "bio_local.h" 65#include "bio_local.h"
66#include "err_local.h"
67 67
68static int buffer_write(BIO *h, const char *buf, int num); 68static int buffer_write(BIO *h, const char *buf, int num);
69static int buffer_read(BIO *h, char *buf, int size); 69static int buffer_read(BIO *h, char *buf, int size);
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index 8327ffc071..a8108054e7 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -1,25 +1,25 @@
1/* $OpenBSD: bio.h,v 1.64 2024/05/19 07:12:50 jsg Exp $ */ 1/* $OpenBSD: bio.h,v 1.65 2025/07/16 18:12:54 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA, 11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms 13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * 15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in 16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed. 17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution 18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used. 19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or 20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package. 21 * in documentation (online or textual) provided with the package.
22 * 22 *
23 * Redistribution and use in source and binary forms, with or without 23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 24 * modification, are permitted provided that the following conditions
25 * are met: 25 * are met:
@@ -34,10 +34,10 @@
34 * Eric Young (eay@cryptsoft.com)" 34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library 35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-). 36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from 37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement: 38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * 40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 * 52 *
53 * The licence and distribution terms for any publically available version or 53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
@@ -96,8 +96,8 @@ extern "C" {
96#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ 96#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */
97#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ 97#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */
98#define BIO_TYPE_DGRAM (21|0x0400|0x0100) 98#define BIO_TYPE_DGRAM (21|0x0400|0x0100)
99#define BIO_TYPE_ASN1 (22|0x0200) /* filter */ 99#define BIO_TYPE_ASN1 (22|0x0200) /* filter */
100#define BIO_TYPE_COMP (23|0x0200) /* filter */ 100#define BIO_TYPE_COMP (23|0x0200) /* filter */
101 101
102#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ 102#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
103#define BIO_TYPE_FILTER 0x0200 103#define BIO_TYPE_FILTER 0x0200
@@ -139,14 +139,14 @@ extern "C" {
139#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ 139#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */
140#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally 140#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally
141 * connected socket to be 141 * connected socket to be
142 * passed in */ 142 * passed in */
143#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ 143#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */
144#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ 144#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */
145#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ 145#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */
146#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */ 146#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */
147 147
148#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */ 148#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */
149#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */ 149#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation timed out */
150 150
151/* #ifdef IP_MTU_DISCOVER */ 151/* #ifdef IP_MTU_DISCOVER */
152#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */ 152#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */
@@ -232,7 +232,7 @@ void BIO_clear_flags(BIO *b, int flags);
232 232
233/* The next three are used in conjunction with the 233/* The next three are used in conjunction with the
234 * BIO_should_io_special() condition. After this returns true, 234 * BIO_should_io_special() condition. After this returns true,
235 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO 235 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
236 * stack and return the 'reason' for the special and the offending BIO. 236 * stack and return the 'reason' for the special and the offending BIO.
237 * Given a BIO, BIO_get_retry_reason(bio) will return the code. */ 237 * Given a BIO, BIO_get_retry_reason(bio) will return the code. */
238/* Returned from the SSL bio when the certificate retrieval code had an error */ 238/* Returned from the SSL bio when the certificate retrieval code had an error */
@@ -380,7 +380,7 @@ int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
380#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) 380#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
381#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) 381#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
382#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) 382#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
383#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) 383#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
384#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0) 384#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0)
385 385
386 386
@@ -571,7 +571,6 @@ const BIO_METHOD *BIO_s_socket(void);
571const BIO_METHOD *BIO_s_connect(void); 571const BIO_METHOD *BIO_s_connect(void);
572const BIO_METHOD *BIO_s_accept(void); 572const BIO_METHOD *BIO_s_accept(void);
573const BIO_METHOD *BIO_s_fd(void); 573const BIO_METHOD *BIO_s_fd(void);
574const BIO_METHOD *BIO_s_log(void);
575const BIO_METHOD *BIO_s_bio(void); 574const BIO_METHOD *BIO_s_bio(void);
576const BIO_METHOD *BIO_s_null(void); 575const BIO_METHOD *BIO_s_null(void);
577const BIO_METHOD *BIO_f_null(void); 576const BIO_METHOD *BIO_f_null(void);
diff --git a/src/lib/libcrypto/bio/bio_cb.c b/src/lib/libcrypto/bio/bio_cb.c
index 18e9be8d68..990cb20708 100644
--- a/src/lib/libcrypto/bio/bio_cb.c
+++ b/src/lib/libcrypto/bio/bio_cb.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_cb.c,v 1.19 2023/07/05 21:23:37 beck Exp $ */ 1/* $OpenBSD: bio_cb.c,v 1.20 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,7 +60,6 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/err.h>
64#include <openssl/bio.h> 63#include <openssl/bio.h>
65 64
66#include "bio_local.h" 65#include "bio_local.h"
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 463d2ad23a..04e8f4c295 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_lib.c,v 1.54 2024/07/09 06:14:59 beck Exp $ */ 1/* $OpenBSD: bio_lib.c,v 1.55 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,10 +62,10 @@
62 62
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/crypto.h> 64#include <openssl/crypto.h>
65#include <openssl/err.h>
66#include <openssl/stack.h> 65#include <openssl/stack.h>
67 66
68#include "bio_local.h" 67#include "bio_local.h"
68#include "err_local.h"
69 69
70/* 70/*
71 * Helper function to work out whether to call the new style callback or the old 71 * Helper function to work out whether to call the new style callback or the old
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index d74c710a7f..60e61100b1 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_acpt.c,v 1.31 2023/07/05 21:23:37 beck Exp $ */ 1/* $OpenBSD: bss_acpt.c,v 1.33 2025/06/02 12:18:21 jsg Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -65,9 +65,9 @@
65 65
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/buffer.h> 67#include <openssl/buffer.h>
68#include <openssl/err.h>
69 68
70#include "bio_local.h" 69#include "bio_local.h"
70#include "err_local.h"
71 71
72#define SOCKET_PROTOCOL IPPROTO_TCP 72#define SOCKET_PROTOCOL IPPROTO_TCP
73 73
@@ -261,11 +261,12 @@ again:
261 if (c->bio_chain != NULL) { 261 if (c->bio_chain != NULL) {
262 if ((dbio = BIO_dup_chain(c->bio_chain)) == NULL) 262 if ((dbio = BIO_dup_chain(c->bio_chain)) == NULL)
263 goto err; 263 goto err;
264 if (!BIO_push(dbio, bio)) goto err; 264 if (!BIO_push(dbio, bio))
265 bio = dbio; 265 goto err;
266 bio = dbio;
266 } 267 }
267 if (BIO_push(b, bio) 268 if (BIO_push(b, bio) == NULL)
268 == NULL) goto err; 269 goto err;
269 270
270 c->state = ACPT_S_OK; 271 c->state = ACPT_S_OK;
271 return (1); 272 return (1);
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index 39d8d1e46c..f1d1bbeecd 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_bio.c,v 1.29 2024/07/09 06:14:59 beck Exp $ */ 1/* $OpenBSD: bss_bio.c,v 1.30 2025/05/10 05:54:38 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -81,10 +81,10 @@
81#include <sys/types.h> 81#include <sys/types.h>
82 82
83#include <openssl/bio.h> 83#include <openssl/bio.h>
84#include <openssl/err.h>
85#include <openssl/crypto.h> 84#include <openssl/crypto.h>
86 85
87#include "bio_local.h" 86#include "bio_local.h"
87#include "err_local.h"
88 88
89static int bio_new(BIO *bio); 89static int bio_new(BIO *bio);
90static int bio_free(BIO *bio); 90static int bio_free(BIO *bio);
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index 3b0e3d3bdd..14f410f59d 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_conn.c,v 1.41 2024/04/19 09:54:36 tb Exp $ */ 1/* $OpenBSD: bss_conn.c,v 1.43 2025/06/02 12:18:21 jsg Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -68,9 +68,9 @@
68 68
69#include <openssl/bio.h> 69#include <openssl/bio.h>
70#include <openssl/buffer.h> 70#include <openssl/buffer.h>
71#include <openssl/err.h>
72 71
73#include "bio_local.h" 72#include "bio_local.h"
73#include "err_local.h"
74 74
75#define SOCKET_PROTOCOL IPPROTO_TCP 75#define SOCKET_PROTOCOL IPPROTO_TCP
76 76
@@ -141,7 +141,7 @@ conn_state(BIO *b, BIO_CONNECT *c)
141 } 141 }
142 for (; *p != '\0'; p++) { 142 for (; *p != '\0'; p++) {
143 if ((*p == ':') || (*p == '/')) 143 if ((*p == ':') || (*p == '/'))
144 break; 144 break;
145 } 145 }
146 146
147 i= *p; 147 i= *p;
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 9b6ca2bdd8..21f71718bb 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_file.c,v 1.35 2023/07/05 21:23:37 beck Exp $ */ 1/* $OpenBSD: bss_file.c,v 1.36 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -88,9 +88,9 @@
88#include <string.h> 88#include <string.h>
89 89
90#include <openssl/bio.h> 90#include <openssl/bio.h>
91#include <openssl/err.h>
92 91
93#include "bio_local.h" 92#include "bio_local.h"
93#include "err_local.h"
94 94
95static int file_write(BIO *h, const char *buf, int num); 95static int file_write(BIO *h, const char *buf, int num);
96static int file_read(BIO *h, char *buf, int size); 96static int file_read(BIO *h, char *buf, int size);
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
deleted file mode 100644
index 9e2e882646..0000000000
--- a/src/lib/libcrypto/bio/bss_log.c
+++ /dev/null
@@ -1,216 +0,0 @@
1/* $OpenBSD: bss_log.c,v 1.24 2023/07/05 21:23:37 beck Exp $ */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * licensing@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/*
57 Why BIO_s_log?
58
59 BIO_s_log is useful for system daemons (or services under NT).
60 It is one-way BIO, it sends all stuff to syslogd (on system that
61 commonly use that), or event log (on NT), or OPCOM (on OpenVMS).
62
63*/
64
65#include <errno.h>
66#include <stdio.h>
67#include <string.h>
68#include <syslog.h>
69
70#include <openssl/buffer.h>
71#include <openssl/err.h>
72
73#include "bio_local.h"
74
75#ifndef NO_SYSLOG
76
77static int slg_write(BIO *h, const char *buf, int num);
78static int slg_puts(BIO *h, const char *str);
79static long slg_ctrl(BIO *h, int cmd, long arg1, void *arg2);
80static int slg_new(BIO *h);
81static int slg_free(BIO *data);
82static void xopenlog(BIO* bp, char* name, int level);
83static void xsyslog(BIO* bp, int priority, const char* string);
84static void xcloselog(BIO* bp);
85
86static const BIO_METHOD methods_slg = {
87 .type = BIO_TYPE_MEM,
88 .name = "syslog",
89 .bwrite = slg_write,
90 .bputs = slg_puts,
91 .ctrl = slg_ctrl,
92 .create = slg_new,
93 .destroy = slg_free
94};
95
96const BIO_METHOD *
97BIO_s_log(void)
98{
99 return (&methods_slg);
100}
101LCRYPTO_ALIAS(BIO_s_log);
102
103static int
104slg_new(BIO *bi)
105{
106 bi->init = 1;
107 bi->num = 0;
108 bi->ptr = NULL;
109 xopenlog(bi, "application", LOG_DAEMON);
110 return (1);
111}
112
113static int
114slg_free(BIO *a)
115{
116 if (a == NULL)
117 return (0);
118 xcloselog(a);
119 return (1);
120}
121
122static int
123slg_write(BIO *b, const char *in, int inl)
124{
125 int ret = inl;
126 char* buf;
127 char* pp;
128 int priority, i;
129 static const struct {
130 int strl;
131 char str[10];
132 int log_level;
133 }
134 mapping[] = {
135 { 6, "PANIC ", LOG_EMERG },
136 { 6, "EMERG ", LOG_EMERG },
137 { 4, "EMR ", LOG_EMERG },
138 { 6, "ALERT ", LOG_ALERT },
139 { 4, "ALR ", LOG_ALERT },
140 { 5, "CRIT ", LOG_CRIT },
141 { 4, "CRI ", LOG_CRIT },
142 { 6, "ERROR ", LOG_ERR },
143 { 4, "ERR ", LOG_ERR },
144 { 8, "WARNING ", LOG_WARNING },
145 { 5, "WARN ", LOG_WARNING },
146 { 4, "WAR ", LOG_WARNING },
147 { 7, "NOTICE ", LOG_NOTICE },
148 { 5, "NOTE ", LOG_NOTICE },
149 { 4, "NOT ", LOG_NOTICE },
150 { 5, "INFO ", LOG_INFO },
151 { 4, "INF ", LOG_INFO },
152 { 6, "DEBUG ", LOG_DEBUG },
153 { 4, "DBG ", LOG_DEBUG },
154 { 0, "", LOG_ERR } /* The default */
155 };
156
157 if ((buf = malloc(inl + 1)) == NULL) {
158 return (0);
159 }
160 strlcpy(buf, in, inl + 1);
161 i = 0;
162 while (strncmp(buf, mapping[i].str, mapping[i].strl) != 0)
163 i++;
164 priority = mapping[i].log_level;
165 pp = buf + mapping[i].strl;
166
167 xsyslog(b, priority, pp);
168
169 free(buf);
170 return (ret);
171}
172
173static long
174slg_ctrl(BIO *b, int cmd, long num, void *ptr)
175{
176 switch (cmd) {
177 case BIO_CTRL_SET:
178 xcloselog(b);
179 xopenlog(b, ptr, num);
180 break;
181 default:
182 break;
183 }
184 return (0);
185}
186
187static int
188slg_puts(BIO *bp, const char *str)
189{
190 int n, ret;
191
192 n = strlen(str);
193 ret = slg_write(bp, str, n);
194 return (ret);
195}
196
197
198static void
199xopenlog(BIO* bp, char* name, int level)
200{
201 openlog(name, LOG_PID|LOG_CONS, level);
202}
203
204static void
205xsyslog(BIO *bp, int priority, const char *string)
206{
207 syslog(priority, "%s", string);
208}
209
210static void
211xcloselog(BIO* bp)
212{
213 closelog();
214}
215
216#endif /* NO_SYSLOG */
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c
index 6d0d54db84..0fa6317a2b 100644
--- a/src/lib/libcrypto/bio/bss_mem.c
+++ b/src/lib/libcrypto/bio/bss_mem.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bss_mem.c,v 1.22 2023/07/05 21:23:37 beck Exp $ */ 1/* $OpenBSD: bss_mem.c,v 1.27 2025/05/31 11:31:16 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,10 +62,10 @@
62#include <string.h> 62#include <string.h>
63 63
64#include <openssl/bio.h> 64#include <openssl/bio.h>
65#include <openssl/err.h>
66#include <openssl/buffer.h> 65#include <openssl/buffer.h>
67 66
68#include "bio_local.h" 67#include "bio_local.h"
68#include "err_local.h"
69 69
70struct bio_mem { 70struct bio_mem {
71 BUF_MEM *buf; 71 BUF_MEM *buf;
@@ -140,6 +140,7 @@ BIO_new_mem_buf(const void *buf, int buf_len)
140 return NULL; 140 return NULL;
141 141
142 bm = bio->ptr; 142 bm = bio->ptr;
143 free(bm->buf->data);
143 bm->buf->data = (void *)buf; /* Trust in the BIO_FLAGS_MEM_RDONLY flag. */ 144 bm->buf->data = (void *)buf; /* Trust in the BIO_FLAGS_MEM_RDONLY flag. */
144 bm->buf->length = buf_len; 145 bm->buf->length = buf_len;
145 bm->buf->max = buf_len; 146 bm->buf->max = buf_len;
@@ -162,6 +163,12 @@ mem_new(BIO *bio)
162 free(bm); 163 free(bm);
163 return 0; 164 return 0;
164 } 165 }
166 if (BUF_MEM_grow_clean(bm->buf, 64) != 64) {
167 BUF_MEM_free(bm->buf);
168 free(bm);
169 return 0;
170 }
171 bm->buf->length = 0;
165 172
166 bio->shutdown = 1; 173 bio->shutdown = 1;
167 bio->init = 1; 174 bio->init = 1;
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_add.S b/src/lib/libcrypto/bn/arch/amd64/bignum_add.S
index 5fe4aae7a1..1d4e6d08ef 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_add.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_add.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_add.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,9 +18,8 @@
16// Add, z := x + y 18// Add, z := x + y
17// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] 19// Inputs x[m], y[n]; outputs function return (carry-out) and z[p]
18// 20//
19// extern uint64_t bignum_add 21// extern uint64_t bignum_add(uint64_t p, uint64_t *z, uint64_t m,
20// (uint64_t p, uint64_t *z, 22// const uint64_t *x, uint64_t n, const uint64_t *y);
21// uint64_t m, uint64_t *x, uint64_t n, uint64_t *y);
22// 23//
23// Does the z := x + y operation, truncating modulo p words in general and 24// Does the z := x + y operation, truncating modulo p words in general and
24// returning a top carry (0 or 1) in the p'th place, only adding the input 25// returning a top carry (0 or 1) in the p'th place, only adding the input
@@ -49,7 +50,7 @@
49 50
50 51
51S2N_BN_SYMBOL(bignum_add): 52S2N_BN_SYMBOL(bignum_add):
52 _CET_ENDBR 53 _CET_ENDBR
53 54
54#if WINDOWS_ABI 55#if WINDOWS_ABI
55 push rdi 56 push rdi
@@ -75,7 +76,7 @@ S2N_BN_SYMBOL(bignum_add):
75 cmp p, n 76 cmp p, n
76 cmovc n, p 77 cmovc n, p
77 cmp m, n 78 cmp m, n
78 jc ylonger 79 jc bignum_add_ylonger
79 80
80// The case where x is longer or of the same size (p >= m >= n) 81// The case where x is longer or of the same size (p >= m >= n)
81 82
@@ -83,27 +84,27 @@ S2N_BN_SYMBOL(bignum_add):
83 sub m, n 84 sub m, n
84 inc m 85 inc m
85 test n, n 86 test n, n
86 jz xtest 87 jz bignum_add_xtest
87xmainloop: 88bignum_add_xmainloop:
88 mov a, [x+8*i] 89 mov a, [x+8*i]
89 adc a, [y+8*i] 90 adc a, [y+8*i]
90 mov [z+8*i],a 91 mov [z+8*i],a
91 inc i 92 inc i
92 dec n 93 dec n
93 jnz xmainloop 94 jnz bignum_add_xmainloop
94 jmp xtest 95 jmp bignum_add_xtest
95xtoploop: 96bignum_add_xtoploop:
96 mov a, [x+8*i] 97 mov a, [x+8*i]
97 adc a, 0 98 adc a, 0
98 mov [z+8*i],a 99 mov [z+8*i],a
99 inc i 100 inc i
100xtest: 101bignum_add_xtest:
101 dec m 102 dec m
102 jnz xtoploop 103 jnz bignum_add_xtoploop
103 mov ashort, 0 104 mov ashort, 0
104 adc a, 0 105 adc a, 0
105 test p, p 106 test p, p
106 jnz tails 107 jnz bignum_add_tails
107#if WINDOWS_ABI 108#if WINDOWS_ABI
108 pop rsi 109 pop rsi
109 pop rdi 110 pop rdi
@@ -112,30 +113,30 @@ xtest:
112 113
113// The case where y is longer (p >= n > m) 114// The case where y is longer (p >= n > m)
114 115
115ylonger: 116bignum_add_ylonger:
116 117
117 sub p, n 118 sub p, n
118 sub n, m 119 sub n, m
119 test m, m 120 test m, m
120 jz ytoploop 121 jz bignum_add_ytoploop
121ymainloop: 122bignum_add_ymainloop:
122 mov a, [x+8*i] 123 mov a, [x+8*i]
123 adc a, [y+8*i] 124 adc a, [y+8*i]
124 mov [z+8*i],a 125 mov [z+8*i],a
125 inc i 126 inc i
126 dec m 127 dec m
127 jnz ymainloop 128 jnz bignum_add_ymainloop
128ytoploop: 129bignum_add_ytoploop:
129 mov a, [y+8*i] 130 mov a, [y+8*i]
130 adc a, 0 131 adc a, 0
131 mov [z+8*i],a 132 mov [z+8*i],a
132 inc i 133 inc i
133 dec n 134 dec n
134 jnz ytoploop 135 jnz bignum_add_ytoploop
135 mov ashort, 0 136 mov ashort, 0
136 adc a, 0 137 adc a, 0
137 test p, p 138 test p, p
138 jnz tails 139 jnz bignum_add_tails
139#if WINDOWS_ABI 140#if WINDOWS_ABI
140 pop rsi 141 pop rsi
141 pop rdi 142 pop rdi
@@ -144,16 +145,16 @@ ytoploop:
144 145
145// Adding a non-trivial tail, when p > max(m,n) 146// Adding a non-trivial tail, when p > max(m,n)
146 147
147tails: 148bignum_add_tails:
148 mov [z+8*i],a 149 mov [z+8*i],a
149 xor a, a 150 xor a, a
150 jmp tail 151 jmp bignum_add_tail
151tailloop: 152bignum_add_tailloop:
152 mov [z+8*i],a 153 mov [z+8*i],a
153tail: 154bignum_add_tail:
154 inc i 155 inc i
155 dec p 156 dec p
156 jnz tailloop 157 jnz bignum_add_tailloop
157#if WINDOWS_ABI 158#if WINDOWS_ABI
158 pop rsi 159 pop rsi
159 pop rdi 160 pop rdi
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S b/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S
index 25ba17bce2..a611919603 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_cmadd.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,8 +18,8 @@
16// Multiply-add with single-word multiplier, z := z + c * y 18// Multiply-add with single-word multiplier, z := z + c * y
17// Inputs c, y[n]; outputs function return (carry-out) and z[k] 19// Inputs c, y[n]; outputs function return (carry-out) and z[k]
18// 20//
19// extern uint64_t bignum_cmadd 21// extern uint64_t bignum_cmadd(uint64_t k, uint64_t *z, uint64_t c, uint64_t n,
20// (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); 22// const uint64_t *y);
21// 23//
22// Does the "z := z + c * y" operation where y is n digits, result z is p. 24// Does the "z := z + c * y" operation where y is n digits, result z is p.
23// Truncates the result in general. 25// Truncates the result in general.
@@ -54,7 +56,7 @@
54 56
55 57
56S2N_BN_SYMBOL(bignum_cmadd): 58S2N_BN_SYMBOL(bignum_cmadd):
57 _CET_ENDBR 59 _CET_ENDBR
58 60
59#if WINDOWS_ABI 61#if WINDOWS_ABI
60 push rdi 62 push rdi
@@ -82,7 +84,7 @@ S2N_BN_SYMBOL(bignum_cmadd):
82 84
83 xor h, h 85 xor h, h
84 test n, n 86 test n, n
85 jz end 87 jz bignum_cmadd_end
86 88
87// Move c into a safer register as multiplies overwrite rdx 89// Move c into a safer register as multiplies overwrite rdx
88 90
@@ -96,11 +98,11 @@ S2N_BN_SYMBOL(bignum_cmadd):
96 mov h, rdx 98 mov h, rdx
97 mov ishort, 1 99 mov ishort, 1
98 dec n 100 dec n
99 jz hightail 101 jz bignum_cmadd_hightail
100 102
101// Main loop, where we always have CF + previous high part h to add in 103// Main loop, where we always have CF + previous high part h to add in
102 104
103loop: 105bignum_cmadd_loop:
104 adc h, [z+8*i] 106 adc h, [z+8*i]
105 sbb r, r 107 sbb r, r
106 mov rax, [x+8*i] 108 mov rax, [x+8*i]
@@ -111,36 +113,36 @@ loop:
111 mov h, rdx 113 mov h, rdx
112 inc i 114 inc i
113 dec n 115 dec n
114 jnz loop 116 jnz bignum_cmadd_loop
115 117
116hightail: 118bignum_cmadd_hightail:
117 adc h, 0 119 adc h, 0
118 120
119// Propagate the carry all the way to the end with h as extra carry word 121// Propagate the carry all the way to the end with h as extra carry word
120 122
121tail: 123bignum_cmadd_tail:
122 test p, p 124 test p, p
123 jz end 125 jz bignum_cmadd_end
124 126
125 add [z+8*i], h 127 add [z+8*i], h
126 mov hshort, 0 128 mov hshort, 0
127 inc i 129 inc i
128 dec p 130 dec p
129 jz highend 131 jz bignum_cmadd_highend
130 132
131tloop: 133bignum_cmadd_tloop:
132 adc [z+8*i], h 134 adc [z+8*i], h
133 inc i 135 inc i
134 dec p 136 dec p
135 jnz tloop 137 jnz bignum_cmadd_tloop
136 138
137highend: 139bignum_cmadd_highend:
138 140
139 adc h, 0 141 adc h, 0
140 142
141// Return the high/carry word 143// Return the high/carry word
142 144
143end: 145bignum_cmadd_end:
144 mov rax, h 146 mov rax, h
145 147
146 pop rbx 148 pop rbx
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S b/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S
index 12f785d63a..eb71d9da44 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_cmul.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,8 +18,8 @@
16// Multiply by a single word, z := c * y 18// Multiply by a single word, z := c * y
17// Inputs c, y[n]; outputs function return (carry-out) and z[k] 19// Inputs c, y[n]; outputs function return (carry-out) and z[k]
18// 20//
19// extern uint64_t bignum_cmul 21// extern uint64_t bignum_cmul(uint64_t k, uint64_t *z, uint64_t c, uint64_t n,
20// (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); 22// const uint64_t *y);
21// 23//
22// Does the "z := c * y" operation where y is n digits, result z is p. 24// Does the "z := c * y" operation where y is n digits, result z is p.
23// Truncates the result in general unless p >= n + 1. 25// Truncates the result in general unless p >= n + 1.
@@ -51,7 +53,7 @@
51 53
52 54
53S2N_BN_SYMBOL(bignum_cmul): 55S2N_BN_SYMBOL(bignum_cmul):
54 _CET_ENDBR 56 _CET_ENDBR
55 57
56#if WINDOWS_ABI 58#if WINDOWS_ABI
57 push rdi 59 push rdi
@@ -76,7 +78,7 @@ S2N_BN_SYMBOL(bignum_cmul):
76 xor h, h 78 xor h, h
77 xor i, i 79 xor i, i
78 test n, n 80 test n, n
79 jz tail 81 jz bignum_cmul_tail
80 82
81// Move c into a safer register as multiplies overwrite rdx 83// Move c into a safer register as multiplies overwrite rdx
82 84
@@ -90,11 +92,11 @@ S2N_BN_SYMBOL(bignum_cmul):
90 mov h, rdx 92 mov h, rdx
91 inc i 93 inc i
92 cmp i, n 94 cmp i, n
93 jz tail 95 jz bignum_cmul_tail
94 96
95// Main loop doing the multiplications 97// Main loop doing the multiplications
96 98
97loop: 99bignum_cmul_loop:
98 mov rax, [x+8*i] 100 mov rax, [x+8*i]
99 mul c 101 mul c
100 add rax, h 102 add rax, h
@@ -103,28 +105,28 @@ loop:
103 mov h, rdx 105 mov h, rdx
104 inc i 106 inc i
105 cmp i, n 107 cmp i, n
106 jc loop 108 jc bignum_cmul_loop
107 109
108// Add a tail when the destination is longer 110// Add a tail when the destination is longer
109 111
110tail: 112bignum_cmul_tail:
111 cmp i, p 113 cmp i, p
112 jnc end 114 jnc bignum_cmul_end
113 mov [z+8*i], h 115 mov [z+8*i], h
114 xor h, h 116 xor h, h
115 inc i 117 inc i
116 cmp i, p 118 cmp i, p
117 jnc end 119 jnc bignum_cmul_end
118 120
119tloop: 121bignum_cmul_tloop:
120 mov [z+8*i], h 122 mov [z+8*i], h
121 inc i 123 inc i
122 cmp i, p 124 cmp i, p
123 jc tloop 125 jc bignum_cmul_tloop
124 126
125// Return the high/carry word 127// Return the high/carry word
126 128
127end: 129bignum_cmul_end:
128 mov rax, h 130 mov rax, h
129 131
130#if WINDOWS_ABI 132#if WINDOWS_ABI
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_modadd.S b/src/lib/libcrypto/bn/arch/amd64/bignum_modadd.S
new file mode 100644
index 0000000000..baf27fdc7f
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_modadd.S
@@ -0,0 +1,112 @@
1// $OpenBSD: bignum_modadd.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Add modulo m, z := (x + y) mod m, assuming x and y reduced
19// Inputs x[k], y[k], m[k]; output z[k]
20//
21// extern void bignum_modadd(uint64_t k, uint64_t *z, const uint64_t *x,
22// const uint64_t *y, const uint64_t *m);
23//
24// Standard x86-64 ABI: RDI = k, RSI = z, RDX = x, RCX = y, R8 = m
25// Microsoft x64 ABI: RCX = k, RDX = z, R8 = x, R9 = y, [RSP+40] = m
26// ----------------------------------------------------------------------------
27
28#include "s2n_bignum_internal.h"
29
30 .intel_syntax noprefix
31 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_modadd)
32 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_modadd)
33 .text
34
35#define k rdi
36#define z rsi
37#define x rdx
38#define y rcx
39#define m r8
40#define i r9
41#define j r10
42#define a rax
43#define c r11
44
45S2N_BN_SYMBOL(bignum_modadd):
46 _CET_ENDBR
47
48#if WINDOWS_ABI
49 push rdi
50 push rsi
51 mov rdi, rcx
52 mov rsi, rdx
53 mov rdx, r8
54 mov rcx, r9
55 mov r8, [rsp+56]
56#endif
57
58// If k = 0 do nothing
59
60 test k, k
61 jz bignum_modadd_end
62
63// First just add (c::z) := x + y
64
65 xor c, c
66 mov j, k
67 xor i, i
68bignum_modadd_addloop:
69 mov a, [x+8*i]
70 adc a, [y+8*i]
71 mov [z+8*i], a
72 inc i
73 dec j
74 jnz bignum_modadd_addloop
75 adc c, 0
76
77// Now do a comparison subtraction (c::z) - m, recording mask for (c::z) >= m
78
79 mov j, k
80 xor i, i
81bignum_modadd_cmploop:
82 mov a, [z+8*i]
83 sbb a, [m+8*i]
84 inc i
85 dec j
86 jnz bignum_modadd_cmploop
87 sbb c, 0
88 not c
89
90// Now do a masked subtraction z := z - [c] * m
91
92 xor i, i
93bignum_modadd_subloop:
94 mov a, [m+8*i]
95 and a, c
96 neg j
97 sbb [z+8*i], a
98 sbb j, j
99 inc i
100 cmp i, k
101 jc bignum_modadd_subloop
102
103bignum_modadd_end:
104#if WINDOWS_ABI
105 pop rsi
106 pop rdi
107#endif
108 ret
109
110#if defined(__linux__) && defined(__ELF__)
111.section .note.GNU-stack,"",%progbits
112#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_modsub.S b/src/lib/libcrypto/bn/arch/amd64/bignum_modsub.S
new file mode 100644
index 0000000000..63b3230e35
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_modsub.S
@@ -0,0 +1,99 @@
1// $OpenBSD: bignum_modsub.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Subtract modulo m, z := (x - y) mod m, assuming x and y reduced
19// Inputs x[k], y[k], m[k]; output z[k]
20//
21// extern void bignum_modsub(uint64_t k, uint64_t *z, const uint64_t *x,
22// const uint64_t *y, const uint64_t *m);
23//
24// Standard x86-64 ABI: RDI = k, RSI = z, RDX = x, RCX = y, R8 = m
25// Microsoft x64 ABI: RCX = k, RDX = z, R8 = x, R9 = y, [RSP+40] = m
26// ----------------------------------------------------------------------------
27
28#include "s2n_bignum_internal.h"
29
30 .intel_syntax noprefix
31 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_modsub)
32 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_modsub)
33 .text
34
35#define k rdi
36#define z rsi
37#define x rdx
38#define y rcx
39#define m r8
40#define i r9
41#define j r10
42#define a rax
43#define c r11
44
45S2N_BN_SYMBOL(bignum_modsub):
46 _CET_ENDBR
47
48#if WINDOWS_ABI
49 push rdi
50 push rsi
51 mov rdi, rcx
52 mov rsi, rdx
53 mov rdx, r8
54 mov rcx, r9
55 mov r8, [rsp+56]
56#endif
57
58// If k = 0 do nothing
59
60 test k, k
61 jz bignum_modsub_end
62
63// Subtract z := x - y and record a mask for the carry x - y < 0
64
65 xor c, c
66 mov j, k
67 xor i, i
68bignum_modsub_subloop:
69 mov a, [x+8*i]
70 sbb a, [y+8*i]
71 mov [z+8*i], a
72 inc i
73 dec j
74 jnz bignum_modsub_subloop
75 sbb c, c
76
77// Now do a masked addition z := z + [c] * m
78
79 xor i, i
80bignum_modsub_addloop:
81 mov a, [m+8*i]
82 and a, c
83 neg j
84 adc [z+8*i], a
85 sbb j, j
86 inc i
87 cmp i, k
88 jc bignum_modsub_addloop
89
90bignum_modsub_end:
91#if WINDOWS_ABI
92 pop rsi
93 pop rdi
94#endif
95 ret
96
97#if defined(__linux__) && defined(__ELF__)
98.section .note.GNU-stack,"",%progbits
99#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S
index a3552679a2..538cce9af7 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_mul.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,9 +18,8 @@
16// Multiply z := x * y 18// Multiply z := x * y
17// Inputs x[m], y[n]; output z[k] 19// Inputs x[m], y[n]; output z[k]
18// 20//
19// extern void bignum_mul 21// extern void bignum_mul(uint64_t k, uint64_t *z, uint64_t m, const uint64_t *x,
20// (uint64_t k, uint64_t *z, 22// uint64_t n, const uint64_t *y);
21// uint64_t m, uint64_t *x, uint64_t n, uint64_t *y);
22// 23//
23// Does the "z := x * y" operation where x is m digits, y is n, result z is k. 24// Does the "z := x * y" operation where x is m digits, y is n, result z is k.
24// Truncates the result in general unless k >= m + n 25// Truncates the result in general unless k >= m + n
@@ -59,7 +60,7 @@
59 60
60 61
61S2N_BN_SYMBOL(bignum_mul): 62S2N_BN_SYMBOL(bignum_mul):
62 _CET_ENDBR 63 _CET_ENDBR
63 64
64#if WINDOWS_ABI 65#if WINDOWS_ABI
65 push rdi 66 push rdi
@@ -88,7 +89,7 @@ S2N_BN_SYMBOL(bignum_mul):
88// If we did a multiply-add variant, however, then we could 89// If we did a multiply-add variant, however, then we could
89 90
90 test p, p 91 test p, p
91 jz end 92 jz bignum_mul_end
92 93
93// Set initial 2-part sum to zero (we zero c inside the body) 94// Set initial 2-part sum to zero (we zero c inside the body)
94 95
@@ -99,7 +100,7 @@ S2N_BN_SYMBOL(bignum_mul):
99 100
100 xor k, k 101 xor k, k
101 102
102outerloop: 103bignum_mul_outerloop:
103 104
104// Zero our carry term first; we eventually want it and a zero is useful now 105// Zero our carry term first; we eventually want it and a zero is useful now
105// Set a = max 0 (k + 1 - n), i = min (k + 1) m 106// Set a = max 0 (k + 1 - n), i = min (k + 1) m
@@ -125,11 +126,11 @@ outerloop:
125 mov d, k 126 mov d, k
126 sub d, i 127 sub d, i
127 sub i, a 128 sub i, a
128 jbe innerend 129 jbe bignum_mul_innerend
129 lea x,[rcx+8*a] 130 lea x,[rcx+8*a]
130 lea y,[r9+8*d-8] 131 lea y,[r9+8*d-8]
131 132
132innerloop: 133bignum_mul_innerloop:
133 mov rax, [y+8*i] 134 mov rax, [y+8*i]
134 mul QWORD PTR [x] 135 mul QWORD PTR [x]
135 add x, 8 136 add x, 8
@@ -137,9 +138,9 @@ innerloop:
137 adc h, rdx 138 adc h, rdx
138 adc c, 0 139 adc c, 0
139 dec i 140 dec i
140 jnz innerloop 141 jnz bignum_mul_innerloop
141 142
142innerend: 143bignum_mul_innerend:
143 144
144 mov [z], l 145 mov [z], l
145 mov l, h 146 mov l, h
@@ -147,9 +148,9 @@ innerend:
147 add z, 8 148 add z, 8
148 149
149 cmp k, p 150 cmp k, p
150 jc outerloop 151 jc bignum_mul_outerloop
151 152
152end: 153bignum_mul_end:
153 pop r15 154 pop r15
154 pop r14 155 pop r14
155 pop r13 156 pop r13
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8.S
new file mode 100644
index 0000000000..d6ad514020
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8.S
@@ -0,0 +1,187 @@
1// $OpenBSD: bignum_mul_4_8.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Multiply z := x * y
19// Inputs x[4], y[4]; output z[8]
20//
21// extern void bignum_mul_4_8(uint64_t z[static 8], const uint64_t x[static 4],
22// const uint64_t y[static 4]);
23//
24// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y
25// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y
26// ----------------------------------------------------------------------------
27
28#include "s2n_bignum_internal.h"
29
30 .intel_syntax noprefix
31 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_mul_4_8)
32 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_mul_4_8)
33 .text
34
35// These are actually right
36
37#define z rdi
38#define x rsi
39
40// Copied in or set up
41
42#define y rcx
43
44// A zero register
45
46#define zero rbp
47#define zeroe ebp
48
49// Add in x[i] * rdx to the (i,i+1) position with the register window
50// Would be nice to have conditional expressions reg[i], reg[i+1] ...
51
52.macro mulpadd arg1,arg2
53 mulx rbx, rax, [x+8*\arg2]
54.if ((\arg1 + \arg2) % 4 == 0)
55 adcx r8, rax
56 adox r9, rbx
57.elseif ((\arg1 + \arg2) % 4 == 1)
58 adcx r9, rax
59 adox r10, rbx
60.elseif ((\arg1 + \arg2) % 4 == 2)
61 adcx r10, rax
62 adox r11, rbx
63.elseif ((\arg1 + \arg2) % 4 == 3)
64 adcx r11, rax
65 adox r8, rbx
66.endif
67
68.endm
69
70
71// Add in the whole j'th row
72
73.macro addrow arg1
74 mov rdx, [y+8*\arg1]
75 xor zeroe, zeroe
76
77 mulpadd \arg1, 0
78
79.if (\arg1 % 4 == 0)
80 mov [z+8*\arg1],r8
81.elseif (\arg1 % 4 == 1)
82 mov [z+8*\arg1],r9
83.elseif (\arg1 % 4 == 2)
84 mov [z+8*\arg1],r10
85.elseif (\arg1 % 4 == 3)
86 mov [z+8*\arg1],r11
87.endif
88
89 mulpadd \arg1, 1
90 mulpadd \arg1, 2
91
92.if (\arg1 % 4 == 0)
93 mulx r8, rax, [x+24]
94 adcx r11, rax
95 adox r8, zero
96 adcx r8, zero
97.elseif (\arg1 % 4 == 1)
98 mulx r9, rax, [x+24]
99 adcx r8, rax
100 adox r9, zero
101 adcx r9, zero
102.elseif (\arg1 % 4 == 2)
103 mulx r10, rax, [x+24]
104 adcx r9, rax
105 adox r10, zero
106 adcx r10, zero
107.elseif (\arg1 % 4 == 3)
108 mulx r11, rax, [x+24]
109 adcx r10, rax
110 adox r11, zero
111 adcx r11, zero
112.endif
113
114.endm
115
116
117
118S2N_BN_SYMBOL(bignum_mul_4_8):
119 _CET_ENDBR
120
121#if WINDOWS_ABI
122 push rdi
123 push rsi
124 mov rdi, rcx
125 mov rsi, rdx
126 mov rdx, r8
127#endif
128
129// Save more registers to play with
130
131 push rbp
132 push rbx
133
134// Copy y into a safe register to start with
135
136 mov y, rdx
137
138// Zero a register, which also makes sure we don't get a fake carry-in
139
140 xor zeroe, zeroe
141
142// Do the zeroth row, which is a bit different
143// Write back the zero-zero product and then accumulate
144// r8,r11,r10,r9 as y[0] * x from 1..4
145
146 mov rdx, [y]
147
148 mulx r9, r8, [x]
149 mov [z], r8
150
151 mulx r10, rbx, [x+8]
152 adcx r9, rbx
153
154 mulx r11, rbx, [x+16]
155 adcx r10, rbx
156
157 mulx r8, rbx, [x+24]
158 adcx r11, rbx
159 adcx r8, zero
160
161// Now all the other rows in a uniform pattern
162
163 addrow 1
164 addrow 2
165 addrow 3
166
167// Now write back the additional columns
168
169 mov [z+32], r8
170 mov [z+40], r9
171 mov [z+48], r10
172 mov [z+56], r11
173
174// Restore registers and return
175
176 pop rbx
177 pop rbp
178
179#if WINDOWS_ABI
180 pop rsi
181 pop rdi
182#endif
183 ret
184
185#if defined(__linux__) && defined(__ELF__)
186.section .note.GNU-stack,"",%progbits
187#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S
index 70ff69e372..2592d1d658 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_mul_4_8_alt.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,8 +18,8 @@
16// Multiply z := x * y 18// Multiply z := x * y
17// Inputs x[4], y[4]; output z[8] 19// Inputs x[4], y[4]; output z[8]
18// 20//
19// extern void bignum_mul_4_8_alt 21// extern void bignum_mul_4_8_alt(uint64_t z[static 8], const uint64_t x[static 4],
20// (uint64_t z[static 8], uint64_t x[static 4], uint64_t y[static 4]); 22// const uint64_t y[static 4]);
21// 23//
22// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y 24// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y
23// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y 25// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y
@@ -72,7 +74,7 @@
72 adc h, rdx 74 adc h, rdx
73 75
74S2N_BN_SYMBOL(bignum_mul_4_8_alt): 76S2N_BN_SYMBOL(bignum_mul_4_8_alt):
75 _CET_ENDBR 77 _CET_ENDBR
76 78
77#if WINDOWS_ABI 79#if WINDOWS_ABI
78 push rdi 80 push rdi
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12.S
new file mode 100644
index 0000000000..56cbdf06e0
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12.S
@@ -0,0 +1,223 @@
1// $OpenBSD: bignum_mul_6_12.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Multiply z := x * y
19// Inputs x[6], y[6]; output z[12]
20//
21// extern void bignum_mul_6_12(uint64_t z[static 12], const uint64_t x[static 6],
22// const uint64_t y[static 6]);
23//
24// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y
25// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y
26// ----------------------------------------------------------------------------
27
28#include "s2n_bignum_internal.h"
29
30 .intel_syntax noprefix
31 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_mul_6_12)
32 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_mul_6_12)
33 .text
34
35// These are actually right
36
37#define z rdi
38#define x rsi
39
40// Copied in or set up
41
42#define y rcx
43
44// A zero register
45
46#define zero rbp
47#define zeroe ebp
48
49// Add in x[i] * rdx to the (i,i+1) position with the register window
50// Would be nice to have conditional expressions reg[i], reg[i+1] ...
51
52.macro mulpadd arg1,arg2
53 mulx rbx, rax, [x+8*\arg2]
54.if ((\arg1 + \arg2) % 6 == 0)
55 adcx r8, rax
56 adox r9, rbx
57.elseif ((\arg1 + \arg2) % 6 == 1)
58 adcx r9, rax
59 adox r10, rbx
60.elseif ((\arg1 + \arg2) % 6 == 2)
61 adcx r10, rax
62 adox r11, rbx
63.elseif ((\arg1 + \arg2) % 6 == 3)
64 adcx r11, rax
65 adox r12, rbx
66.elseif ((\arg1 + \arg2) % 6 == 4)
67 adcx r12, rax
68 adox r13, rbx
69.elseif ((\arg1 + \arg2) % 6 == 5)
70 adcx r13, rax
71 adox r8, rbx
72.endif
73
74.endm
75
76
77// Add in the whole j'th row
78
79.macro addrow arg1
80 mov rdx, [y+8*\arg1]
81 xor zeroe, zeroe
82
83 mulpadd \arg1, 0
84
85.if (\arg1 % 6 == 0)
86 mov [z+8*\arg1],r8
87.elseif (\arg1 % 6 == 1)
88 mov [z+8*\arg1],r9
89.elseif (\arg1 % 6 == 2)
90 mov [z+8*\arg1],r10
91.elseif (\arg1 % 6 == 3)
92 mov [z+8*\arg1],r11
93.elseif (\arg1 % 6 == 4)
94 mov [z+8*\arg1],r12
95.elseif (\arg1 % 6 == 5)
96 mov [z+8*\arg1],r13
97.endif
98
99 mulpadd \arg1, 1
100 mulpadd \arg1, 2
101 mulpadd \arg1, 3
102 mulpadd \arg1, 4
103
104.if (\arg1 % 6 == 0)
105 mulx r8, rax, [x+40]
106 adcx r13, rax
107 adox r8, zero
108 adcx r8, zero
109.elseif (\arg1 % 6 == 1)
110 mulx r9, rax, [x+40]
111 adcx r8, rax
112 adox r9, zero
113 adcx r9, zero
114.elseif (\arg1 % 6 == 2)
115 mulx r10, rax, [x+40]
116 adcx r9, rax
117 adox r10, zero
118 adcx r10, zero
119.elseif (\arg1 % 6 == 3)
120 mulx r11, rax, [x+40]
121 adcx r10, rax
122 adox r11, zero
123 adcx r11, zero
124.elseif (\arg1 % 6 == 4)
125 mulx r12, rax, [x+40]
126 adcx r11, rax
127 adox r12, zero
128 adcx r12, zero
129.elseif (\arg1 % 6 == 5)
130 mulx r13, rax, [x+40]
131 adcx r12, rax
132 adox r13, zero
133 adcx r13, zero
134.endif
135
136.endm
137
138
139
140S2N_BN_SYMBOL(bignum_mul_6_12):
141 _CET_ENDBR
142
143#if WINDOWS_ABI
144 push rdi
145 push rsi
146 mov rdi, rcx
147 mov rsi, rdx
148 mov rdx, r8
149#endif
150
151// Save more registers to play with
152
153 push rbp
154 push rbx
155 push r12
156 push r13
157
158// Copy y into a safe register to start with
159
160 mov y, rdx
161
162// Zero a register, which also makes sure we don't get a fake carry-in
163
164 xor zeroe, zeroe
165
166// Do the zeroth row, which is a bit different
167// Write back the zero-zero product and then accumulate
168// r8,r13,r12,r11,r10,r9 as y[0] * x from 1..6
169
170 mov rdx, [y]
171
172 mulx r9, r8, [x]
173 mov [z], r8
174
175 mulx r10, rbx, [x+8]
176 adcx r9, rbx
177
178 mulx r11, rbx, [x+16]
179 adcx r10, rbx
180
181 mulx r12, rbx, [x+24]
182 adcx r11, rbx
183
184 mulx r13, rbx, [x+32]
185 adcx r12, rbx
186
187 mulx r8, rbx, [x+40]
188 adcx r13, rbx
189 adcx r8, zero
190
191// Now all the other rows in a uniform pattern
192
193 addrow 1
194 addrow 2
195 addrow 3
196 addrow 4
197 addrow 5
198
199// Now write back the additional columns
200
201 mov [z+48], r8
202 mov [z+56], r9
203 mov [z+64], r10
204 mov [z+72], r11
205 mov [z+80], r12
206 mov [z+88], r13
207
208// Restore registers and return
209
210 pop r13
211 pop r12
212 pop rbx
213 pop rbp
214
215#if WINDOWS_ABI
216 pop rsi
217 pop rdi
218#endif
219 ret
220
221#if defined(__linux__) && defined(__ELF__)
222.section .note.GNU-stack,"",%progbits
223#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12_alt.S
new file mode 100644
index 0000000000..077c52b38e
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_6_12_alt.S
@@ -0,0 +1,199 @@
1// $OpenBSD: bignum_mul_6_12_alt.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Multiply z := x * y
19// Inputs x[6], y[6]; output z[12]
20//
21// extern void bignum_mul_6_12_alt(uint64_t z[static 12],
22// const uint64_t x[static 6],
23// const uint64_t y[static 6]);
24//
25// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y
26// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y
27// ----------------------------------------------------------------------------
28
29#include "s2n_bignum_internal.h"
30
31 .intel_syntax noprefix
32 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_mul_6_12_alt)
33 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_mul_6_12_alt)
34 .text
35
36// These are actually right
37
38#define z rdi
39#define x rsi
40
41// This is moved from rdx to free it for muls
42
43#define y rcx
44
45// Other variables used as a rotating 3-word window to add terms to
46
47#define t0 r8
48#define t1 r9
49#define t2 r10
50
51// Macro for the key "multiply and add to (c,h,l)" step
52
53#define combadd(c,h,l,numa,numb) \
54 mov rax, numa; \
55 mul QWORD PTR numb; \
56 add l, rax; \
57 adc h, rdx; \
58 adc c, 0
59
60// A minutely shorter form for when c = 0 initially
61
62#define combadz(c,h,l,numa,numb) \
63 mov rax, numa; \
64 mul QWORD PTR numb; \
65 add l, rax; \
66 adc h, rdx; \
67 adc c, c
68
69// A short form where we don't expect a top carry
70
71#define combads(h,l,numa,numb) \
72 mov rax, numa; \
73 mul QWORD PTR numb; \
74 add l, rax; \
75 adc h, rdx
76
77S2N_BN_SYMBOL(bignum_mul_6_12_alt):
78 _CET_ENDBR
79
80#if WINDOWS_ABI
81 push rdi
82 push rsi
83 mov rdi, rcx
84 mov rsi, rdx
85 mov rdx, r8
86#endif
87
88// Copy y into a safe register to start with
89
90 mov y, rdx
91
92// Result term 0
93
94 mov rax, [x]
95 mul QWORD PTR [y]
96
97 mov [z], rax
98 mov t0, rdx
99 xor t1, t1
100
101// Result term 1
102
103 xor t2, t2
104 combads(t1,t0,[x],[y+8])
105 combadz(t2,t1,t0,[x+8],[y])
106 mov [z+8], t0
107
108// Result term 2
109
110 xor t0, t0
111 combadz(t0,t2,t1,[x],[y+16])
112 combadd(t0,t2,t1,[x+8],[y+8])
113 combadd(t0,t2,t1,[x+16],[y])
114 mov [z+16], t1
115
116// Result term 3
117
118 xor t1, t1
119 combadz(t1,t0,t2,[x],[y+24])
120 combadd(t1,t0,t2,[x+8],[y+16])
121 combadd(t1,t0,t2,[x+16],[y+8])
122 combadd(t1,t0,t2,[x+24],[y])
123 mov [z+24], t2
124
125// Result term 4
126
127 xor t2, t2
128 combadz(t2,t1,t0,[x],[y+32])
129 combadd(t2,t1,t0,[x+8],[y+24])
130 combadd(t2,t1,t0,[x+16],[y+16])
131 combadd(t2,t1,t0,[x+24],[y+8])
132 combadd(t2,t1,t0,[x+32],[y])
133 mov [z+32], t0
134
135// Result term 5
136
137 xor t0, t0
138 combadz(t0,t2,t1,[x],[y+40])
139 combadd(t0,t2,t1,[x+8],[y+32])
140 combadd(t0,t2,t1,[x+16],[y+24])
141 combadd(t0,t2,t1,[x+24],[y+16])
142 combadd(t0,t2,t1,[x+32],[y+8])
143 combadd(t0,t2,t1,[x+40],[y])
144 mov [z+40], t1
145
146// Result term 6
147
148 xor t1, t1
149 combadz(t1,t0,t2,[x+8],[y+40])
150 combadd(t1,t0,t2,[x+16],[y+32])
151 combadd(t1,t0,t2,[x+24],[y+24])
152 combadd(t1,t0,t2,[x+32],[y+16])
153 combadd(t1,t0,t2,[x+40],[y+8])
154 mov [z+48], t2
155
156// Result term 7
157
158 xor t2, t2
159 combadz(t2,t1,t0,[x+16],[y+40])
160 combadd(t2,t1,t0,[x+24],[y+32])
161 combadd(t2,t1,t0,[x+32],[y+24])
162 combadd(t2,t1,t0,[x+40],[y+16])
163 mov [z+56], t0
164
165// Result term 8
166
167 xor t0, t0
168 combadz(t0,t2,t1,[x+24],[y+40])
169 combadd(t0,t2,t1,[x+32],[y+32])
170 combadd(t0,t2,t1,[x+40],[y+24])
171 mov [z+64], t1
172
173// Result term 9
174
175 xor t1, t1
176 combadz(t1,t0,t2,[x+32],[y+40])
177 combadd(t1,t0,t2,[x+40],[y+32])
178 mov [z+72], t2
179
180// Result term 10
181
182 combads(t1,t0,[x+40],[y+40])
183 mov [z+80], t0
184
185// Result term 11
186
187 mov [z+88], t1
188
189// Return
190
191#if WINDOWS_ABI
192 pop rsi
193 pop rdi
194#endif
195 ret
196
197#if defined(__linux__) && defined(__ELF__)
198.section .note.GNU-stack,"",%progbits
199#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16.S
new file mode 100644
index 0000000000..faa0196d8e
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16.S
@@ -0,0 +1,273 @@
1// $OpenBSD: bignum_mul_8_16.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Multiply z := x * y
19// Inputs x[8], y[8]; output z[16]
20//
21// extern void bignum_mul_8_16(uint64_t z[static 16], const uint64_t x[static 8],
22// const uint64_t y[static 8]);
23//
24// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y
25// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y
26// ----------------------------------------------------------------------------
27
28#include "s2n_bignum_internal.h"
29
30 .intel_syntax noprefix
31 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_mul_8_16)
32 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_mul_8_16)
33 .text
34
35// These are actually right
36
37#define z rdi
38#define x rsi
39
40// Copied in or set up
41
42#define y rcx
43
44// A zero register
45
46#define zero rbp
47#define zeroe ebp
48
49// mulpadd i, j adds x[i] * rdx (now assumed = y[j]) into the window at i+j
50
51.macro mulpadd arg1,arg2
52 mulx rbx, rax, [x+8*\arg1]
53.if ((\arg1 + \arg2) % 8 == 0)
54 adcx r8, rax
55 adox r9, rbx
56.elseif ((\arg1 + \arg2) % 8 == 1)
57 adcx r9, rax
58 adox r10, rbx
59.elseif ((\arg1 + \arg2) % 8 == 2)
60 adcx r10, rax
61 adox r11, rbx
62.elseif ((\arg1 + \arg2) % 8 == 3)
63 adcx r11, rax
64 adox r12, rbx
65.elseif ((\arg1 + \arg2) % 8 == 4)
66 adcx r12, rax
67 adox r13, rbx
68.elseif ((\arg1 + \arg2) % 8 == 5)
69 adcx r13, rax
70 adox r14, rbx
71.elseif ((\arg1 + \arg2) % 8 == 6)
72 adcx r14, rax
73 adox r15, rbx
74.elseif ((\arg1 + \arg2) % 8 == 7)
75 adcx r15, rax
76 adox r8, rbx
77.endif
78
79.endm
80
81// mulpade i, j adds x[i] * rdx (now assumed = y[j]) into the window at i+j
82// but re-creates the top word assuming nothing to add there
83
84.macro mulpade arg1,arg2
85.if ((\arg1 + \arg2) % 8 == 0)
86 mulx r9, rax, [x+8*\arg1]
87 adcx r8, rax
88 adox r9, zero
89.elseif ((\arg1 + \arg2) % 8 == 1)
90 mulx r10, rax, [x+8*\arg1]
91 adcx r9, rax
92 adox r10, zero
93.elseif ((\arg1 + \arg2) % 8 == 2)
94 mulx r11, rax, [x+8*\arg1]
95 adcx r10, rax
96 adox r11, zero
97.elseif ((\arg1 + \arg2) % 8 == 3)
98 mulx r12, rax, [x+8*\arg1]
99 adcx r11, rax
100 adox r12, zero
101.elseif ((\arg1 + \arg2) % 8 == 4)
102 mulx r13, rax, [x+8*\arg1]
103 adcx r12, rax
104 adox r13, zero
105.elseif ((\arg1 + \arg2) % 8 == 5)
106 mulx r14, rax, [x+8*\arg1]
107 adcx r13, rax
108 adox r14, zero
109.elseif ((\arg1 + \arg2) % 8 == 6)
110 mulx r15, rax, [x+8*\arg1]
111 adcx r14, rax
112 adox r15, zero
113.elseif ((\arg1 + \arg2) % 8 == 7)
114 mulx r8, rax, [x+8*\arg1]
115 adcx r15, rax
116 adox r8, zero
117.endif
118
119.endm
120
121// Add in the whole j'th row
122
123.macro addrow arg1
124 mov rdx, [y+8*\arg1]
125 xor zeroe, zeroe
126
127 mulpadd 0, \arg1
128
129.if (\arg1 % 8 == 0)
130 mov [z+8*\arg1],r8
131.elseif (\arg1 % 8 == 1)
132 mov [z+8*\arg1],r9
133.elseif (\arg1 % 8 == 2)
134 mov [z+8*\arg1],r10
135.elseif (\arg1 % 8 == 3)
136 mov [z+8*\arg1],r11
137.elseif (\arg1 % 8 == 4)
138 mov [z+8*\arg1],r12
139.elseif (\arg1 % 8 == 5)
140 mov [z+8*\arg1],r13
141.elseif (\arg1 % 8 == 6)
142 mov [z+8*\arg1],r14
143.elseif (\arg1 % 8 == 7)
144 mov [z+8*\arg1],r15
145.endif
146
147 mulpadd 1, \arg1
148 mulpadd 2, \arg1
149 mulpadd 3, \arg1
150 mulpadd 4, \arg1
151 mulpadd 5, \arg1
152 mulpadd 6, \arg1
153 mulpade 7, \arg1
154
155.if (\arg1 % 8 == 0)
156 adc r8, zero
157.elseif (\arg1 % 8 == 1)
158 adc r9, zero
159.elseif (\arg1 % 8 == 2)
160 adc r10, zero
161.elseif (\arg1 % 8 == 3)
162 adc r11, zero
163.elseif (\arg1 % 8 == 4)
164 adc r12, zero
165.elseif (\arg1 % 8 == 5)
166 adc r13, zero
167.elseif (\arg1 % 8 == 6)
168 adc r14, zero
169.elseif (\arg1 % 8 == 7)
170 adc r15, zero
171.endif
172
173.endm
174
175
176S2N_BN_SYMBOL(bignum_mul_8_16):
177 _CET_ENDBR
178
179#if WINDOWS_ABI
180 push rdi
181 push rsi
182 mov rdi, rcx
183 mov rsi, rdx
184 mov rdx, r8
185#endif
186
187// Save more registers to play with
188
189 push rbp
190 push rbx
191 push r12
192 push r13
193 push r14
194 push r15
195
196// Copy y into a safe register to start with
197
198 mov y, rdx
199
200// Zero a register, which also makes sure we don't get a fake carry-in
201
202 xor zeroe, zeroe
203
204// Do the zeroth row, which is a bit different
205// Write back the zero-zero product and then accumulate
206// r8,r15,r14,r13,r12,r11,r10,r9 as y[0] * x from 1..8
207
208 mov rdx, [y]
209
210 mulx r9, r8, [x]
211 mov [z], r8
212
213 mulx r10, rbx, [x+8]
214 adc r9, rbx
215
216 mulx r11, rbx, [x+16]
217 adc r10, rbx
218
219 mulx r12, rbx, [x+24]
220 adc r11, rbx
221
222 mulx r13, rbx, [x+32]
223 adc r12, rbx
224
225 mulx r14, rbx, [x+40]
226 adc r13, rbx
227
228 mulx r15, rbx, [x+48]
229 adc r14, rbx
230
231 mulx r8, rbx, [x+56]
232 adc r15, rbx
233 adc r8, zero
234
235// Now all the other rows in a uniform pattern
236
237 addrow 1
238 addrow 2
239 addrow 3
240 addrow 4
241 addrow 5
242 addrow 6
243 addrow 7
244
245// Now write back the additional columns
246
247 mov [z+64], r8
248 mov [z+72], r9
249 mov [z+80], r10
250 mov [z+88], r11
251 mov [z+96], r12
252 mov [z+104], r13
253 mov [z+112], r14
254 mov [z+120], r15
255
256// Real epilog
257
258 pop r15
259 pop r14
260 pop r13
261 pop r12
262 pop rbx
263 pop rbp
264
265#if WINDOWS_ABI
266 pop rsi
267 pop rdi
268#endif
269 ret
270
271#if defined(__linux__) && defined(__ELF__)
272.section .note.GNU-stack,"",%progbits
273#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S
index 066403b074..0e30b9170f 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_mul_8_16_alt.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,8 +18,9 @@
16// Multiply z := x * y 18// Multiply z := x * y
17// Inputs x[8], y[8]; output z[16] 19// Inputs x[8], y[8]; output z[16]
18// 20//
19// extern void bignum_mul_8_16_alt 21// extern void bignum_mul_8_16_alt(uint64_t z[static 16],
20// (uint64_t z[static 16], uint64_t x[static 8], uint64_t y[static 8]); 22// const uint64_t x[static 8],
23// const uint64_t y[static 8]);
21// 24//
22// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y 25// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y
23// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y 26// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y
@@ -72,7 +75,7 @@
72 adc h, rdx 75 adc h, rdx
73 76
74S2N_BN_SYMBOL(bignum_mul_8_16_alt): 77S2N_BN_SYMBOL(bignum_mul_8_16_alt):
75 _CET_ENDBR 78 _CET_ENDBR
76 79
77#if WINDOWS_ABI 80#if WINDOWS_ABI
78 push rdi 81 push rdi
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S
index 54e3f59442..86f1af2ac4 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_sqr.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,8 +18,7 @@
16// Square z := x^2 18// Square z := x^2
17// Input x[n]; output z[k] 19// Input x[n]; output z[k]
18// 20//
19// extern void bignum_sqr 21// extern void bignum_sqr(uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x);
20// (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x);
21// 22//
22// Does the "z := x^2" operation where x is n digits and result z is k. 23// Does the "z := x^2" operation where x is n digits and result z is k.
23// Truncates the result in general unless k >= 2 * n 24// Truncates the result in general unless k >= 2 * n
@@ -62,7 +63,7 @@
62#define llshort ebp 63#define llshort ebp
63 64
64S2N_BN_SYMBOL(bignum_sqr): 65S2N_BN_SYMBOL(bignum_sqr):
65 _CET_ENDBR 66 _CET_ENDBR
66 67
67#if WINDOWS_ABI 68#if WINDOWS_ABI
68 push rdi 69 push rdi
@@ -86,7 +87,7 @@ S2N_BN_SYMBOL(bignum_sqr):
86// If p = 0 the result is trivial and nothing needs doing 87// If p = 0 the result is trivial and nothing needs doing
87 88
88 test p, p 89 test p, p
89 jz end 90 jz bignum_sqr_end
90 91
91// initialize (hh,ll) = 0 92// initialize (hh,ll) = 0
92 93
@@ -97,7 +98,7 @@ S2N_BN_SYMBOL(bignum_sqr):
97 98
98 xor k, k 99 xor k, k
99 100
100outerloop: 101bignum_sqr_outerloop:
101 102
102// First let bot = MAX 0 (k + 1 - n) and top = MIN (k + 1) n 103// First let bot = MAX 0 (k + 1 - n) and top = MIN (k + 1) n
103// We want to accumulate all x[i] * x[k - i] for bot <= i < top 104// We want to accumulate all x[i] * x[k - i] for bot <= i < top
@@ -122,7 +123,7 @@ outerloop:
122// If htop <= bot then main doubled part of the sum is empty 123// If htop <= bot then main doubled part of the sum is empty
123 124
124 cmp i, htop 125 cmp i, htop
125 jnc nosumming 126 jnc bignum_sqr_nosumming
126 127
127// Use a moving pointer for [y] = x[k-i] for the cofactor 128// Use a moving pointer for [y] = x[k-i] for the cofactor
128 129
@@ -132,7 +133,7 @@ outerloop:
132 133
133// Do the main part of the sum x[i] * x[k - i] for 2 * i < k 134// Do the main part of the sum x[i] * x[k - i] for 2 * i < k
134 135
135innerloop: 136bignum_sqr_innerloop:
136 mov a, [x+8*i] 137 mov a, [x+8*i]
137 mul QWORD PTR [y] 138 mul QWORD PTR [y]
138 add l, a 139 add l, a
@@ -141,7 +142,7 @@ innerloop:
141 sub y, 8 142 sub y, 8
142 inc i 143 inc i
143 cmp i, htop 144 cmp i, htop
144 jc innerloop 145 jc bignum_sqr_innerloop
145 146
146// Now double it 147// Now double it
147 148
@@ -151,11 +152,11 @@ innerloop:
151 152
152// If k is even (which means 2 * i = k) and i < n add the extra x[i]^2 term 153// If k is even (which means 2 * i = k) and i < n add the extra x[i]^2 term
153 154
154nosumming: 155bignum_sqr_nosumming:
155 test k, 1 156 test k, 1
156 jnz innerend 157 jnz bignum_sqr_innerend
157 cmp i, n 158 cmp i, n
158 jnc innerend 159 jnc bignum_sqr_innerend
159 160
160 mov a, [x+8*i] 161 mov a, [x+8*i]
161 mul a 162 mul a
@@ -165,7 +166,7 @@ nosumming:
165 166
166// Now add the local sum into the global sum, store and shift 167// Now add the local sum into the global sum, store and shift
167 168
168innerend: 169bignum_sqr_innerend:
169 add l, ll 170 add l, ll
170 mov [z+8*k], l 171 mov [z+8*k], l
171 adc h, hh 172 adc h, hh
@@ -175,11 +176,11 @@ innerend:
175 176
176 inc k 177 inc k
177 cmp k, p 178 cmp k, p
178 jc outerloop 179 jc bignum_sqr_outerloop
179 180
180// Restore registers and return 181// Restore registers and return
181 182
182end: 183bignum_sqr_end:
183 pop r15 184 pop r15
184 pop r14 185 pop r14
185 pop r13 186 pop r13
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8.S
new file mode 100644
index 0000000000..25664782f7
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8.S
@@ -0,0 +1,158 @@
1// $OpenBSD: bignum_sqr_4_8.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Square, z := x^2
19// Input x[4]; output z[8]
20//
21// extern void bignum_sqr_4_8(uint64_t z[static 8], const uint64_t x[static 4]);
22//
23// Standard x86-64 ABI: RDI = z, RSI = x
24// Microsoft x64 ABI: RCX = z, RDX = x
25// ----------------------------------------------------------------------------
26
27#include "s2n_bignum_internal.h"
28
29 .intel_syntax noprefix
30 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sqr_4_8)
31 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sqr_4_8)
32 .text
33
34// These are actually right
35
36#define z rdi
37#define x rsi
38
39// A zero register
40
41#define zero rbp
42#define zeroe ebp
43
44// Other registers
45
46#define d1 r8
47#define d2 r9
48#define d3 r10
49#define d4 r11
50#define d5 r12
51#define d6 r13
52
53
54
55S2N_BN_SYMBOL(bignum_sqr_4_8):
56 _CET_ENDBR
57
58#if WINDOWS_ABI
59 push rdi
60 push rsi
61 mov rdi, rcx
62 mov rsi, rdx
63#endif
64
65// Save more registers to play with
66
67 push rbp
68 push r12
69 push r13
70
71// Set up an initial window [d6;...d1] = [23;03;01]
72
73 mov rdx, [x]
74 mulx d2, d1, [x+8]
75 mulx d4, d3, [x+24]
76 mov rdx, [x+16]
77 mulx d6, d5, [x+24]
78
79// Clear our zero register, and also initialize the flags for the carry chain
80
81 xor zeroe, zeroe
82
83// Chain in the addition of 02 + 12 + 13 to that window (no carry-out possible)
84// This gives all the "heterogeneous" terms of the squaring ready to double
85
86 mulx rcx, rax, [x]
87 adcx d2, rax
88 adox d3, rcx
89 mulx rcx, rax, [x+8]
90 adcx d3, rax
91 adox d4, rcx
92 mov rdx, [x+24]
93 mulx rcx, rax, [x+8]
94 adcx d4, rax
95 adox d5, rcx
96 adcx d5, zero
97 adox d6, zero
98 adcx d6, zero
99
100// In principle this is otiose as CF and OF carries are absorbed at this point
101// However it seems helpful for the OOO engine to be told it's a fresh start
102
103 xor zeroe, zeroe
104
105// Double and add to the 00 + 11 + 22 + 33 terms
106//
107// We could use shift-double but this seems tidier and in larger squarings
108// it was actually more efficient. I haven't experimented with this small
109// case to see how much that matters. Note: the writeback here is sprinkled
110// into the sequence in such a way that things still work if z = x, i.e. if
111// the output overwrites the input buffer and beyond.
112
113 mov rdx, [x]
114 mulx rdx, rax, rdx
115 mov [z], rax
116 adcx d1, d1
117 adox d1, rdx
118 mov rdx, [x+8]
119 mov [z+8], d1
120 mulx rdx, rax, rdx
121 adcx d2, d2
122 adox d2, rax
123 adcx d3, d3
124 adox d3, rdx
125 mov rdx, [x+16]
126 mov [z+16], d2
127 mulx rdx, rax, rdx
128 adcx d4, d4
129 adox d4, rax
130 adcx d5, d5
131 adox d5, rdx
132 mov rdx, [x+24]
133 mov [z+24], d3
134 mulx rdx, rax, rdx
135 mov [z+32], d4
136 adcx d6, d6
137 mov [z+40], d5
138 adox d6, rax
139 mov [z+48], d6
140 adcx rdx, zero
141 adox rdx, zero
142 mov [z+56], rdx
143
144// Restore saved registers and return
145
146 pop r13
147 pop r12
148 pop rbp
149
150#if WINDOWS_ABI
151 pop rsi
152 pop rdi
153#endif
154 ret
155
156#if defined(__linux__) && defined(__ELF__)
157.section .note.GNU-stack,"",%progbits
158#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S
index 7c534ae907..7eafac3284 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_sqr_4_8_alt.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,8 +18,8 @@
16// Square, z := x^2 18// Square, z := x^2
17// Input x[4]; output z[8] 19// Input x[4]; output z[8]
18// 20//
19// extern void bignum_sqr_4_8_alt 21// extern void bignum_sqr_4_8_alt(uint64_t z[static 8],
20// (uint64_t z[static 8], uint64_t x[static 4]); 22// const uint64_t x[static 4]);
21// 23//
22// Standard x86-64 ABI: RDI = z, RSI = x 24// Standard x86-64 ABI: RDI = z, RSI = x
23// Microsoft x64 ABI: RCX = z, RDX = x 25// Microsoft x64 ABI: RCX = z, RDX = x
@@ -71,7 +73,7 @@
71 adc c, 0 73 adc c, 0
72 74
73S2N_BN_SYMBOL(bignum_sqr_4_8_alt): 75S2N_BN_SYMBOL(bignum_sqr_4_8_alt):
74 _CET_ENDBR 76 _CET_ENDBR
75 77
76#if WINDOWS_ABI 78#if WINDOWS_ABI
77 push rdi 79 push rdi
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12.S
new file mode 100644
index 0000000000..3f055e8b75
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12.S
@@ -0,0 +1,227 @@
1// $OpenBSD: bignum_sqr_6_12.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Square, z := x^2
19// Input x[6]; output z[12]
20//
21// extern void bignum_sqr_6_12(uint64_t z[static 12], const uint64_t x[static 6]);
22//
23// Standard x86-64 ABI: RDI = z, RSI = x
24// Microsoft x64 ABI: RCX = z, RDX = x
25// ----------------------------------------------------------------------------
26
27#include "s2n_bignum_internal.h"
28
29 .intel_syntax noprefix
30 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sqr_6_12)
31 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sqr_6_12)
32 .text
33
34// These are actually right
35
36#define z rdi
37#define x rsi
38
39// A zero register
40
41#define zero rbp
42#define zeroe ebp
43
44// Other registers
45
46#define d1 r8
47#define d2 r9
48#define d3 r10
49#define d4 r11
50#define d5 r12
51#define d6 r13
52#define d7 r14
53#define d8 r15
54#define d9 rbx
55
56// Care is needed: re-using the zero register
57
58#define d10 rbp
59
60
61S2N_BN_SYMBOL(bignum_sqr_6_12):
62 _CET_ENDBR
63
64#if WINDOWS_ABI
65 push rdi
66 push rsi
67 mov rdi, rcx
68 mov rsi, rdx
69#endif
70
71// Save more registers to play with
72
73 push rbp
74 push rbx
75 push r12
76 push r13
77 push r14
78 push r15
79
80// Set up an initial window [d8;...d1] = [34;05;03;01]
81
82 mov rdx, [x]
83 mulx d2, d1, [x+8]
84 mulx d4, d3, [x+24]
85 mulx d6, d5, [x+40]
86 mov rdx, [x+24]
87 mulx d8, d7, [x+32]
88
89// Clear our zero register, and also initialize the flags for the carry chain
90
91 xor zeroe, zeroe
92
93// Chain in the addition of 02 + 12 + 13 + 14 + 15 to that window
94// (no carry-out possible since we add it to the top of a product)
95
96 mov rdx, [x+16]
97 mulx rcx, rax, [x]
98 adcx d2, rax
99 adox d3, rcx
100 mulx rcx, rax, [x+8]
101 adcx d3, rax
102 adox d4, rcx
103 mov rdx, [x+8]
104 mulx rcx, rax, [x+24]
105 adcx d4, rax
106 adox d5, rcx
107 mulx rcx, rax, [x+32]
108 adcx d5, rax
109 adox d6, rcx
110 mulx rcx, rax, [x+40]
111 adcx d6, rax
112 adox d7, rcx
113 adcx d7, zero
114 adox d8, zero
115 adcx d8, zero
116
117// Again zero out the flags. Actually they are already cleared but it may
118// help decouple these in the OOO engine not to wait for the chain above
119
120 xor zeroe, zeroe
121
122// Now chain in the 04 + 23 + 24 + 25 + 35 + 45 terms
123// We are running out of registers and here our zero register is not zero!
124
125 mov rdx, [x+32]
126 mulx rcx, rax, [x]
127 adcx d4, rax
128 adox d5, rcx
129 mov rdx, [x+16]
130 mulx rcx, rax, [x+24]
131 adcx d5, rax
132 adox d6, rcx
133 mulx rcx, rax, [x+32]
134 adcx d6, rax
135 adox d7, rcx
136 mulx rcx, rax, [x+40]
137 adcx d7, rax
138 adox d8, rcx
139 mov rdx, [x+24]
140 mulx d9, rax, [x+40]
141 adcx d8, rax
142 adox d9, zero
143 mov rdx, [x+32]
144 mulx d10, rax, [x+40]
145 adcx d9, rax
146 mov eax, 0
147 adox d10, rax
148 adcx d10, rax
149
150// Again, just for a clear fresh start for the flags
151
152 xor eax, eax
153
154// Double and add to the 00 + 11 + 22 + 33 + 44 + 55 terms
155//
156// We could use shift-double but this seems tidier and in larger squarings
157// it was actually more efficient. I haven't experimented with this small
158// case to see how much that matters. Note: the writeback here is sprinkled
159// into the sequence in such a way that things still work if z = x, i.e. if
160// the output overwrites the input buffer and beyond.
161
162 mov rdx, [x]
163 mulx rdx, rax, rdx
164 mov [z], rax
165 adcx d1, d1
166 adox d1, rdx
167 mov rdx, [x+8]
168 mov [z+8], d1
169 mulx rdx, rax, rdx
170 adcx d2, d2
171 adox d2, rax
172 adcx d3, d3
173 adox d3, rdx
174 mov rdx, [x+16]
175 mov [z+16], d2
176 mulx rdx, rax, rdx
177 adcx d4, d4
178 adox d4, rax
179 adcx d5, d5
180 adox d5, rdx
181 mov rdx, [x+24]
182 mov [z+24], d3
183 mulx rdx, rax, rdx
184 adcx d6, d6
185 adox d6, rax
186 adcx d7, d7
187 adox d7, rdx
188 mov rdx, [x+32]
189 mov [z+32], d4
190 mulx rdx, rax, rdx
191 adcx d8, d8
192 adox d8, rax
193 adcx d9, d9
194 adox d9, rdx
195 mov rdx, [x+40]
196 mov [z+40], d5
197 mulx rdx, rax, rdx
198 mov [z+48], d6
199 adcx d10, d10
200 mov [z+56], d7
201 adox d10, rax
202 mov [z+64], d8
203 mov eax, 0
204 mov [z+72], d9
205 adcx rdx, rax
206 mov [z+80], d10
207 adox rdx, rax
208 mov [z+88], rdx
209
210// Restore saved registers and return
211
212 pop r15
213 pop r14
214 pop r13
215 pop r12
216 pop rbx
217 pop rbp
218
219#if WINDOWS_ABI
220 pop rsi
221 pop rdi
222#endif
223 ret
224
225#if defined(__linux__) && defined(__ELF__)
226.section .note.GNU-stack,"",%progbits
227#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12_alt.S
new file mode 100644
index 0000000000..eb43b0a15b
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_6_12_alt.S
@@ -0,0 +1,210 @@
1// $OpenBSD: bignum_sqr_6_12_alt.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Square, z := x^2
19// Input x[6]; output z[12]
20//
21// extern void bignum_sqr_6_12_alt(uint64_t z[static 12],
22// const uint64_t x[static 6]);
23//
24// Standard x86-64 ABI: RDI = z, RSI = x
25// Microsoft x64 ABI: RCX = z, RDX = x
26// ----------------------------------------------------------------------------
27
28#include "s2n_bignum_internal.h"
29
30 .intel_syntax noprefix
31 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sqr_6_12_alt)
32 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sqr_6_12_alt)
33 .text
34
35// Input arguments
36
37#define z rdi
38#define x rsi
39
40// Other variables used as a rotating 3-word window to add terms to
41
42#define t0 r8
43#define t1 r9
44#define t2 r10
45
46// Additional temporaries for local windows to share doublings
47
48#define u0 rcx
49#define u1 r11
50
51// Macro for the key "multiply and add to (c,h,l)" step
52
53#define combadd(c,h,l,numa,numb) \
54 mov rax, numa; \
55 mul QWORD PTR numb; \
56 add l, rax; \
57 adc h, rdx; \
58 adc c, 0
59
60// Set up initial window (c,h,l) = numa * numb
61
62#define combaddz(c,h,l,numa,numb) \
63 mov rax, numa; \
64 mul QWORD PTR numb; \
65 xor c, c; \
66 mov l, rax; \
67 mov h, rdx
68
69// Doubling step (c,h,l) = 2 * (c,hh,ll) + (0,h,l)
70
71#define doubladd(c,h,l,hh,ll) \
72 add ll, ll; \
73 adc hh, hh; \
74 adc c, c; \
75 add l, ll; \
76 adc h, hh; \
77 adc c, 0
78
79// Square term incorporation (c,h,l) += numba^2
80
81#define combadd1(c,h,l,numa) \
82 mov rax, numa; \
83 mul rax; \
84 add l, rax; \
85 adc h, rdx; \
86 adc c, 0
87
88// A short form where we don't expect a top carry
89
90#define combads(h,l,numa) \
91 mov rax, numa; \
92 mul rax; \
93 add l, rax; \
94 adc h, rdx
95
96// A version doubling directly before adding, for single non-square terms
97
98#define combadd2(c,h,l,numa,numb) \
99 mov rax, numa; \
100 mul QWORD PTR numb; \
101 add rax, rax; \
102 adc rdx, rdx; \
103 adc c, 0; \
104 add l, rax; \
105 adc h, rdx; \
106 adc c, 0
107
108S2N_BN_SYMBOL(bignum_sqr_6_12_alt):
109 _CET_ENDBR
110
111#if WINDOWS_ABI
112 push rdi
113 push rsi
114 mov rdi, rcx
115 mov rsi, rdx
116#endif
117
118// Result term 0
119
120 mov rax, [x]
121 mul rax
122
123 mov [z], rax
124 mov t0, rdx
125 xor t1, t1
126
127// Result term 1
128
129 xor t2, t2
130 combadd2(t2,t1,t0,[x],[x+8])
131 mov [z+8], t0
132
133// Result term 2
134
135 xor t0, t0
136 combadd1(t0,t2,t1,[x+8])
137 combadd2(t0,t2,t1,[x],[x+16])
138 mov [z+16], t1
139
140// Result term 3
141
142 combaddz(t1,u1,u0,[x],[x+24])
143 combadd(t1,u1,u0,[x+8],[x+16])
144 doubladd(t1,t0,t2,u1,u0)
145 mov [z+24], t2
146
147// Result term 4
148
149 combaddz(t2,u1,u0,[x],[x+32])
150 combadd(t2,u1,u0,[x+8],[x+24])
151 doubladd(t2,t1,t0,u1,u0)
152 combadd1(t2,t1,t0,[x+16])
153 mov [z+32], t0
154
155// Result term 5
156
157 combaddz(t0,u1,u0,[x],[x+40])
158 combadd(t0,u1,u0,[x+8],[x+32])
159 combadd(t0,u1,u0,[x+16],[x+24])
160 doubladd(t0,t2,t1,u1,u0)
161 mov [z+40], t1
162
163// Result term 6
164
165 combaddz(t1,u1,u0,[x+8],[x+40])
166 combadd(t1,u1,u0,[x+16],[x+32])
167 doubladd(t1,t0,t2,u1,u0)
168 combadd1(t1,t0,t2,[x+24])
169 mov [z+48], t2
170
171// Result term 7
172
173 combaddz(t2,u1,u0,[x+16],[x+40])
174 combadd(t2,u1,u0,[x+24],[x+32])
175 doubladd(t2,t1,t0,u1,u0)
176 mov [z+56], t0
177
178// Result term 8
179
180 xor t0, t0
181 combadd2(t0,t2,t1,[x+24],[x+40])
182 combadd1(t0,t2,t1,[x+32])
183 mov [z+64], t1
184
185// Result term 9
186
187 xor t1, t1
188 combadd2(t1,t0,t2,[x+32],[x+40])
189 mov [z+72], t2
190
191// Result term 10
192
193 combads(t1,t0,[x+40])
194 mov [z+80], t0
195
196// Result term 11
197
198 mov [z+88], t1
199
200// Return
201
202#if WINDOWS_ABI
203 pop rsi
204 pop rdi
205#endif
206 ret
207
208#if defined(__linux__) && defined(__ELF__)
209.section .note.GNU-stack,"",%progbits
210#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16.S
new file mode 100644
index 0000000000..41277b5b6a
--- /dev/null
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16.S
@@ -0,0 +1,311 @@
1// $OpenBSD: bignum_sqr_8_16.S,v 1.4 2025/08/12 10:23:40 jsing Exp $
2//
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4//
5// Permission to use, copy, modify, and/or distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// ----------------------------------------------------------------------------
18// Square, z := x^2
19// Input x[8]; output z[16]
20//
21// extern void bignum_sqr_8_16(uint64_t z[static 16], const uint64_t x[static 8]);
22//
23// Standard x86-64 ABI: RDI = z, RSI = x
24// Microsoft x64 ABI: RCX = z, RDX = x
25// ----------------------------------------------------------------------------
26
27#include "s2n_bignum_internal.h"
28
29 .intel_syntax noprefix
30 S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sqr_8_16)
31 S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sqr_8_16)
32 .text
33
34// These are actually right
35
36#define z rdi
37#define x rsi
38
39// A zero register
40
41#define zero rbp
42#define zeroe ebp
43
44// mulpadd i, j adds rdx * x[i] into the window at the i+j point
45
46.macro mulpadd arg1,arg2
47 mulx rcx, rax, [x+8*\arg1]
48.if ((\arg1 + \arg2) % 8 == 0)
49 adcx r8, rax
50 adox r9, rcx
51.elseif ((\arg1 + \arg2) % 8 == 1)
52 adcx r9, rax
53 adox r10, rcx
54.elseif ((\arg1 + \arg2) % 8 == 2)
55 adcx r10, rax
56 adox r11, rcx
57.elseif ((\arg1 + \arg2) % 8 == 3)
58 adcx r11, rax
59 adox r12, rcx
60.elseif ((\arg1 + \arg2) % 8 == 4)
61 adcx r12, rax
62 adox r13, rcx
63.elseif ((\arg1 + \arg2) % 8 == 5)
64 adcx r13, rax
65 adox r14, rcx
66.elseif ((\arg1 + \arg2) % 8 == 6)
67 adcx r14, rax
68 adox r15, rcx
69.elseif ((\arg1 + \arg2) % 8 == 7)
70 adcx r15, rax
71 adox r8, rcx
72.endif
73
74.endm
75
76// mulpade i, j adds rdx * x[i] into the window at i+j
77// but re-creates the top word assuming nothing to add there
78
79.macro mulpade arg1,arg2
80.if ((\arg1 + \arg2) % 8 == 0)
81 mulx r9, rax, [x+8*\arg1]
82 adcx r8, rax
83 adox r9, zero
84.elseif ((\arg1 + \arg2) % 8 == 1)
85 mulx r10, rax, [x+8*\arg1]
86 adcx r9, rax
87 adox r10, zero
88.elseif ((\arg1 + \arg2) % 8 == 2)
89 mulx r11, rax, [x+8*\arg1]
90 adcx r10, rax
91 adox r11, zero
92.elseif ((\arg1 + \arg2) % 8 == 3)
93 mulx r12, rax, [x+8*\arg1]
94 adcx r11, rax
95 adox r12, zero
96.elseif ((\arg1 + \arg2) % 8 == 4)
97 mulx r13, rax, [x+8*\arg1]
98 adcx r12, rax
99 adox r13, zero
100.elseif ((\arg1 + \arg2) % 8 == 5)
101 mulx r14, rax, [x+8*\arg1]
102 adcx r13, rax
103 adox r14, zero
104.elseif ((\arg1 + \arg2) % 8 == 6)
105 mulx r15, rax, [x+8*\arg1]
106 adcx r14, rax
107 adox r15, zero
108.elseif ((\arg1 + \arg2) % 8 == 7)
109 mulx r8, rax, [x+8*\arg1]
110 adcx r15, rax
111 adox r8, zero
112.endif
113
114.endm
115
116.macro diagonals
117
118 xor zeroe, zeroe
119
120// Set initial window [r8..r10] + 2 wb = 10 + 20 + 30 + 40 + 50 + 60 + 70
121
122 mov rdx, [x]
123 mulx rax, r9, [x+8]
124 mov [z+8], r9
125 mulx rcx, r10, [x+16]
126 adcx r10, rax
127 mov [z+16], r10
128 mulx rax, r11, [x+24]
129 adcx r11, rcx
130 mulx rcx, r12, [x+32]
131 adcx r12, rax
132 mulx rax, r13, [x+40]
133 adcx r13, rcx
134 mulx rcx, r14, [x+48]
135 adcx r14, rax
136 mulx r8, r15, [x+56]
137 adcx r15, rcx
138 adcx r8, zero
139
140// Add in the next diagonal = 21 + 31 + 41 + 51 + 61 + 71 + 54
141
142 xor zeroe, zeroe
143 mov rdx, [x+8]
144 mulpadd 2, 1
145 mov [z+24], r11
146 mulpadd 3, 1
147 mov [z+32], r12
148 mulpadd 4, 1
149 mulpadd 5, 1
150 mulpadd 6, 1
151 mulpade 7, 1
152 mov rdx, [x+32]
153 mulpade 5, 4
154 adcx r10, zero
155
156// And the next one = 32 + 42 + 52 + 62 + 72 + 64 + 65
157
158 xor zeroe, zeroe
159 mov rdx, [x+16]
160 mulpadd 3, 2
161 mov [z+40], r13
162 mulpadd 4, 2
163 mov [z+48], r14
164 mulpadd 5, 2
165 mulpadd 6, 2
166 mulpadd 7, 2
167 mov rdx, [x+48]
168 mulpade 4, 6
169 mulpade 5, 6
170 adcx r12, zero
171
172// And the final one = 43 + 53 + 63 + 73 + 74 + 75 + 76
173
174 xor zeroe, zeroe
175 mov rdx, [x+24]
176 mulpadd 4, 3
177 mov [z+56], r15
178 mulpadd 5, 3
179 mov [z+64], r8
180 mulpadd 6, 3
181 mulpadd 7, 3
182 mov rdx, [x+56]
183 mulpadd 4, 7
184 mulpade 5, 7
185 mulpade 6, 7
186 adcx r14, zero
187
188// Double and add things; use z[1]..z[8] and thereafter the registers
189// r9..r15 which haven't been written back yet
190
191 xor zeroe, zeroe
192 mov rdx, [x]
193 mulx rcx, rax, rdx
194 mov [z], rax
195 mov rax, [z+8]
196 adcx rax, rax
197 adox rax, rcx
198 mov [z+8], rax
199
200 mov rax, [z+16]
201 mov rdx, [x+8]
202 mulx rcx, rdx, rdx
203 adcx rax, rax
204 adox rax, rdx
205 mov [z+16], rax
206 mov rax, [z+24]
207 adcx rax, rax
208 adox rax, rcx
209 mov [z+24], rax
210
211 mov rax, [z+32]
212 mov rdx, [x+16]
213 mulx rcx, rdx, rdx
214 adcx rax, rax
215 adox rax, rdx
216 mov [z+32], rax
217 mov rax, [z+40]
218 adcx rax, rax
219 adox rax, rcx
220 mov [z+40], rax
221
222 mov rax, [z+48]
223 mov rdx, [x+24]
224 mulx rcx, rdx, rdx
225 adcx rax, rax
226 adox rax, rdx
227 mov [z+48], rax
228 mov rax, [z+56]
229 adcx rax, rax
230 adox rax, rcx
231 mov [z+56], rax
232
233 mov rax, [z+64]
234 mov rdx, [x+32]
235 mulx rcx, rdx, rdx
236 adcx rax, rax
237 adox rax, rdx
238 mov [z+64], rax
239 adcx r9, r9
240 adox r9, rcx
241 mov [z+72], r9
242
243 mov rdx, [x+40]
244 mulx rcx, rdx, rdx
245 adcx r10, r10
246 adox r10, rdx
247 mov [z+80], r10
248 adcx r11, r11
249 adox r11, rcx
250 mov [z+88], r11
251
252 mov rdx, [x+48]
253 mulx rcx, rdx, rdx
254 adcx r12, r12
255 adox r12, rdx
256 mov [z+96], r12
257 adcx r13, r13
258 adox r13, rcx
259 mov [z+104], r13
260
261 mov rdx, [x+56]
262 mulx r15, rdx, rdx
263 adcx r14, r14
264 adox r14, rdx
265 mov [z+112], r14
266 adcx r15, zero
267 adox r15, zero
268 mov [z+120], r15
269
270.endm
271
272
273S2N_BN_SYMBOL(bignum_sqr_8_16):
274 _CET_ENDBR
275
276#if WINDOWS_ABI
277 push rdi
278 push rsi
279 mov rdi, rcx
280 mov rsi, rdx
281#endif
282
283// Save more registers to play with
284
285 push rbp
286 push r12
287 push r13
288 push r14
289 push r15
290
291// Do the multiplication
292
293 diagonals
294
295// Real epilog
296
297 pop r15
298 pop r14
299 pop r13
300 pop r12
301 pop rbp
302
303#if WINDOWS_ABI
304 pop rsi
305 pop rdi
306#endif
307 ret
308
309#if defined(__linux__) && defined(__ELF__)
310.section .note.GNU-stack,"",%progbits
311#endif
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S
index ac0b6f96c2..cb10ba2a12 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_sqr_8_16_alt.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,7 +18,8 @@
16// Square, z := x^2 18// Square, z := x^2
17// Input x[8]; output z[16] 19// Input x[8]; output z[16]
18// 20//
19// extern void bignum_sqr_8_16_alt (uint64_t z[static 16], uint64_t x[static 8]); 21// extern void bignum_sqr_8_16_alt(uint64_t z[static 16],
22// const uint64_t x[static 8]);
20// 23//
21// Standard x86-64 ABI: RDI = z, RSI = x 24// Standard x86-64 ABI: RDI = z, RSI = x
22// Microsoft x64 ABI: RCX = z, RDX = x 25// Microsoft x64 ABI: RCX = z, RDX = x
@@ -103,7 +106,7 @@
103 adc c, 0 106 adc c, 0
104 107
105S2N_BN_SYMBOL(bignum_sqr_8_16_alt): 108S2N_BN_SYMBOL(bignum_sqr_8_16_alt):
106 _CET_ENDBR 109 _CET_ENDBR
107 110
108#if WINDOWS_ABI 111#if WINDOWS_ABI
109 push rdi 112 push rdi
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S
index 3ff8a30510..7324d3a71e 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S
+++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S
@@ -1,3 +1,5 @@
1// $OpenBSD: bignum_sub.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,9 +18,8 @@
16// Subtract, z := x - y 18// Subtract, z := x - y
17// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] 19// Inputs x[m], y[n]; outputs function return (carry-out) and z[p]
18// 20//
19// extern uint64_t bignum_sub 21// extern uint64_t bignum_sub(uint64_t p, uint64_t *z, uint64_t m,
20// (uint64_t p, uint64_t *z, 22// const uint64_t *x, uint64_t n, const uint64_t *y);
21// uint64_t m, uint64_t *x, uint64_t n, uint64_t *y);
22// 23//
23// Does the z := x - y operation, truncating modulo p words in general and 24// Does the z := x - y operation, truncating modulo p words in general and
24// returning a top borrow (0 or 1) in the p'th place, only subtracting input 25// returning a top borrow (0 or 1) in the p'th place, only subtracting input
@@ -49,7 +50,7 @@
49 50
50 51
51S2N_BN_SYMBOL(bignum_sub): 52S2N_BN_SYMBOL(bignum_sub):
52 _CET_ENDBR 53 _CET_ENDBR
53 54
54#if WINDOWS_ABI 55#if WINDOWS_ABI
55 push rdi 56 push rdi
@@ -75,7 +76,7 @@ S2N_BN_SYMBOL(bignum_sub):
75 cmp p, n 76 cmp p, n
76 cmovc n, p 77 cmovc n, p
77 cmp m, n 78 cmp m, n
78 jc ylonger 79 jc bignum_sub_ylonger
79 80
80// The case where x is longer or of the same size (p >= m >= n) 81// The case where x is longer or of the same size (p >= m >= n)
81 82
@@ -83,32 +84,32 @@ S2N_BN_SYMBOL(bignum_sub):
83 sub m, n 84 sub m, n
84 inc m 85 inc m
85 test n, n 86 test n, n
86 jz xtest 87 jz bignum_sub_xtest
87xmainloop: 88bignum_sub_xmainloop:
88 mov a, [x+8*i] 89 mov a, [x+8*i]
89 sbb a, [y+8*i] 90 sbb a, [y+8*i]
90 mov [z+8*i],a 91 mov [z+8*i],a
91 inc i 92 inc i
92 dec n 93 dec n
93 jnz xmainloop 94 jnz bignum_sub_xmainloop
94 jmp xtest 95 jmp bignum_sub_xtest
95xtoploop: 96bignum_sub_xtoploop:
96 mov a, [x+8*i] 97 mov a, [x+8*i]
97 sbb a, 0 98 sbb a, 0
98 mov [z+8*i],a 99 mov [z+8*i],a
99 inc i 100 inc i
100xtest: 101bignum_sub_xtest:
101 dec m 102 dec m
102 jnz xtoploop 103 jnz bignum_sub_xtoploop
103 sbb a, a 104 sbb a, a
104 test p, p 105 test p, p
105 jz tailskip 106 jz bignum_sub_tailskip
106tailloop: 107bignum_sub_tailloop:
107 mov [z+8*i],a 108 mov [z+8*i],a
108 inc i 109 inc i
109 dec p 110 dec p
110 jnz tailloop 111 jnz bignum_sub_tailloop
111tailskip: 112bignum_sub_tailskip:
112 neg a 113 neg a
113#if WINDOWS_ABI 114#if WINDOWS_ABI
114 pop rsi 115 pop rsi
@@ -118,29 +119,29 @@ tailskip:
118 119
119// The case where y is longer (p >= n > m) 120// The case where y is longer (p >= n > m)
120 121
121ylonger: 122bignum_sub_ylonger:
122 123
123 sub p, n 124 sub p, n
124 sub n, m 125 sub n, m
125 test m, m 126 test m, m
126 jz ytoploop 127 jz bignum_sub_ytoploop
127ymainloop: 128bignum_sub_ymainloop:
128 mov a, [x+8*i] 129 mov a, [x+8*i]
129 sbb a, [y+8*i] 130 sbb a, [y+8*i]
130 mov [z+8*i],a 131 mov [z+8*i],a
131 inc i 132 inc i
132 dec m 133 dec m
133 jnz ymainloop 134 jnz bignum_sub_ymainloop
134ytoploop: 135bignum_sub_ytoploop:
135 mov ashort, 0 136 mov ashort, 0
136 sbb a, [y+8*i] 137 sbb a, [y+8*i]
137 mov [z+8*i],a 138 mov [z+8*i],a
138 inc i 139 inc i
139 dec n 140 dec n
140 jnz ytoploop 141 jnz bignum_sub_ytoploop
141 sbb a, a 142 sbb a, a
142 test p, p 143 test p, p
143 jnz tailloop 144 jnz bignum_sub_tailloop
144 neg a 145 neg a
145#if WINDOWS_ABI 146#if WINDOWS_ABI
146 pop rsi 147 pop rsi
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c
index a377a05681..9ff8920ca2 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c
+++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_arch.c,v 1.7 2023/06/24 16:01:44 jsing Exp $ */ 1/* $OpenBSD: bn_arch.c,v 1.12 2025/08/14 15:29:17 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -19,6 +19,7 @@
19 19
20#include "bn_arch.h" 20#include "bn_arch.h"
21#include "bn_local.h" 21#include "bn_local.h"
22#include "crypto_arch.h"
22#include "s2n_bignum.h" 23#include "s2n_bignum.h"
23 24
24#ifdef HAVE_BN_ADD 25#ifdef HAVE_BN_ADD
@@ -26,8 +27,8 @@ BN_ULONG
26bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, 27bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
27 int b_len) 28 int b_len)
28{ 29{
29 return bignum_add(r_len, (uint64_t *)r, a_len, (uint64_t *)a, 30 return bignum_add(r_len, (uint64_t *)r, a_len, (const uint64_t *)a,
30 b_len, (uint64_t *)b); 31 b_len, (const uint64_t *)b);
31} 32}
32#endif 33#endif
33 34
@@ -36,8 +37,8 @@ bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
36BN_ULONG 37BN_ULONG
37bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) 38bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n)
38{ 39{
39 return bignum_add(n, (uint64_t *)rd, n, (uint64_t *)ad, n, 40 return bignum_add(n, (uint64_t *)rd, n, (const uint64_t *)ad, n,
40 (uint64_t *)bd); 41 (const uint64_t *)bd);
41} 42}
42#endif 43#endif
43 44
@@ -46,8 +47,8 @@ BN_ULONG
46bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, 47bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
47 int b_len) 48 int b_len)
48{ 49{
49 return bignum_sub(r_len, (uint64_t *)r, a_len, (uint64_t *)a, 50 return bignum_sub(r_len, (uint64_t *)r, a_len, (const uint64_t *)a,
50 b_len, (uint64_t *)b); 51 b_len, (const uint64_t *)b);
51} 52}
52#endif 53#endif
53 54
@@ -55,8 +56,28 @@ bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
55BN_ULONG 56BN_ULONG
56bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) 57bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n)
57{ 58{
58 return bignum_sub(n, (uint64_t *)rd, n, (uint64_t *)ad, n, 59 return bignum_sub(n, (uint64_t *)rd, n, (const uint64_t *)ad, n,
59 (uint64_t *)bd); 60 (const uint64_t *)bd);
61}
62#endif
63
64#ifdef HAVE_BN_MOD_ADD_WORDS
65void
66bn_mod_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
67 const BN_ULONG *m, size_t n)
68{
69 bignum_modadd(n, (uint64_t *)r, (const uint64_t *)a,
70 (const uint64_t *)b, (const uint64_t *)m);
71}
72#endif
73
74#ifdef HAVE_BN_MOD_SUB_WORDS
75void
76bn_mod_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
77 const BN_ULONG *m, size_t n)
78{
79 bignum_modsub(n, (uint64_t *)r, (const uint64_t *)a,
80 (const uint64_t *)b, (const uint64_t *)m);
60} 81}
61#endif 82#endif
62 83
@@ -64,7 +85,7 @@ bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n)
64BN_ULONG 85BN_ULONG
65bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) 86bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w)
66{ 87{
67 return bignum_cmadd(num, (uint64_t *)rd, w, num, (uint64_t *)ad); 88 return bignum_cmadd(num, (uint64_t *)rd, w, num, (const uint64_t *)ad);
68} 89}
69#endif 90#endif
70 91
@@ -72,25 +93,52 @@ bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w)
72BN_ULONG 93BN_ULONG
73bn_mul_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) 94bn_mul_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w)
74{ 95{
75 return bignum_cmul(num, (uint64_t *)rd, w, num, (uint64_t *)ad); 96 return bignum_cmul(num, (uint64_t *)rd, w, num, (const uint64_t *)ad);
76} 97}
77#endif 98#endif
78 99
79#ifdef HAVE_BN_MUL_COMBA4 100#ifdef HAVE_BN_MUL_COMBA4
80void 101void
81bn_mul_comba4(BN_ULONG *rd, BN_ULONG *ad, BN_ULONG *bd) 102bn_mul_comba4(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd)
82{ 103{
83 /* XXX - consider using non-alt on CPUs that have the ADX extension. */ 104 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_ADX) != 0) {
84 bignum_mul_4_8_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); 105 bignum_mul_4_8((uint64_t *)rd, (const uint64_t *)ad,
106 (const uint64_t *)bd);
107 return;
108 }
109
110 bignum_mul_4_8_alt((uint64_t *)rd, (const uint64_t *)ad,
111 (const uint64_t *)bd);
112}
113#endif
114
115#ifdef HAVE_BN_MUL_COMBA6
116void
117bn_mul_comba6(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd)
118{
119 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_ADX) != 0) {
120 bignum_mul_6_12((uint64_t *)rd, (const uint64_t *)ad,
121 (const uint64_t *)bd);
122 return;
123 }
124
125 bignum_mul_6_12_alt((uint64_t *)rd, (const uint64_t *)ad,
126 (const uint64_t *)bd);
85} 127}
86#endif 128#endif
87 129
88#ifdef HAVE_BN_MUL_COMBA8 130#ifdef HAVE_BN_MUL_COMBA8
89void 131void
90bn_mul_comba8(BN_ULONG *rd, BN_ULONG *ad, BN_ULONG *bd) 132bn_mul_comba8(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd)
91{ 133{
92 /* XXX - consider using non-alt on CPUs that have the ADX extension. */ 134 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_ADX) != 0) {
93 bignum_mul_8_16_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); 135 bignum_mul_8_16((uint64_t *)rd, (const uint64_t *)ad,
136 (const uint64_t *)bd);
137 return;
138 }
139
140 bignum_mul_8_16_alt((uint64_t *)rd, (const uint64_t *)ad,
141 (const uint64_t *)bd);
94} 142}
95#endif 143#endif
96 144
@@ -98,7 +146,7 @@ bn_mul_comba8(BN_ULONG *rd, BN_ULONG *ad, BN_ULONG *bd)
98int 146int
99bn_sqr(BIGNUM *r, const BIGNUM *a, int r_len, BN_CTX *ctx) 147bn_sqr(BIGNUM *r, const BIGNUM *a, int r_len, BN_CTX *ctx)
100{ 148{
101 bignum_sqr(r_len, (uint64_t *)r->d, a->top, (uint64_t *)a->d); 149 bignum_sqr(r_len, (uint64_t *)r->d, a->top, (const uint64_t *)a->d);
102 150
103 return 1; 151 return 1;
104} 152}
@@ -108,8 +156,25 @@ bn_sqr(BIGNUM *r, const BIGNUM *a, int r_len, BN_CTX *ctx)
108void 156void
109bn_sqr_comba4(BN_ULONG *rd, const BN_ULONG *ad) 157bn_sqr_comba4(BN_ULONG *rd, const BN_ULONG *ad)
110{ 158{
111 /* XXX - consider using non-alt on CPUs that have the ADX extension. */ 159 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_ADX) != 0) {
112 bignum_sqr_4_8_alt((uint64_t *)rd, (uint64_t *)ad); 160 bignum_sqr_4_8((uint64_t *)rd, (const uint64_t *)ad);
161 return;
162 }
163
164 bignum_sqr_4_8_alt((uint64_t *)rd, (const uint64_t *)ad);
165}
166#endif
167
168#ifdef HAVE_BN_SQR_COMBA6
169void
170bn_sqr_comba6(BN_ULONG *rd, const BN_ULONG *ad)
171{
172 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_ADX) != 0) {
173 bignum_sqr_6_12((uint64_t *)rd, (const uint64_t *)ad);
174 return;
175 }
176
177 bignum_sqr_6_12_alt((uint64_t *)rd, (const uint64_t *)ad);
113} 178}
114#endif 179#endif
115 180
@@ -117,8 +182,12 @@ bn_sqr_comba4(BN_ULONG *rd, const BN_ULONG *ad)
117void 182void
118bn_sqr_comba8(BN_ULONG *rd, const BN_ULONG *ad) 183bn_sqr_comba8(BN_ULONG *rd, const BN_ULONG *ad)
119{ 184{
120 /* XXX - consider using non-alt on CPUs that have the ADX extension. */ 185 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_ADX) != 0) {
121 bignum_sqr_8_16_alt((uint64_t *)rd, (uint64_t *)ad); 186 bignum_sqr_8_16((uint64_t *)rd, (const uint64_t *)ad);
187 return;
188 }
189
190 bignum_sqr_8_16_alt((uint64_t *)rd, (const uint64_t *)ad);
122} 191}
123#endif 192#endif
124 193
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.h b/src/lib/libcrypto/bn/arch/amd64/bn_arch.h
index 927cd75208..7359f993a7 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.h
+++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_arch.h,v 1.14 2024/03/26 06:09:25 jsing Exp $ */ 1/* $OpenBSD: bn_arch.h,v 1.16 2025/08/14 15:22:54 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -27,13 +27,18 @@
27 27
28#define HAVE_BN_DIV_WORDS 28#define HAVE_BN_DIV_WORDS
29 29
30#define HAVE_BN_MOD_ADD_WORDS
31#define HAVE_BN_MOD_SUB_WORDS
32
30#define HAVE_BN_MUL_ADD_WORDS 33#define HAVE_BN_MUL_ADD_WORDS
31#define HAVE_BN_MUL_COMBA4 34#define HAVE_BN_MUL_COMBA4
35#define HAVE_BN_MUL_COMBA6
32#define HAVE_BN_MUL_COMBA8 36#define HAVE_BN_MUL_COMBA8
33#define HAVE_BN_MUL_WORDS 37#define HAVE_BN_MUL_WORDS
34 38
35#define HAVE_BN_SQR 39#define HAVE_BN_SQR
36#define HAVE_BN_SQR_COMBA4 40#define HAVE_BN_SQR_COMBA4
41#define HAVE_BN_SQR_COMBA6
37#define HAVE_BN_SQR_COMBA8 42#define HAVE_BN_SQR_COMBA8
38 43
39#define HAVE_BN_SUB 44#define HAVE_BN_SUB
diff --git a/src/lib/libcrypto/bn/arch/amd64/word_clz.S b/src/lib/libcrypto/bn/arch/amd64/word_clz.S
index 3926fcd4b0..705fbdbbda 100644
--- a/src/lib/libcrypto/bn/arch/amd64/word_clz.S
+++ b/src/lib/libcrypto/bn/arch/amd64/word_clz.S
@@ -1,3 +1,5 @@
1// $OpenBSD: word_clz.S,v 1.7 2025/08/11 14:13:56 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -16,7 +18,7 @@
16// Count leading zero bits in a single word 18// Count leading zero bits in a single word
17// Input a; output function return 19// Input a; output function return
18// 20//
19// extern uint64_t word_clz (uint64_t a); 21// extern uint64_t word_clz(uint64_t a);
20// 22//
21// Standard x86-64 ABI: RDI = a, returns RAX 23// Standard x86-64 ABI: RDI = a, returns RAX
22// Microsoft x64 ABI: RCX = a, returns RAX 24// Microsoft x64 ABI: RCX = a, returns RAX
@@ -30,7 +32,7 @@
30 .text 32 .text
31 33
32S2N_BN_SYMBOL(word_clz): 34S2N_BN_SYMBOL(word_clz):
33 _CET_ENDBR 35 _CET_ENDBR
34 36
35#if WINDOWS_ABI 37#if WINDOWS_ABI
36 push rdi 38 push rdi
diff --git a/src/lib/libcrypto/bn/asm/bn-586.pl b/src/lib/libcrypto/bn/asm/bn-586.pl
index 71b775af8d..19a1afdbbe 100644
--- a/src/lib/libcrypto/bn/asm/bn-586.pl
+++ b/src/lib/libcrypto/bn/asm/bn-586.pl
@@ -6,8 +6,7 @@ require "x86asm.pl";
6 6
7&asm_init($ARGV[0],$0); 7&asm_init($ARGV[0],$0);
8 8
9$sse2=0; 9$sse2=1;
10for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
11 10
12&external_label("OPENSSL_ia32cap_P") if ($sse2); 11&external_label("OPENSSL_ia32cap_P") if ($sse2);
13 12
diff --git a/src/lib/libcrypto/bn/asm/x86-mont.pl b/src/lib/libcrypto/bn/asm/x86-mont.pl
index 6524651748..3be440f11f 100755
--- a/src/lib/libcrypto/bn/asm/x86-mont.pl
+++ b/src/lib/libcrypto/bn/asm/x86-mont.pl
@@ -32,8 +32,7 @@ require "x86asm.pl";
32 32
33&asm_init($ARGV[0],$0); 33&asm_init($ARGV[0],$0);
34 34
35$sse2=0; 35$sse2=1;
36for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
37 36
38&external_label("OPENSSL_ia32cap_P") if ($sse2); 37&external_label("OPENSSL_ia32cap_P") if ($sse2);
39 38
diff --git a/src/lib/libcrypto/bn/bn_add.c b/src/lib/libcrypto/bn/bn_add.c
index 86768a312a..81fa60e429 100644
--- a/src/lib/libcrypto/bn/bn_add.c
+++ b/src/lib/libcrypto/bn/bn_add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_add.c,v 1.26 2023/07/08 12:21:58 beck Exp $ */ 1/* $OpenBSD: bn_add.c,v 1.29 2025/05/25 04:53:05 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,44 +60,10 @@
60#include <limits.h> 60#include <limits.h>
61#include <stdio.h> 61#include <stdio.h>
62 62
63#include <openssl/err.h>
64
65#include "bn_arch.h" 63#include "bn_arch.h"
66#include "bn_local.h" 64#include "bn_local.h"
67#include "bn_internal.h" 65#include "bn_internal.h"
68 66#include "err_local.h"
69/*
70 * bn_add_words() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b
71 * are both arrays of words. Any carry resulting from the addition is returned.
72 */
73#ifndef HAVE_BN_ADD_WORDS
74BN_ULONG
75bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
76{
77 BN_ULONG carry = 0;
78
79 assert(n >= 0);
80 if (n <= 0)
81 return 0;
82
83 while (n & ~3) {
84 bn_qwaddqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0],
85 carry, &carry, &r[3], &r[2], &r[1], &r[0]);
86 a += 4;
87 b += 4;
88 r += 4;
89 n -= 4;
90 }
91 while (n) {
92 bn_addw_addw(a[0], b[0], carry, &carry, &r[0]);
93 a++;
94 b++;
95 r++;
96 n--;
97 }
98 return carry;
99}
100#endif
101 67
102/* 68/*
103 * bn_add() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b are both 69 * bn_add() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b are both
@@ -147,40 +113,6 @@ bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
147#endif 113#endif
148 114
149/* 115/*
150 * bn_sub_words() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b
151 * are both arrays of words. Any borrow resulting from the subtraction is
152 * returned.
153 */
154#ifndef HAVE_BN_SUB_WORDS
155BN_ULONG
156bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
157{
158 BN_ULONG borrow = 0;
159
160 assert(n >= 0);
161 if (n <= 0)
162 return 0;
163
164 while (n & ~3) {
165 bn_qwsubqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0],
166 borrow, &borrow, &r[3], &r[2], &r[1], &r[0]);
167 a += 4;
168 b += 4;
169 r += 4;
170 n -= 4;
171 }
172 while (n) {
173 bn_subw_subw(a[0], b[0], borrow, &borrow, &r[0]);
174 a++;
175 b++;
176 r++;
177 n--;
178 }
179 return borrow;
180}
181#endif
182
183/*
184 * bn_sub() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b are both 116 * bn_sub() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b are both
185 * arrays of words (r may be the same as a or b). The length of a and b may 117 * arrays of words (r may be the same as a or b). The length of a and b may
186 * differ, while r must be at least max(a_len, b_len) in length. Any borrow 118 * differ, while r must be at least max(a_len, b_len) in length. Any borrow
@@ -208,7 +140,7 @@ bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
208 /* XXX - consider doing four at a time to match bn_sub_words. */ 140 /* XXX - consider doing four at a time to match bn_sub_words. */
209 while (diff_len < 0) { 141 while (diff_len < 0) {
210 /* Compute r[0] = 0 - b[0] - borrow. */ 142 /* Compute r[0] = 0 - b[0] - borrow. */
211 bn_subw(0 - b[0], borrow, &borrow, &r[0]); 143 bn_subw_subw(0, b[0], borrow, &borrow, &r[0]);
212 diff_len++; 144 diff_len++;
213 b++; 145 b++;
214 r++; 146 r++;
@@ -217,7 +149,7 @@ bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
217 /* XXX - consider doing four at a time to match bn_sub_words. */ 149 /* XXX - consider doing four at a time to match bn_sub_words. */
218 while (diff_len > 0) { 150 while (diff_len > 0) {
219 /* Compute r[0] = a[0] - 0 - borrow. */ 151 /* Compute r[0] = a[0] - 0 - borrow. */
220 bn_subw(a[0], borrow, &borrow, &r[0]); 152 bn_subw_subw(a[0], 0, borrow, &borrow, &r[0]);
221 diff_len--; 153 diff_len--;
222 a++; 154 a++;
223 r++; 155 r++;
diff --git a/src/lib/libcrypto/bn/bn_add_sub.c b/src/lib/libcrypto/bn/bn_add_sub.c
new file mode 100644
index 0000000000..5c9d5a2b1a
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_add_sub.c
@@ -0,0 +1,178 @@
1/* $OpenBSD: bn_add_sub.c,v 1.1 2025/05/25 04:30:55 jsing Exp $ */
2/*
3 * Copyright (c) 2023,2024,2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <openssl/bn.h>
19
20#include "bn_internal.h"
21
22/*
23 * bn_add_words() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b
24 * are both arrays of words. Any carry resulting from the addition is returned.
25 */
26#ifndef HAVE_BN_ADD_WORDS
27BN_ULONG
28bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
29{
30 BN_ULONG carry = 0;
31
32 while (n >= 4) {
33 bn_qwaddqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0],
34 carry, &carry, &r[3], &r[2], &r[1], &r[0]);
35 a += 4;
36 b += 4;
37 r += 4;
38 n -= 4;
39 }
40 while (n > 0) {
41 bn_addw_addw(a[0], b[0], carry, &carry, &r[0]);
42 a++;
43 b++;
44 r++;
45 n--;
46 }
47
48 return carry;
49}
50#endif
51
52/*
53 * bn_sub_words() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b
54 * are both arrays of words. Any borrow resulting from the subtraction is
55 * returned.
56 */
57#ifndef HAVE_BN_SUB_WORDS
58BN_ULONG
59bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
60{
61 BN_ULONG borrow = 0;
62
63 while (n >= 4) {
64 bn_qwsubqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0],
65 borrow, &borrow, &r[3], &r[2], &r[1], &r[0]);
66 a += 4;
67 b += 4;
68 r += 4;
69 n -= 4;
70 }
71 while (n > 0) {
72 bn_subw_subw(a[0], b[0], borrow, &borrow, &r[0]);
73 a++;
74 b++;
75 r++;
76 n--;
77 }
78
79 return borrow;
80}
81#endif
82
83/*
84 * bn_sub_borrow() computes a[i] - b[i], returning the resulting borrow only.
85 */
86#ifndef HAVE_BN_SUB_WORDS_BORROW
87BN_ULONG
88bn_sub_words_borrow(const BN_ULONG *a, const BN_ULONG *b, size_t n)
89{
90 BN_ULONG borrow = 0;
91 BN_ULONG r;
92
93 while (n >= 4) {
94 bn_qwsubqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0],
95 borrow, &borrow, &r, &r, &r, &r);
96 a += 4;
97 b += 4;
98 n -= 4;
99 }
100 while (n > 0) {
101 bn_subw_subw(a[0], b[0], borrow, &borrow, &r);
102 a++;
103 b++;
104 n--;
105 }
106
107 return borrow;
108}
109#endif
110
111/*
112 * bn_add_words_masked() computes r[] = a[] + (b[] & mask), where a, b and r are
113 * arrays of words with length n (r may be the same as a or b).
114 */
115#ifndef HAVE_BN_ADD_WORDS_MASKED
116BN_ULONG
117bn_add_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
118 BN_ULONG mask, size_t n)
119{
120 BN_ULONG carry = 0;
121
122 /* XXX - consider conditional/masked versions of bn_addw_addw/bn_qwaddqw. */
123
124 while (n >= 4) {
125 bn_qwaddqw(a[3], a[2], a[1], a[0], b[3] & mask, b[2] & mask,
126 b[1] & mask, b[0] & mask, carry, &carry, &r[3], &r[2],
127 &r[1], &r[0]);
128 a += 4;
129 b += 4;
130 r += 4;
131 n -= 4;
132 }
133 while (n > 0) {
134 bn_addw_addw(a[0], b[0] & mask, carry, &carry, &r[0]);
135 a++;
136 b++;
137 r++;
138 n--;
139 }
140
141 return carry;
142}
143#endif
144
145/*
146 * bn_sub_words_masked() computes r[] = a[] - (b[] & mask), where a, b and r are
147 * arrays of words with length n (r may be the same as a or b).
148 */
149#ifndef HAVE_BN_SUB_WORDS_MASKED
150BN_ULONG
151bn_sub_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
152 BN_ULONG mask, size_t n)
153{
154 BN_ULONG borrow = 0;
155
156 /* XXX - consider conditional/masked versions of bn_subw_subw/bn_qwsubqw. */
157
158 /* Compute conditional r[i] = a[i] - b[i]. */
159 while (n >= 4) {
160 bn_qwsubqw(a[3], a[2], a[1], a[0], b[3] & mask, b[2] & mask,
161 b[1] & mask, b[0] & mask, borrow, &borrow, &r[3], &r[2],
162 &r[1], &r[0]);
163 a += 4;
164 b += 4;
165 r += 4;
166 n -= 4;
167 }
168 while (n > 0) {
169 bn_subw_subw(a[0], b[0] & mask, borrow, &borrow, &r[0]);
170 a++;
171 b++;
172 r++;
173 n--;
174 }
175
176 return borrow;
177}
178#endif
diff --git a/src/lib/libcrypto/bn/bn_convert.c b/src/lib/libcrypto/bn/bn_convert.c
index 6a6354f44e..ca5c7d7865 100644
--- a/src/lib/libcrypto/bn/bn_convert.c
+++ b/src/lib/libcrypto/bn/bn_convert.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_convert.c,v 1.23 2024/11/08 14:18:44 jsing Exp $ */ 1/* $OpenBSD: bn_convert.c,v 1.24 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -65,11 +65,11 @@
65 65
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/buffer.h> 67#include <openssl/buffer.h>
68#include <openssl/err.h>
69 68
70#include "bn_local.h" 69#include "bn_local.h"
71#include "bytestring.h" 70#include "bytestring.h"
72#include "crypto_internal.h" 71#include "crypto_internal.h"
72#include "err_local.h"
73 73
74static int bn_dec2bn_cbs(BIGNUM **bnp, CBS *cbs); 74static int bn_dec2bn_cbs(BIGNUM **bnp, CBS *cbs);
75static int bn_hex2bn_cbs(BIGNUM **bnp, CBS *cbs); 75static int bn_hex2bn_cbs(BIGNUM **bnp, CBS *cbs);
diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c
index 129b9c9781..eda93dcaa4 100644
--- a/src/lib/libcrypto/bn/bn_ctx.c
+++ b/src/lib/libcrypto/bn/bn_ctx.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_ctx.c,v 1.22 2023/07/08 12:21:58 beck Exp $ */ 1/* $OpenBSD: bn_ctx.c,v 1.23 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -19,9 +19,9 @@
19#include <string.h> 19#include <string.h>
20 20
21#include <openssl/opensslconf.h> 21#include <openssl/opensslconf.h>
22#include <openssl/err.h>
23 22
24#include "bn_local.h" 23#include "bn_local.h"
24#include "err_local.h"
25 25
26#define BN_CTX_INITIAL_LEN 8 26#define BN_CTX_INITIAL_LEN 8
27 27
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index 09a8a364df..1026b43add 100644
--- a/src/lib/libcrypto/bn/bn_div.c
+++ b/src/lib/libcrypto/bn/bn_div.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_div.c,v 1.41 2024/04/10 14:58:06 beck Exp $ */ 1/* $OpenBSD: bn_div.c,v 1.42 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,11 +62,11 @@
62#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63 63
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/err.h>
66 65
67#include "bn_arch.h" 66#include "bn_arch.h"
68#include "bn_local.h" 67#include "bn_local.h"
69#include "bn_internal.h" 68#include "bn_internal.h"
69#include "err_local.h"
70 70
71BN_ULONG bn_div_3_words(const BN_ULONG *m, BN_ULONG d1, BN_ULONG d0); 71BN_ULONG bn_div_3_words(const BN_ULONG *m, BN_ULONG d1, BN_ULONG d0);
72 72
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index e925d325d2..6a5c1c857a 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_exp.c,v 1.58 2025/02/13 11:15:09 tb Exp $ */ 1/* $OpenBSD: bn_exp.c,v 1.59 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -112,10 +112,9 @@
112#include <stdlib.h> 112#include <stdlib.h>
113#include <string.h> 113#include <string.h>
114 114
115#include <openssl/err.h>
116
117#include "bn_local.h" 115#include "bn_local.h"
118#include "constant_time.h" 116#include "constant_time.h"
117#include "err_local.h"
119 118
120/* maximum precomputation table size for *variable* sliding windows */ 119/* maximum precomputation table size for *variable* sliding windows */
121#define TABLE_SIZE 32 120#define TABLE_SIZE 32
diff --git a/src/lib/libcrypto/bn/bn_gcd.c b/src/lib/libcrypto/bn/bn_gcd.c
index fa5d71a7f3..319d9ca390 100644
--- a/src/lib/libcrypto/bn/bn_gcd.c
+++ b/src/lib/libcrypto/bn/bn_gcd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_gcd.c,v 1.29 2024/04/10 14:58:06 beck Exp $ */ 1/* $OpenBSD: bn_gcd.c,v 1.31 2025/06/02 12:40:10 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -109,9 +109,8 @@
109 * 109 *
110 */ 110 */
111 111
112#include <openssl/err.h>
113
114#include "bn_local.h" 112#include "bn_local.h"
113#include "err_local.h"
115 114
116static BIGNUM * 115static BIGNUM *
117euclid(BIGNUM *a, BIGNUM *b) 116euclid(BIGNUM *a, BIGNUM *b)
@@ -681,8 +680,10 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct
681 /* A >= 2*B, so D=2 or D=3 */ 680 /* A >= 2*B, so D=2 or D=3 */
682 if (!BN_sub(M, A, T)) 681 if (!BN_sub(M, A, T))
683 goto err; 682 goto err;
684 if (!BN_add(D,T,B)) goto err; /* use D (:= 3*B) as temp */ 683 /* use D (:= 3*B) as temp */
685 if (BN_ucmp(A, D) < 0) { 684 if (!BN_add(D, T, B))
685 goto err;
686 if (BN_ucmp(A, D) < 0) {
686 /* A < 3*B, so D=2 */ 687 /* A < 3*B, so D=2 */
687 if (!BN_set_word(D, 2)) 688 if (!BN_set_word(D, 2))
688 goto err; 689 goto err;
diff --git a/src/lib/libcrypto/bn/bn_internal.h b/src/lib/libcrypto/bn/bn_internal.h
index fd04bc9f8a..8b5145e225 100644
--- a/src/lib/libcrypto/bn/bn_internal.h
+++ b/src/lib/libcrypto/bn/bn_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_internal.h,v 1.15 2023/06/25 11:42:26 jsing Exp $ */ 1/* $OpenBSD: bn_internal.h,v 1.20 2025/08/02 16:20:00 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -26,6 +26,30 @@ int bn_word_clz(BN_ULONG w);
26 26
27int bn_bitsize(const BIGNUM *bn); 27int bn_bitsize(const BIGNUM *bn);
28 28
29BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
30 int num);
31BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
32 int num);
33BN_ULONG bn_sub_words_borrow(const BN_ULONG *a, const BN_ULONG *b, size_t n);
34BN_ULONG bn_add_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
35 BN_ULONG mask, size_t n);
36BN_ULONG bn_sub_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
37 BN_ULONG mask, size_t n);
38void bn_mod_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
39 const BN_ULONG *m, size_t n);
40void bn_mod_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
41 const BN_ULONG *m, size_t n);
42void bn_mod_mul_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
43 const BN_ULONG *m, BN_ULONG *t, BN_ULONG m0, size_t n);
44void bn_mod_sqr_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *m,
45 BN_ULONG *t, BN_ULONG m0, size_t n);
46
47void bn_montgomery_multiply_words(BN_ULONG *rp, const BN_ULONG *ap,
48 const BN_ULONG *bp, const BN_ULONG *np, BN_ULONG *tp, BN_ULONG n0,
49 int n_len);
50void bn_montgomery_reduce_words(BN_ULONG *r, BN_ULONG *a, const BN_ULONG *n,
51 BN_ULONG n0, int n_len);
52
29#ifndef HAVE_BN_CT_NE_ZERO 53#ifndef HAVE_BN_CT_NE_ZERO
30static inline int 54static inline int
31bn_ct_ne_zero(BN_ULONG w) 55bn_ct_ne_zero(BN_ULONG w)
diff --git a/src/lib/libcrypto/bn/bn_isqrt.c b/src/lib/libcrypto/bn/bn_isqrt.c
index 018d5f34bd..b725519e1a 100644
--- a/src/lib/libcrypto/bn/bn_isqrt.c
+++ b/src/lib/libcrypto/bn/bn_isqrt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_isqrt.c,v 1.10 2023/06/04 17:28:35 tb Exp $ */ 1/* $OpenBSD: bn_isqrt.c,v 1.11 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -19,10 +19,10 @@
19#include <stdint.h> 19#include <stdint.h>
20 20
21#include <openssl/bn.h> 21#include <openssl/bn.h>
22#include <openssl/err.h>
23 22
24#include "bn_local.h" 23#include "bn_local.h"
25#include "crypto_internal.h" 24#include "crypto_internal.h"
25#include "err_local.h"
26 26
27/* 27/*
28 * Calculate integer square root of |n| using a variant of Newton's method. 28 * Calculate integer square root of |n| using a variant of Newton's method.
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 72b988650c..3e451a6191 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_lib.c,v 1.93 2024/04/16 13:07:14 jsing Exp $ */ 1/* $OpenBSD: bn_lib.c,v 1.94 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,10 +63,9 @@
63 63
64#include <openssl/opensslconf.h> 64#include <openssl/opensslconf.h>
65 65
66#include <openssl/err.h>
67
68#include "bn_local.h" 66#include "bn_local.h"
69#include "bn_internal.h" 67#include "bn_internal.h"
68#include "err_local.h"
70 69
71BIGNUM * 70BIGNUM *
72BN_new(void) 71BN_new(void)
diff --git a/src/lib/libcrypto/bn/bn_local.h b/src/lib/libcrypto/bn/bn_local.h
index 067ffab3d9..1bd4c16baf 100644
--- a/src/lib/libcrypto/bn/bn_local.h
+++ b/src/lib/libcrypto/bn/bn_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_local.h,v 1.50 2025/02/13 11:04:20 tb Exp $ */ 1/* $OpenBSD: bn_local.h,v 1.54 2025/08/05 15:08:13 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -240,10 +240,12 @@ BN_ULONG bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len,
240 const BN_ULONG *b, int b_len); 240 const BN_ULONG *b, int b_len);
241 241
242void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb); 242void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
243void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); 243void bn_mul_comba4(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b);
244void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); 244void bn_mul_comba6(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b);
245void bn_mul_comba8(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b);
245 246
246void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a); 247void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a);
248void bn_sqr_comba6(BN_ULONG *r, const BN_ULONG *a);
247void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a); 249void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a);
248 250
249int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, 251int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
@@ -254,10 +256,6 @@ int bn_expand_bits(BIGNUM *a, size_t bits);
254int bn_expand_bytes(BIGNUM *a, size_t bytes); 256int bn_expand_bytes(BIGNUM *a, size_t bytes);
255int bn_wexpand(BIGNUM *a, int words); 257int bn_wexpand(BIGNUM *a, int words);
256 258
257BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
258 int num);
259BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
260 int num);
261BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); 259BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
262BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); 260BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
263void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); 261void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
diff --git a/src/lib/libcrypto/bn/bn_mod.c b/src/lib/libcrypto/bn/bn_mod.c
index 365f6fcf03..7198c02e3b 100644
--- a/src/lib/libcrypto/bn/bn_mod.c
+++ b/src/lib/libcrypto/bn/bn_mod.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mod.c,v 1.22 2023/07/08 12:21:58 beck Exp $ */ 1/* $OpenBSD: bn_mod.c,v 1.23 2025/05/10 05:54:38 tb Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. */ 3 * for the OpenSSL project. */
4/* ==================================================================== 4/* ====================================================================
@@ -111,9 +111,8 @@
111 * [including the GNU Public Licence.] 111 * [including the GNU Public Licence.]
112 */ 112 */
113 113
114#include <openssl/err.h>
115
116#include "bn_local.h" 114#include "bn_local.h"
115#include "err_local.h"
117 116
118int 117int
119BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) 118BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
diff --git a/src/lib/libcrypto/bn/bn_mod_sqrt.c b/src/lib/libcrypto/bn/bn_mod_sqrt.c
index 280002cc48..fc55f84317 100644
--- a/src/lib/libcrypto/bn/bn_mod_sqrt.c
+++ b/src/lib/libcrypto/bn/bn_mod_sqrt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mod_sqrt.c,v 1.3 2023/08/03 18:53:55 tb Exp $ */ 1/* $OpenBSD: bn_mod_sqrt.c,v 1.4 2025/05/10 05:54:38 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
@@ -16,9 +16,8 @@
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19#include <openssl/err.h>
20
21#include "bn_local.h" 19#include "bn_local.h"
20#include "err_local.h"
22 21
23/* 22/*
24 * Tonelli-Shanks according to H. Cohen "A Course in Computational Algebraic 23 * Tonelli-Shanks according to H. Cohen "A Course in Computational Algebraic
diff --git a/src/lib/libcrypto/bn/bn_mod_words.c b/src/lib/libcrypto/bn/bn_mod_words.c
new file mode 100644
index 0000000000..d9aee8701a
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_mod_words.c
@@ -0,0 +1,114 @@
1/* $OpenBSD: bn_mod_words.c,v 1.3 2025/08/05 15:15:54 jsing Exp $ */
2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include "bn_local.h"
19#include "bn_internal.h"
20
21/*
22 * bn_mod_add_words() computes r[] = (a[] + b[]) mod m[], where a, b, r and
23 * m are arrays of words with length n (r may be the same as a or b).
24 */
25#ifndef HAVE_BN_MOD_ADD_WORDS
26void
27bn_mod_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
28 const BN_ULONG *m, size_t n)
29{
30 BN_ULONG carry, mask;
31
32 /*
33 * Compute a + b, then compute r - m to determine if r >= m, considering
34 * any carry that resulted from the addition. Finally complete a
35 * conditional subtraction of r - m.
36 */
37 /* XXX - change bn_add_words to use size_t. */
38 carry = bn_add_words(r, a, b, n);
39 mask = ~(carry - bn_sub_words_borrow(r, m, n));
40 bn_sub_words_masked(r, r, m, mask, n);
41}
42#endif
43
44/*
45 * bn_mod_sub_words() computes r[] = (a[] - b[]) mod m[], where a, b, r and
46 * m are arrays of words with length n (r may be the same as a or b).
47 */
48#ifndef HAVE_BN_MOD_SUB_WORDS
49void
50bn_mod_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
51 const BN_ULONG *m, size_t n)
52{
53 BN_ULONG borrow, mask;
54
55 /*
56 * Compute a - b, then complete a conditional addition of r + m
57 * based on the resulting borrow.
58 */
59 /* XXX - change bn_sub_words to use size_t. */
60 borrow = bn_sub_words(r, a, b, n);
61 mask = (0 - borrow);
62 bn_add_words_masked(r, r, m, mask, n);
63}
64#endif
65
66/*
67 * bn_mod_mul_words() computes r[] = (a[] * b[]) mod m[], where a, b, r and
68 * m are arrays of words with length n (r may be the same as a or b) in the
69 * Montgomery domain. The result remains in the Montgomery domain.
70 */
71#ifndef HAVE_BN_MOD_MUL_WORDS
72void
73bn_mod_mul_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
74 const BN_ULONG *m, BN_ULONG *t, BN_ULONG m0, size_t n)
75{
76 if (n == 4) {
77 bn_mul_comba4(t, a, b);
78 bn_montgomery_reduce_words(r, t, m, m0, n);
79 } else if (n == 6) {
80 bn_mul_comba6(t, a, b);
81 bn_montgomery_reduce_words(r, t, m, m0, n);
82 } else if (n == 8) {
83 bn_mul_comba8(t, a, b);
84 bn_montgomery_reduce_words(r, t, m, m0, n);
85 } else {
86 bn_montgomery_multiply_words(r, a, b, m, t, m0, n);
87 }
88}
89#endif
90
91/*
92 * bn_mod_sqr_words() computes r[] = (a[] * a[]) mod m[], where a, r and
93 * m are arrays of words with length n (r may be the same as a) in the
94 * Montgomery domain. The result remains in the Montgomery domain.
95 */
96#ifndef HAVE_BN_MOD_SQR_WORDS
97void
98bn_mod_sqr_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *m,
99 BN_ULONG *t, BN_ULONG m0, size_t n)
100{
101 if (n == 4) {
102 bn_sqr_comba4(t, a);
103 bn_montgomery_reduce_words(r, t, m, m0, n);
104 } else if (n == 6) {
105 bn_sqr_comba6(t, a);
106 bn_montgomery_reduce_words(r, t, m, m0, n);
107 } else if (n == 8) {
108 bn_sqr_comba8(t, a);
109 bn_montgomery_reduce_words(r, t, m, m0, n);
110 } else {
111 bn_montgomery_multiply_words(r, a, a, m, t, m0, n);
112 }
113}
114#endif
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index edd7bcd0c8..8280a8db27 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mont.c,v 1.66 2025/03/09 15:22:40 tb Exp $ */ 1/* $OpenBSD: bn_mont.c,v 1.69 2025/08/03 10:33:46 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -116,6 +116,7 @@
116 * sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf 116 * sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf
117 */ 117 */
118 118
119#include <limits.h>
119#include <stdio.h> 120#include <stdio.h>
120#include <stdint.h> 121#include <stdint.h>
121#include <string.h> 122#include <string.h>
@@ -214,7 +215,7 @@ BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
214 goto err; 215 goto err;
215 mont->N.neg = 0; 216 mont->N.neg = 0;
216 mont->ri = ((BN_num_bits(mod) + BN_BITS2 - 1) / BN_BITS2) * BN_BITS2; 217 mont->ri = ((BN_num_bits(mod) + BN_BITS2 - 1) / BN_BITS2) * BN_BITS2;
217 if (mont->ri * 2 < mont->ri) 218 if (mont->ri > INT_MAX / 2)
218 goto err; 219 goto err;
219 220
220 /* 221 /*
@@ -316,6 +317,44 @@ BN_MONT_CTX_set_locked(BN_MONT_CTX **pmctx, int lock, const BIGNUM *mod,
316LCRYPTO_ALIAS(BN_MONT_CTX_set_locked); 317LCRYPTO_ALIAS(BN_MONT_CTX_set_locked);
317 318
318/* 319/*
320 * bn_montgomery_reduce_words() performs Montgomery reduction, reducing the input
321 * from its Montgomery form aR to a, returning the result in r. a must be twice
322 * the length of the modulus. Note that the input is mutated in the process of
323 * performing the reduction.
324 */
325void
326bn_montgomery_reduce_words(BN_ULONG *r, BN_ULONG *a, const BN_ULONG *n,
327 BN_ULONG n0, int n_len)
328{
329 BN_ULONG v, mask;
330 BN_ULONG carry = 0;
331 int i;
332
333 /* Add multiples of the modulus, so that it becomes divisible by R. */
334 for (i = 0; i < n_len; i++) {
335 v = bn_mul_add_words(&a[i], n, n_len, a[i] * n0);
336 bn_addw_addw(v, a[i + n_len], carry, &carry, &a[i + n_len]);
337 }
338
339 /* Divide by R (this is the equivalent of right shifting by n_len). */
340 a = &a[n_len];
341
342 /*
343 * The output is now in the range of [0, 2N). Attempt to reduce once by
344 * subtracting the modulus. If the reduction was necessary then the
345 * result is already in r, otherwise copy the value prior to reduction
346 * from the top half of a.
347 */
348 mask = carry - bn_sub_words(r, a, n, n_len);
349
350 for (i = 0; i < n_len; i++) {
351 *r = (*r & ~mask) | (*a & mask);
352 r++;
353 a++;
354 }
355}
356
357/*
319 * bn_montgomery_reduce() performs Montgomery reduction, reducing the input 358 * bn_montgomery_reduce() performs Montgomery reduction, reducing the input
320 * from its Montgomery form aR to a, returning the result in r. Note that the 359 * from its Montgomery form aR to a, returning the result in r. Note that the
321 * input is mutated in the process of performing the reduction, destroying its 360 * input is mutated in the process of performing the reduction, destroying its
@@ -325,7 +364,6 @@ static int
325bn_montgomery_reduce(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mctx) 364bn_montgomery_reduce(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mctx)
326{ 365{
327 BIGNUM *n; 366 BIGNUM *n;
328 BN_ULONG *ap, *rp, n0, v, carry, mask;
329 int i, max, n_len; 367 int i, max, n_len;
330 368
331 n = &mctx->N; 369 n = &mctx->N;
@@ -341,7 +379,8 @@ bn_montgomery_reduce(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mctx)
341 379
342 /* 380 /*
343 * Expand a to twice the length of the modulus, zero if necessary. 381 * Expand a to twice the length of the modulus, zero if necessary.
344 * XXX - make this a requirement of the caller. 382 * XXX - make this a requirement of the caller or use a temporary
383 * allocation.
345 */ 384 */
346 if ((max = 2 * n_len) < n_len) 385 if ((max = 2 * n_len) < n_len)
347 return 0; 386 return 0;
@@ -350,33 +389,8 @@ bn_montgomery_reduce(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mctx)
350 for (i = a->top; i < max; i++) 389 for (i = a->top; i < max; i++)
351 a->d[i] = 0; 390 a->d[i] = 0;
352 391
353 carry = 0; 392 bn_montgomery_reduce_words(r->d, a->d, n->d, mctx->n0[0], n_len);
354 n0 = mctx->n0[0];
355 393
356 /* Add multiples of the modulus, so that it becomes divisible by R. */
357 for (i = 0; i < n_len; i++) {
358 v = bn_mul_add_words(&a->d[i], n->d, n_len, a->d[i] * n0);
359 bn_addw_addw(v, a->d[i + n_len], carry, &carry,
360 &a->d[i + n_len]);
361 }
362
363 /* Divide by R (this is the equivalent of right shifting by n_len). */
364 ap = &a->d[n_len];
365
366 /*
367 * The output is now in the range of [0, 2N). Attempt to reduce once by
368 * subtracting the modulus. If the reduction was necessary then the
369 * result is already in r, otherwise copy the value prior to reduction
370 * from the top half of a.
371 */
372 mask = carry - bn_sub_words(r->d, ap, n->d, n_len);
373
374 rp = r->d;
375 for (i = 0; i < n_len; i++) {
376 *rp = (*rp & ~mask) | (*ap & mask);
377 rp++;
378 ap++;
379 }
380 r->top = n_len; 394 r->top = n_len;
381 395
382 bn_correct_top(r); 396 bn_correct_top(r);
@@ -417,7 +431,7 @@ bn_mod_mul_montgomery_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
417 return ret; 431 return ret;
418} 432}
419 433
420static void 434static inline void
421bn_montgomery_multiply_word(const BN_ULONG *ap, BN_ULONG b, const BN_ULONG *np, 435bn_montgomery_multiply_word(const BN_ULONG *ap, BN_ULONG b, const BN_ULONG *np,
422 BN_ULONG *tp, BN_ULONG w, BN_ULONG *carry_a, BN_ULONG *carry_n, int n_len) 436 BN_ULONG *tp, BN_ULONG w, BN_ULONG *carry_a, BN_ULONG *carry_n, int n_len)
423{ 437{
@@ -452,7 +466,7 @@ bn_montgomery_multiply_word(const BN_ULONG *ap, BN_ULONG b, const BN_ULONG *np,
452 * given word arrays. The caller must ensure that rp, ap, bp and np are all 466 * given word arrays. The caller must ensure that rp, ap, bp and np are all
453 * n_len words in length, while tp must be n_len * 2 + 2 words in length. 467 * n_len words in length, while tp must be n_len * 2 + 2 words in length.
454 */ 468 */
455static void 469void
456bn_montgomery_multiply_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, 470bn_montgomery_multiply_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
457 const BN_ULONG *np, BN_ULONG *tp, BN_ULONG n0, int n_len) 471 const BN_ULONG *np, BN_ULONG *tp, BN_ULONG n0, int n_len)
458{ 472{
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index bdeb9b0fe8..a30d05fb02 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mul.c,v 1.39 2023/07/08 12:21:58 beck Exp $ */ 1/* $OpenBSD: bn_mul.c,v 1.43 2025/08/14 15:15:04 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -57,6 +57,7 @@
57 */ 57 */
58 58
59#include <assert.h> 59#include <assert.h>
60#include <limits.h>
60#include <stdio.h> 61#include <stdio.h>
61#include <string.h> 62#include <string.h>
62 63
@@ -73,7 +74,7 @@
73 */ 74 */
74#ifndef HAVE_BN_MUL_COMBA4 75#ifndef HAVE_BN_MUL_COMBA4
75void 76void
76bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) 77bn_mul_comba4(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b)
77{ 78{
78 BN_ULONG c0, c1, c2; 79 BN_ULONG c0, c1, c2;
79 80
@@ -103,13 +104,73 @@ bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
103#endif 104#endif
104 105
105/* 106/*
107 * bn_mul_comba6() computes r[] = a[] * b[] using Comba multiplication
108 * (https://everything2.com/title/Comba+multiplication), where a and b are both
109 * six word arrays, producing a 12 word array result.
110 */
111#ifndef HAVE_BN_MUL_COMBA6
112void
113bn_mul_comba6(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b)
114{
115 BN_ULONG c0, c1, c2;
116
117 bn_mulw_addtw(a[0], b[0], 0, 0, 0, &c2, &c1, &r[0]);
118
119 bn_mulw_addtw(a[0], b[1], 0, c2, c1, &c2, &c1, &c0);
120 bn_mulw_addtw(a[1], b[0], c2, c1, c0, &c2, &c1, &r[1]);
121
122 bn_mulw_addtw(a[2], b[0], 0, c2, c1, &c2, &c1, &c0);
123 bn_mulw_addtw(a[1], b[1], c2, c1, c0, &c2, &c1, &c0);
124 bn_mulw_addtw(a[0], b[2], c2, c1, c0, &c2, &c1, &r[2]);
125
126 bn_mulw_addtw(a[0], b[3], 0, c2, c1, &c2, &c1, &c0);
127 bn_mulw_addtw(a[1], b[2], c2, c1, c0, &c2, &c1, &c0);
128 bn_mulw_addtw(a[2], b[1], c2, c1, c0, &c2, &c1, &c0);
129 bn_mulw_addtw(a[3], b[0], c2, c1, c0, &c2, &c1, &r[3]);
130
131 bn_mulw_addtw(a[4], b[0], 0, c2, c1, &c2, &c1, &c0);
132 bn_mulw_addtw(a[3], b[1], c2, c1, c0, &c2, &c1, &c0);
133 bn_mulw_addtw(a[2], b[2], c2, c1, c0, &c2, &c1, &c0);
134 bn_mulw_addtw(a[1], b[3], c2, c1, c0, &c2, &c1, &c0);
135 bn_mulw_addtw(a[0], b[4], c2, c1, c0, &c2, &c1, &r[4]);
136
137 bn_mulw_addtw(a[0], b[5], 0, c2, c1, &c2, &c1, &c0);
138 bn_mulw_addtw(a[1], b[4], c2, c1, c0, &c2, &c1, &c0);
139 bn_mulw_addtw(a[2], b[3], c2, c1, c0, &c2, &c1, &c0);
140 bn_mulw_addtw(a[3], b[2], c2, c1, c0, &c2, &c1, &c0);
141 bn_mulw_addtw(a[4], b[1], c2, c1, c0, &c2, &c1, &c0);
142 bn_mulw_addtw(a[5], b[0], c2, c1, c0, &c2, &c1, &r[5]);
143
144 bn_mulw_addtw(a[5], b[1], 0, c2, c1, &c2, &c1, &c0);
145 bn_mulw_addtw(a[4], b[2], c2, c1, c0, &c2, &c1, &c0);
146 bn_mulw_addtw(a[3], b[3], c2, c1, c0, &c2, &c1, &c0);
147 bn_mulw_addtw(a[2], b[4], c2, c1, c0, &c2, &c1, &c0);
148 bn_mulw_addtw(a[1], b[5], c2, c1, c0, &c2, &c1, &r[6]);
149
150 bn_mulw_addtw(a[2], b[5], 0, c2, c1, &c2, &c1, &c0);
151 bn_mulw_addtw(a[3], b[4], c2, c1, c0, &c2, &c1, &c0);
152 bn_mulw_addtw(a[4], b[3], c2, c1, c0, &c2, &c1, &c0);
153 bn_mulw_addtw(a[5], b[2], c2, c1, c0, &c2, &c1, &r[7]);
154
155 bn_mulw_addtw(a[5], b[3], 0, c2, c1, &c2, &c1, &c0);
156 bn_mulw_addtw(a[4], b[4], c2, c1, c0, &c2, &c1, &c0);
157 bn_mulw_addtw(a[3], b[5], c2, c1, c0, &c2, &c1, &r[8]);
158
159 bn_mulw_addtw(a[4], b[5], 0, c2, c1, &c2, &c1, &c0);
160 bn_mulw_addtw(a[5], b[4], c2, c1, c0, &c2, &c1, &r[9]);
161
162 bn_mulw_addtw(a[5], b[5], 0, c2, c1, &c2, &r[11], &r[10]);
163}
164#endif
165
166/*
106 * bn_mul_comba8() computes r[] = a[] * b[] using Comba multiplication 167 * bn_mul_comba8() computes r[] = a[] * b[] using Comba multiplication
107 * (https://everything2.com/title/Comba+multiplication), where a and b are both 168 * (https://everything2.com/title/Comba+multiplication), where a and b are both
108 * eight word arrays, producing a 16 word array result. 169 * eight word arrays, producing a 16 word array result.
109 */ 170 */
110#ifndef HAVE_BN_MUL_COMBA8 171#ifndef HAVE_BN_MUL_COMBA8
111void 172void
112bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) 173bn_mul_comba8(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b)
113{ 174{
114 BN_ULONG c0, c1, c2; 175 BN_ULONG c0, c1, c2;
115 176
@@ -338,14 +399,16 @@ BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
338 if (rr == NULL) 399 if (rr == NULL)
339 goto err; 400 goto err;
340 401
341 rn = a->top + b->top; 402 if (a->top > INT_MAX - b->top)
342 if (rn < a->top)
343 goto err; 403 goto err;
404 rn = a->top + b->top;
344 if (!bn_wexpand(rr, rn)) 405 if (!bn_wexpand(rr, rn))
345 goto err; 406 goto err;
346 407
347 if (a->top == 4 && b->top == 4) { 408 if (a->top == 4 && b->top == 4) {
348 bn_mul_comba4(rr->d, a->d, b->d); 409 bn_mul_comba4(rr->d, a->d, b->d);
410 } else if (a->top == 6 && b->top == 6) {
411 bn_mul_comba6(rr->d, a->d, b->d);
349 } else if (a->top == 8 && b->top == 8) { 412 } else if (a->top == 8 && b->top == 8) {
350 bn_mul_comba8(rr->d, a->d, b->d); 413 bn_mul_comba8(rr->d, a->d, b->d);
351 } else { 414 } else {
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c
index 5a4aa50bf1..d85595e0dd 100644
--- a/src/lib/libcrypto/bn/bn_prime.c
+++ b/src/lib/libcrypto/bn/bn_prime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_prime.c,v 1.34 2023/07/20 06:26:27 tb Exp $ */ 1/* $OpenBSD: bn_prime.c,v 1.35 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -112,9 +112,8 @@
112#include <stdio.h> 112#include <stdio.h>
113#include <time.h> 113#include <time.h>
114 114
115#include <openssl/err.h>
116
117#include "bn_local.h" 115#include "bn_local.h"
116#include "err_local.h"
118 117
119/* The quick sieve algorithm approach to weeding out primes is 118/* The quick sieve algorithm approach to weeding out primes is
120 * Philip Zimmermann's, as implemented in PGP. I have had a read of 119 * Philip Zimmermann's, as implemented in PGP. I have had a read of
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index 9cfcd8e2c0..d3b16f70a0 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_rand.c,v 1.30 2024/03/16 20:42:33 tb Exp $ */ 1/* $OpenBSD: bn_rand.c,v 1.31 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -115,9 +115,8 @@
115#include <string.h> 115#include <string.h>
116#include <time.h> 116#include <time.h>
117 117
118#include <openssl/err.h>
119
120#include "bn_local.h" 118#include "bn_local.h"
119#include "err_local.h"
121 120
122static int 121static int
123bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) 122bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
diff --git a/src/lib/libcrypto/bn/bn_recp.c b/src/lib/libcrypto/bn/bn_recp.c
index e3f22c52a9..ed5049b772 100644
--- a/src/lib/libcrypto/bn/bn_recp.c
+++ b/src/lib/libcrypto/bn/bn_recp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_recp.c,v 1.33 2025/02/04 20:22:20 tb Exp $ */ 1/* $OpenBSD: bn_recp.c,v 1.34 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -58,9 +58,8 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62
63#include "bn_local.h" 61#include "bn_local.h"
62#include "err_local.h"
64 63
65struct bn_recp_ctx_st { 64struct bn_recp_ctx_st {
66 BIGNUM *N; /* the divisor */ 65 BIGNUM *N; /* the divisor */
diff --git a/src/lib/libcrypto/bn/bn_shift.c b/src/lib/libcrypto/bn/bn_shift.c
index 12edc7c0a0..b9f73cc322 100644
--- a/src/lib/libcrypto/bn/bn_shift.c
+++ b/src/lib/libcrypto/bn/bn_shift.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_shift.c,v 1.22 2023/07/08 12:21:58 beck Exp $ */ 1/* $OpenBSD: bn_shift.c,v 1.23 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022, 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2022, 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -16,9 +16,9 @@
16 */ 16 */
17 17
18#include <openssl/bn.h> 18#include <openssl/bn.h>
19#include <openssl/err.h>
20 19
21#include "bn_local.h" 20#include "bn_local.h"
21#include "err_local.h"
22 22
23static inline int 23static inline int
24bn_lshift(BIGNUM *r, const BIGNUM *a, int n) 24bn_lshift(BIGNUM *r, const BIGNUM *a, int n)
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c
index 0dbccbf85d..2f7f71f819 100644
--- a/src/lib/libcrypto/bn/bn_sqr.c
+++ b/src/lib/libcrypto/bn/bn_sqr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_sqr.c,v 1.36 2023/07/08 12:21:58 beck Exp $ */ 1/* $OpenBSD: bn_sqr.c,v 1.38 2025/08/14 15:15:04 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -97,6 +97,51 @@ bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
97#endif 97#endif
98 98
99/* 99/*
100 * bn_sqr_comba6() computes r[] = a[] * a[] using Comba multiplication
101 * (https://everything2.com/title/Comba+multiplication), where a is an
102 * six word array, producing an 12 word array result.
103 */
104#ifndef HAVE_BN_SQR_COMBA6
105void
106bn_sqr_comba6(BN_ULONG *r, const BN_ULONG *a)
107{
108 BN_ULONG c2, c1, c0;
109
110 bn_mulw_addtw(a[0], a[0], 0, 0, 0, &c2, &c1, &r[0]);
111
112 bn_mul2_mulw_addtw(a[1], a[0], 0, c2, c1, &c2, &c1, &r[1]);
113
114 bn_mulw_addtw(a[1], a[1], 0, c2, c1, &c2, &c1, &c0);
115 bn_mul2_mulw_addtw(a[2], a[0], c2, c1, c0, &c2, &c1, &r[2]);
116
117 bn_mul2_mulw_addtw(a[3], a[0], 0, c2, c1, &c2, &c1, &c0);
118 bn_mul2_mulw_addtw(a[2], a[1], c2, c1, c0, &c2, &c1, &r[3]);
119
120 bn_mulw_addtw(a[2], a[2], 0, c2, c1, &c2, &c1, &c0);
121 bn_mul2_mulw_addtw(a[3], a[1], c2, c1, c0, &c2, &c1, &c0);
122 bn_mul2_mulw_addtw(a[4], a[0], c2, c1, c0, &c2, &c1, &r[4]);
123
124 bn_mul2_mulw_addtw(a[5], a[0], 0, c2, c1, &c2, &c1, &c0);
125 bn_mul2_mulw_addtw(a[4], a[1], c2, c1, c0, &c2, &c1, &c0);
126 bn_mul2_mulw_addtw(a[3], a[2], c2, c1, c0, &c2, &c1, &r[5]);
127
128 bn_mulw_addtw(a[3], a[3], 0, c2, c1, &c2, &c1, &c0);
129 bn_mul2_mulw_addtw(a[4], a[2], c2, c1, c0, &c2, &c1, &c0);
130 bn_mul2_mulw_addtw(a[5], a[1], c2, c1, c0, &c2, &c1, &r[6]);
131
132 bn_mul2_mulw_addtw(a[5], a[2], 0, c2, c1, &c2, &c1, &c0);
133 bn_mul2_mulw_addtw(a[4], a[3], c2, c1, c0, &c2, &c1, &r[7]);
134
135 bn_mulw_addtw(a[4], a[4], 0, c2, c1, &c2, &c1, &c0);
136 bn_mul2_mulw_addtw(a[5], a[3], c2, c1, c0, &c2, &c1, &r[8]);
137
138 bn_mul2_mulw_addtw(a[5], a[4], 0, c2, c1, &c2, &c1, &r[9]);
139
140 bn_mulw_addtw(a[5], a[5], 0, c2, c1, &c2, &r[11], &r[10]);
141}
142#endif
143
144/*
100 * bn_sqr_comba8() computes r[] = a[] * a[] using Comba multiplication 145 * bn_sqr_comba8() computes r[] = a[] * a[] using Comba multiplication
101 * (https://everything2.com/title/Comba+multiplication), where a is an 146 * (https://everything2.com/title/Comba+multiplication), where a is an
102 * eight word array, producing an 16 word array result. 147 * eight word array, producing an 16 word array result.
@@ -281,6 +326,8 @@ BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
281 326
282 if (a->top == 4) { 327 if (a->top == 4) {
283 bn_sqr_comba4(rr->d, a->d); 328 bn_sqr_comba4(rr->d, a->d);
329 } else if (a->top == 6) {
330 bn_sqr_comba6(rr->d, a->d);
284 } else if (a->top == 8) { 331 } else if (a->top == 8) {
285 bn_sqr_comba8(rr->d, a->d); 332 bn_sqr_comba8(rr->d, a->d);
286 } else { 333 } else {
diff --git a/src/lib/libcrypto/bn/s2n_bignum.h b/src/lib/libcrypto/bn/s2n_bignum.h
index ce6e8cdc94..7d77894cdc 100644
--- a/src/lib/libcrypto/bn/s2n_bignum.h
+++ b/src/lib/libcrypto/bn/s2n_bignum.h
@@ -1,3 +1,5 @@
1// $OpenBSD: s2n_bignum.h,v 1.4 2025/08/12 10:01:37 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -34,182 +36,240 @@
34// throughput, generally offering higher performance there. 36// throughput, generally offering higher performance there.
35// ---------------------------------------------------------------------------- 37// ----------------------------------------------------------------------------
36 38
39
40#if defined(_MSC_VER) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L || defined(__STDC_NO_VLA__)
41#define S2N_BIGNUM_STATIC
42#else
43#define S2N_BIGNUM_STATIC static
44#endif
45
37// Add, z := x + y 46// Add, z := x + y
38// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] 47// Inputs x[m], y[n]; outputs function return (carry-out) and z[p]
39extern uint64_t bignum_add (uint64_t p, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 48extern uint64_t bignum_add (uint64_t p, uint64_t *z, uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
40 49
41// Add modulo p_25519, z := (x + y) mod p_25519, assuming x and y reduced 50// Add modulo p_25519, z := (x + y) mod p_25519, assuming x and y reduced
42// Inputs x[4], y[4]; output z[4] 51// Inputs x[4], y[4]; output z[4]
43extern void bignum_add_p25519 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 52extern void bignum_add_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
44 53
45// Add modulo p_256, z := (x + y) mod p_256, assuming x and y reduced 54// Add modulo p_256, z := (x + y) mod p_256, assuming x and y reduced
46// Inputs x[4], y[4]; output z[4] 55// Inputs x[4], y[4]; output z[4]
47extern void bignum_add_p256 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 56extern void bignum_add_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
48 57
49// Add modulo p_256k1, z := (x + y) mod p_256k1, assuming x and y reduced 58// Add modulo p_256k1, z := (x + y) mod p_256k1, assuming x and y reduced
50// Inputs x[4], y[4]; output z[4] 59// Inputs x[4], y[4]; output z[4]
51extern void bignum_add_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 60extern void bignum_add_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
52 61
53// Add modulo p_384, z := (x + y) mod p_384, assuming x and y reduced 62// Add modulo p_384, z := (x + y) mod p_384, assuming x and y reduced
54// Inputs x[6], y[6]; output z[6] 63// Inputs x[6], y[6]; output z[6]
55extern void bignum_add_p384 (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); 64extern void bignum_add_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6], const uint64_t y[S2N_BIGNUM_STATIC 6]);
56 65
57// Add modulo p_521, z := (x + y) mod p_521, assuming x and y reduced 66// Add modulo p_521, z := (x + y) mod p_521, assuming x and y reduced
58// Inputs x[9], y[9]; output z[9] 67// Inputs x[9], y[9]; output z[9]
59extern void bignum_add_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); 68extern void bignum_add_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9], const uint64_t y[S2N_BIGNUM_STATIC 9]);
69
70// Add modulo p_sm2, z := (x + y) mod p_sm2, assuming x and y reduced
71// Inputs x[4], y[4]; output z[4]
72extern void bignum_add_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
60 73
61// Compute "amontification" constant z :== 2^{128k} (congruent mod m) 74// Compute "amontification" constant z :== 2^{128k} (congruent mod m)
62// Input m[k]; output z[k]; temporary buffer t[>=k] 75// Input m[k]; output z[k]; temporary buffer t[>=k]
63extern void bignum_amontifier (uint64_t k, uint64_t *z, uint64_t *m, uint64_t *t); 76extern void bignum_amontifier (uint64_t k, uint64_t *z, const uint64_t *m, uint64_t *t);
64 77
65// Almost-Montgomery multiply, z :== (x * y / 2^{64k}) (congruent mod m) 78// Almost-Montgomery multiply, z :== (x * y / 2^{64k}) (congruent mod m)
66// Inputs x[k], y[k], m[k]; output z[k] 79// Inputs x[k], y[k], m[k]; output z[k]
67extern void bignum_amontmul (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); 80extern void bignum_amontmul (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *y, const uint64_t *m);
68 81
69// Almost-Montgomery reduce, z :== (x' / 2^{64p}) (congruent mod m) 82// Almost-Montgomery reduce, z :== (x' / 2^{64p}) (congruent mod m)
70// Inputs x[n], m[k], p; output z[k] 83// Inputs x[n], m[k], p; output z[k]
71extern void bignum_amontredc (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t *m, uint64_t p); 84extern void bignum_amontredc (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x, const uint64_t *m, uint64_t p);
72 85
73// Almost-Montgomery square, z :== (x^2 / 2^{64k}) (congruent mod m) 86// Almost-Montgomery square, z :== (x^2 / 2^{64k}) (congruent mod m)
74// Inputs x[k], m[k]; output z[k] 87// Inputs x[k], m[k]; output z[k]
75extern void bignum_amontsqr (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); 88extern void bignum_amontsqr (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *m);
76 89
77// Convert 4-digit (256-bit) bignum to/from big-endian form 90// Convert 4-digit (256-bit) bignum to/from big-endian form
78// Input x[4]; output z[4] 91// Input x[4]; output z[4]
79extern void bignum_bigendian_4 (uint64_t z[static 4], uint64_t x[static 4]); 92extern void bignum_bigendian_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
80 93
81// Convert 6-digit (384-bit) bignum to/from big-endian form 94// Convert 6-digit (384-bit) bignum to/from big-endian form
82// Input x[6]; output z[6] 95// Input x[6]; output z[6]
83extern void bignum_bigendian_6 (uint64_t z[static 6], uint64_t x[static 6]); 96extern void bignum_bigendian_6 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
84 97
85// Select bitfield starting at bit n with length l <= 64 98// Select bitfield starting at bit n with length l <= 64
86// Inputs x[k], n, l; output function return 99// Inputs x[k], n, l; output function return
87extern uint64_t bignum_bitfield (uint64_t k, uint64_t *x, uint64_t n, uint64_t l); 100extern uint64_t bignum_bitfield (uint64_t k, const uint64_t *x, uint64_t n, uint64_t l);
88 101
89// Return size of bignum in bits 102// Return size of bignum in bits
90// Input x[k]; output function return 103// Input x[k]; output function return
91extern uint64_t bignum_bitsize (uint64_t k, uint64_t *x); 104extern uint64_t bignum_bitsize (uint64_t k, const uint64_t *x);
92 105
93// Divide by a single (nonzero) word, z := x / m and return x mod m 106// Divide by a single (nonzero) word, z := x / m and return x mod m
94// Inputs x[n], m; outputs function return (remainder) and z[k] 107// Inputs x[n], m; outputs function return (remainder) and z[k]
95extern uint64_t bignum_cdiv (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t m); 108extern uint64_t bignum_cdiv (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x, uint64_t m);
96 109
97// Divide by a single word, z := x / m when known to be exact 110// Divide by a single word, z := x / m when known to be exact
98// Inputs x[n], m; output z[k] 111// Inputs x[n], m; output z[k]
99extern void bignum_cdiv_exact (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t m); 112extern void bignum_cdiv_exact (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x, uint64_t m);
100 113
101// Count leading zero digits (64-bit words) 114// Count leading zero digits (64-bit words)
102// Input x[k]; output function return 115// Input x[k]; output function return
103extern uint64_t bignum_cld (uint64_t k, uint64_t *x); 116extern uint64_t bignum_cld (uint64_t k, const uint64_t *x);
104 117
105// Count leading zero bits 118// Count leading zero bits
106// Input x[k]; output function return 119// Input x[k]; output function return
107extern uint64_t bignum_clz (uint64_t k, uint64_t *x); 120extern uint64_t bignum_clz (uint64_t k, const uint64_t *x);
108 121
109// Multiply-add with single-word multiplier, z := z + c * y 122// Multiply-add with single-word multiplier, z := z + c * y
110// Inputs c, y[n]; outputs function return (carry-out) and z[k] 123// Inputs c, y[n]; outputs function return (carry-out) and z[k]
111extern uint64_t bignum_cmadd (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); 124extern uint64_t bignum_cmadd (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, const uint64_t *y);
112 125
113// Negated multiply-add with single-word multiplier, z := z - c * y 126// Negated multiply-add with single-word multiplier, z := z - c * y
114// Inputs c, y[n]; outputs function return (negative carry-out) and z[k] 127// Inputs c, y[n]; outputs function return (negative carry-out) and z[k]
115extern uint64_t bignum_cmnegadd (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); 128extern uint64_t bignum_cmnegadd (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, const uint64_t *y);
116 129
117// Find modulus of bignum w.r.t. single nonzero word m, returning x mod m 130// Find modulus of bignum w.r.t. single nonzero word m, returning x mod m
118// Input x[k], m; output function return 131// Input x[k], m; output function return
119extern uint64_t bignum_cmod (uint64_t k, uint64_t *x, uint64_t m); 132extern uint64_t bignum_cmod (uint64_t k, const uint64_t *x, uint64_t m);
120 133
121// Multiply by a single word, z := c * y 134// Multiply by a single word, z := c * y
122// Inputs c, y[n]; outputs function return (carry-out) and z[k] 135// Inputs c, y[n]; outputs function return (carry-out) and z[k]
123extern uint64_t bignum_cmul (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); 136extern uint64_t bignum_cmul (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, const uint64_t *y);
124 137
125// Multiply by a single word modulo p_25519, z := (c * x) mod p_25519, assuming x reduced 138// Multiply by a single word modulo p_25519, z := (c * x) mod p_25519, assuming x reduced
126// Inputs c, x[4]; output z[4] 139// Inputs c, x[4]; output z[4]
127extern void bignum_cmul_p25519 (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); 140extern void bignum_cmul_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
128extern void bignum_cmul_p25519_alt (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); 141extern void bignum_cmul_p25519_alt (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
129 142
130// Multiply by a single word modulo p_256, z := (c * x) mod p_256, assuming x reduced 143// Multiply by a single word modulo p_256, z := (c * x) mod p_256, assuming x reduced
131// Inputs c, x[4]; output z[4] 144// Inputs c, x[4]; output z[4]
132extern void bignum_cmul_p256 (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); 145extern void bignum_cmul_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
133extern void bignum_cmul_p256_alt (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); 146extern void bignum_cmul_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
134 147
135// Multiply by a single word modulo p_256k1, z := (c * x) mod p_256k1, assuming x reduced 148// Multiply by a single word modulo p_256k1, z := (c * x) mod p_256k1, assuming x reduced
136// Inputs c, x[4]; output z[4] 149// Inputs c, x[4]; output z[4]
137extern void bignum_cmul_p256k1 (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); 150extern void bignum_cmul_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
138extern void bignum_cmul_p256k1_alt (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); 151extern void bignum_cmul_p256k1_alt (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
139 152
140// Multiply by a single word modulo p_384, z := (c * x) mod p_384, assuming x reduced 153// Multiply by a single word modulo p_384, z := (c * x) mod p_384, assuming x reduced
141// Inputs c, x[6]; output z[6] 154// Inputs c, x[6]; output z[6]
142extern void bignum_cmul_p384 (uint64_t z[static 6], uint64_t c, uint64_t x[static 6]); 155extern void bignum_cmul_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 6]);
143extern void bignum_cmul_p384_alt (uint64_t z[static 6], uint64_t c, uint64_t x[static 6]); 156extern void bignum_cmul_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 6]);
144 157
145// Multiply by a single word modulo p_521, z := (c * x) mod p_521, assuming x reduced 158// Multiply by a single word modulo p_521, z := (c * x) mod p_521, assuming x reduced
146// Inputs c, x[9]; output z[9] 159// Inputs c, x[9]; output z[9]
147extern void bignum_cmul_p521 (uint64_t z[static 9], uint64_t c, uint64_t x[static 9]); 160extern void bignum_cmul_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 9]);
148extern void bignum_cmul_p521_alt (uint64_t z[static 9], uint64_t c, uint64_t x[static 9]); 161extern void bignum_cmul_p521_alt (uint64_t z[S2N_BIGNUM_STATIC 9], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 9]);
162
163// Multiply by a single word modulo p_sm2, z := (c * x) mod p_sm2, assuming x reduced
164// Inputs c, x[4]; output z[4]
165extern void bignum_cmul_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
166extern void bignum_cmul_sm2_alt (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t c, const uint64_t x[S2N_BIGNUM_STATIC 4]);
149 167
150// Test bignums for coprimality, gcd(x,y) = 1 168// Test bignums for coprimality, gcd(x,y) = 1
151// Inputs x[m], y[n]; output function return; temporary buffer t[>=2*max(m,n)] 169// Inputs x[m], y[n]; output function return; temporary buffer t[>=2*max(m,n)]
152extern uint64_t bignum_coprime (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y, uint64_t *t); 170extern uint64_t bignum_coprime (uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y, uint64_t *t);
153 171
154// Copy bignum with zero-extension or truncation, z := x 172// Copy bignum with zero-extension or truncation, z := x
155// Input x[n]; output z[k] 173// Input x[n]; output z[k]
156extern void bignum_copy (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x); 174extern void bignum_copy (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x);
175
176// Given table: uint64_t[height*width], copy table[idx*width...(idx+1)*width-1]
177// into z[0..width-1].
178// This function is constant-time with respect to the value of `idx`. This is
179// achieved by reading the whole table and using the bit-masking to get the
180// `idx`-th row.
181// Input table[height*width]; output z[width]
182extern void bignum_copy_row_from_table (uint64_t *z, const uint64_t *table, uint64_t height,
183 uint64_t width, uint64_t idx);
184
185// Given table: uint64_t[height*width], copy table[idx*width...(idx+1)*width-1]
186// into z[0..width-1]. width must be a multiple of 8.
187// This function is constant-time with respect to the value of `idx`. This is
188// achieved by reading the whole table and using the bit-masking to get the
189// `idx`-th row.
190// Input table[height*width]; output z[width]
191extern void bignum_copy_row_from_table_8n (uint64_t *z, const uint64_t *table,
192 uint64_t height, uint64_t width, uint64_t idx);
193
194// Given table: uint64_t[height*16], copy table[idx*16...(idx+1)*16-1] into z[0..row-1].
195// This function is constant-time with respect to the value of `idx`. This is
196// achieved by reading the whole table and using the bit-masking to get the
197// `idx`-th row.
198// Input table[height*16]; output z[16]
199extern void bignum_copy_row_from_table_16 (uint64_t *z, const uint64_t *table,
200 uint64_t height, uint64_t idx);
201
202// Given table: uint64_t[height*32], copy table[idx*32...(idx+1)*32-1] into z[0..row-1].
203// This function is constant-time with respect to the value of `idx`. This is
204// achieved by reading the whole table and using the bit-masking to get the
205// `idx`-th row.
206// Input table[height*32]; output z[32]
207extern void bignum_copy_row_from_table_32 (uint64_t *z, const uint64_t *table,
208 uint64_t height, uint64_t idx);
157 209
158// Count trailing zero digits (64-bit words) 210// Count trailing zero digits (64-bit words)
159// Input x[k]; output function return 211// Input x[k]; output function return
160extern uint64_t bignum_ctd (uint64_t k, uint64_t *x); 212extern uint64_t bignum_ctd (uint64_t k, const uint64_t *x);
161 213
162// Count trailing zero bits 214// Count trailing zero bits
163// Input x[k]; output function return 215// Input x[k]; output function return
164extern uint64_t bignum_ctz (uint64_t k, uint64_t *x); 216extern uint64_t bignum_ctz (uint64_t k, const uint64_t *x);
165 217
166// Convert from almost-Montgomery form, z := (x / 2^256) mod p_256 218// Convert from almost-Montgomery form, z := (x / 2^256) mod p_256
167// Input x[4]; output z[4] 219// Input x[4]; output z[4]
168extern void bignum_deamont_p256 (uint64_t z[static 4], uint64_t x[static 4]); 220extern void bignum_deamont_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
169extern void bignum_deamont_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); 221extern void bignum_deamont_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
170 222
171// Convert from almost-Montgomery form, z := (x / 2^256) mod p_256k1 223// Convert from almost-Montgomery form, z := (x / 2^256) mod p_256k1
172// Input x[4]; output z[4] 224// Input x[4]; output z[4]
173extern void bignum_deamont_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 225extern void bignum_deamont_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
174 226
175// Convert from almost-Montgomery form, z := (x / 2^384) mod p_384 227// Convert from almost-Montgomery form, z := (x / 2^384) mod p_384
176// Input x[6]; output z[6] 228// Input x[6]; output z[6]
177extern void bignum_deamont_p384 (uint64_t z[static 6], uint64_t x[static 6]); 229extern void bignum_deamont_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
178extern void bignum_deamont_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); 230extern void bignum_deamont_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
179 231
180// Convert from almost-Montgomery form z := (x / 2^576) mod p_521 232// Convert from almost-Montgomery form z := (x / 2^576) mod p_521
181// Input x[9]; output z[9] 233// Input x[9]; output z[9]
182extern void bignum_deamont_p521 (uint64_t z[static 9], uint64_t x[static 9]); 234extern void bignum_deamont_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
235
236// Convert from almost-Montgomery form z := (x / 2^256) mod p_sm2
237// Input x[4]; output z[4]
238extern void bignum_deamont_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
183 239
184// Convert from (almost-)Montgomery form z := (x / 2^{64k}) mod m 240// Convert from (almost-)Montgomery form z := (x / 2^{64k}) mod m
185// Inputs x[k], m[k]; output z[k] 241// Inputs x[k], m[k]; output z[k]
186extern void bignum_demont (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); 242extern void bignum_demont (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *m);
187 243
188// Convert from Montgomery form z := (x / 2^256) mod p_256, assuming x reduced 244// Convert from Montgomery form z := (x / 2^256) mod p_256, assuming x reduced
189// Input x[4]; output z[4] 245// Input x[4]; output z[4]
190extern void bignum_demont_p256 (uint64_t z[static 4], uint64_t x[static 4]); 246extern void bignum_demont_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
191extern void bignum_demont_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); 247extern void bignum_demont_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
192 248
193// Convert from Montgomery form z := (x / 2^256) mod p_256k1, assuming x reduced 249// Convert from Montgomery form z := (x / 2^256) mod p_256k1, assuming x reduced
194// Input x[4]; output z[4] 250// Input x[4]; output z[4]
195extern void bignum_demont_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 251extern void bignum_demont_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
196 252
197// Convert from Montgomery form z := (x / 2^384) mod p_384, assuming x reduced 253// Convert from Montgomery form z := (x / 2^384) mod p_384, assuming x reduced
198// Input x[6]; output z[6] 254// Input x[6]; output z[6]
199extern void bignum_demont_p384 (uint64_t z[static 6], uint64_t x[static 6]); 255extern void bignum_demont_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
200extern void bignum_demont_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); 256extern void bignum_demont_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
201 257
202// Convert from Montgomery form z := (x / 2^576) mod p_521, assuming x reduced 258// Convert from Montgomery form z := (x / 2^576) mod p_521, assuming x reduced
203// Input x[9]; output z[9] 259// Input x[9]; output z[9]
204extern void bignum_demont_p521 (uint64_t z[static 9], uint64_t x[static 9]); 260extern void bignum_demont_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
261
262// Convert from Montgomery form z := (x / 2^256) mod p_sm2, assuming x reduced
263// Input x[4]; output z[4]
264extern void bignum_demont_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
205 265
206// Select digit x[n] 266// Select digit x[n]
207// Inputs x[k], n; output function return 267// Inputs x[k], n; output function return
208extern uint64_t bignum_digit (uint64_t k, uint64_t *x, uint64_t n); 268extern uint64_t bignum_digit (uint64_t k, const uint64_t *x, uint64_t n);
209 269
210// Return size of bignum in digits (64-bit word) 270// Return size of bignum in digits (64-bit word)
211// Input x[k]; output function return 271// Input x[k]; output function return
212extern uint64_t bignum_digitsize (uint64_t k, uint64_t *x); 272extern uint64_t bignum_digitsize (uint64_t k, const uint64_t *x);
213 273
214// Divide bignum by 10: z' := z div 10, returning remainder z mod 10 274// Divide bignum by 10: z' := z div 10, returning remainder z mod 10
215// Inputs z[k]; outputs function return (remainder) and z[k] 275// Inputs z[k]; outputs function return (remainder) and z[k]
@@ -217,294 +277,391 @@ extern uint64_t bignum_divmod10 (uint64_t k, uint64_t *z);
217 277
218// Double modulo p_25519, z := (2 * x) mod p_25519, assuming x reduced 278// Double modulo p_25519, z := (2 * x) mod p_25519, assuming x reduced
219// Input x[4]; output z[4] 279// Input x[4]; output z[4]
220extern void bignum_double_p25519 (uint64_t z[static 4], uint64_t x[static 4]); 280extern void bignum_double_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
221 281
222// Double modulo p_256, z := (2 * x) mod p_256, assuming x reduced 282// Double modulo p_256, z := (2 * x) mod p_256, assuming x reduced
223// Input x[4]; output z[4] 283// Input x[4]; output z[4]
224extern void bignum_double_p256 (uint64_t z[static 4], uint64_t x[static 4]); 284extern void bignum_double_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
225 285
226// Double modulo p_256k1, z := (2 * x) mod p_256k1, assuming x reduced 286// Double modulo p_256k1, z := (2 * x) mod p_256k1, assuming x reduced
227// Input x[4]; output z[4] 287// Input x[4]; output z[4]
228extern void bignum_double_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 288extern void bignum_double_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
229 289
230// Double modulo p_384, z := (2 * x) mod p_384, assuming x reduced 290// Double modulo p_384, z := (2 * x) mod p_384, assuming x reduced
231// Input x[6]; output z[6] 291// Input x[6]; output z[6]
232extern void bignum_double_p384 (uint64_t z[static 6], uint64_t x[static 6]); 292extern void bignum_double_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
233 293
234// Double modulo p_521, z := (2 * x) mod p_521, assuming x reduced 294// Double modulo p_521, z := (2 * x) mod p_521, assuming x reduced
235// Input x[9]; output z[9] 295// Input x[9]; output z[9]
236extern void bignum_double_p521 (uint64_t z[static 9], uint64_t x[static 9]); 296extern void bignum_double_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
297
298// Double modulo p_sm2, z := (2 * x) mod p_sm2, assuming x reduced
299// Input x[4]; output z[4]
300extern void bignum_double_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
237 301
238// Extended Montgomery reduce, returning results in input-output buffer 302// Extended Montgomery reduce, returning results in input-output buffer
239// Inputs z[2*k], m[k], w; outputs function return (extra result bit) and z[2*k] 303// Inputs z[2*k], m[k], w; outputs function return (extra result bit) and z[2*k]
240extern uint64_t bignum_emontredc (uint64_t k, uint64_t *z, uint64_t *m, uint64_t w); 304extern uint64_t bignum_emontredc (uint64_t k, uint64_t *z, const uint64_t *m, uint64_t w);
241 305
242// Extended Montgomery reduce in 8-digit blocks, results in input-output buffer 306// Extended Montgomery reduce in 8-digit blocks, results in input-output buffer
243// Inputs z[2*k], m[k], w; outputs function return (extra result bit) and z[2*k] 307// Inputs z[2*k], m[k], w; outputs function return (extra result bit) and z[2*k]
244extern uint64_t bignum_emontredc_8n (uint64_t k, uint64_t *z, uint64_t *m, uint64_t w); 308extern uint64_t bignum_emontredc_8n (uint64_t k, uint64_t *z, const uint64_t *m, uint64_t w);
309// Inputs z[2*k], m[k], w; outputs function return (extra result bit) and z[2*k]
310// Temporary buffer m_precalc[12*(k/4-1)]
311extern uint64_t bignum_emontredc_8n_cdiff (uint64_t k, uint64_t *z, const uint64_t *m,
312 uint64_t w, uint64_t *m_precalc);
245 313
246// Test bignums for equality, x = y 314// Test bignums for equality, x = y
247// Inputs x[m], y[n]; output function return 315// Inputs x[m], y[n]; output function return
248extern uint64_t bignum_eq (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 316extern uint64_t bignum_eq (uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
249 317
250// Test bignum for even-ness 318// Test bignum for even-ness
251// Input x[k]; output function return 319// Input x[k]; output function return
252extern uint64_t bignum_even (uint64_t k, uint64_t *x); 320extern uint64_t bignum_even (uint64_t k, const uint64_t *x);
253 321
254// Convert 4-digit (256-bit) bignum from big-endian bytes 322// Convert 4-digit (256-bit) bignum from big-endian bytes
255// Input x[32] (bytes); output z[4] 323// Input x[32] (bytes); output z[4]
256extern void bignum_frombebytes_4 (uint64_t z[static 4], uint8_t x[static 32]); 324extern void bignum_frombebytes_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint8_t x[S2N_BIGNUM_STATIC 32]);
257 325
258// Convert 6-digit (384-bit) bignum from big-endian bytes 326// Convert 6-digit (384-bit) bignum from big-endian bytes
259// Input x[48] (bytes); output z[6] 327// Input x[48] (bytes); output z[6]
260extern void bignum_frombebytes_6 (uint64_t z[static 6], uint8_t x[static 48]); 328extern void bignum_frombebytes_6 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint8_t x[S2N_BIGNUM_STATIC 48]);
261 329
262// Convert 4-digit (256-bit) bignum from little-endian bytes 330// Convert 4-digit (256-bit) bignum from little-endian bytes
263// Input x[32] (bytes); output z[4] 331// Input x[32] (bytes); output z[4]
264extern void bignum_fromlebytes_4 (uint64_t z[static 4], uint8_t x[static 32]); 332extern void bignum_fromlebytes_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint8_t x[S2N_BIGNUM_STATIC 32]);
265 333
266// Convert 6-digit (384-bit) bignum from little-endian bytes 334// Convert 6-digit (384-bit) bignum from little-endian bytes
267// Input x[48] (bytes); output z[6] 335// Input x[48] (bytes); output z[6]
268extern void bignum_fromlebytes_6 (uint64_t z[static 6], uint8_t x[static 48]); 336extern void bignum_fromlebytes_6 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint8_t x[S2N_BIGNUM_STATIC 48]);
269 337
270// Convert little-endian bytes to 9-digit 528-bit bignum 338// Convert little-endian bytes to 9-digit 528-bit bignum
271// Input x[66] (bytes); output z[9] 339// Input x[66] (bytes); output z[9]
272extern void bignum_fromlebytes_p521 (uint64_t z[static 9],uint8_t x[static 66]); 340extern void bignum_fromlebytes_p521 (uint64_t z[S2N_BIGNUM_STATIC 9],const uint8_t x[S2N_BIGNUM_STATIC 66]);
273 341
274// Compare bignums, x >= y 342// Compare bignums, x >= y
275// Inputs x[m], y[n]; output function return 343// Inputs x[m], y[n]; output function return
276extern uint64_t bignum_ge (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 344extern uint64_t bignum_ge (uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
277 345
278// Compare bignums, x > y 346// Compare bignums, x > y
279// Inputs x[m], y[n]; output function return 347// Inputs x[m], y[n]; output function return
280extern uint64_t bignum_gt (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 348extern uint64_t bignum_gt (uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
281 349
282// Halve modulo p_256, z := (x / 2) mod p_256, assuming x reduced 350// Halve modulo p_256, z := (x / 2) mod p_256, assuming x reduced
283// Input x[4]; output z[4] 351// Input x[4]; output z[4]
284extern void bignum_half_p256 (uint64_t z[static 4], uint64_t x[static 4]); 352extern void bignum_half_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
285 353
286// Halve modulo p_256k1, z := (x / 2) mod p_256k1, assuming x reduced 354// Halve modulo p_256k1, z := (x / 2) mod p_256k1, assuming x reduced
287// Input x[4]; output z[4] 355// Input x[4]; output z[4]
288extern void bignum_half_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 356extern void bignum_half_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
289 357
290// Halve modulo p_384, z := (x / 2) mod p_384, assuming x reduced 358// Halve modulo p_384, z := (x / 2) mod p_384, assuming x reduced
291// Input x[6]; output z[6] 359// Input x[6]; output z[6]
292extern void bignum_half_p384 (uint64_t z[static 6], uint64_t x[static 6]); 360extern void bignum_half_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
293 361
294// Halve modulo p_521, z := (x / 2) mod p_521, assuming x reduced 362// Halve modulo p_521, z := (x / 2) mod p_521, assuming x reduced
295// Input x[9]; output z[9] 363// Input x[9]; output z[9]
296extern void bignum_half_p521 (uint64_t z[static 9], uint64_t x[static 9]); 364extern void bignum_half_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
365
366// Halve modulo p_sm2, z := (x / 2) mod p_sm2, assuming x reduced
367// Input x[4]; output z[4]
368extern void bignum_half_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
369
370// Modular inverse modulo p_25519 = 2^255 - 19
371// Input x[4]; output z[4]
372extern void bignum_inv_p25519(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
373
374// Modular inverse modulo p_256 = 2^256 - 2^224 + 2^192 + 2^96 - 1
375// Input x[4]; output z[4]
376extern void bignum_inv_p256(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
377
378// Modular inverse modulo p_384 = 2^384 - 2^128 - 2^96 + 2^32 - 1
379// Input x[6]; output z[6]
380extern void bignum_inv_p384(uint64_t z[S2N_BIGNUM_STATIC 6],const uint64_t x[S2N_BIGNUM_STATIC 6]);
381
382// Modular inverse modulo p_521 = 2^521 - 1
383// Input x[9]; output z[9]
384extern void bignum_inv_p521(uint64_t z[S2N_BIGNUM_STATIC 9],const uint64_t x[S2N_BIGNUM_STATIC 9]);
385
386// Modular inverse modulo p_sm2 = 2^256 - 2^224 - 2^96 + 2^64 - 1
387// Input x[4]; output z[4]
388extern void bignum_inv_sm2(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
389
390// Inverse square root modulo p_25519
391// Input x[4]; output function return (Legendre symbol) and z[4]
392extern int64_t bignum_invsqrt_p25519(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
393extern int64_t bignum_invsqrt_p25519_alt(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
297 394
298// Test bignum for zero-ness, x = 0 395// Test bignum for zero-ness, x = 0
299// Input x[k]; output function return 396// Input x[k]; output function return
300extern uint64_t bignum_iszero (uint64_t k, uint64_t *x); 397extern uint64_t bignum_iszero (uint64_t k, const uint64_t *x);
301 398
302// Multiply z := x * y 399// Multiply z := x * y
303// Inputs x[16], y[16]; output z[32]; temporary buffer t[>=32] 400// Inputs x[16], y[16]; output z[32]; temporary buffer t[>=32]
304extern void bignum_kmul_16_32 (uint64_t z[static 32], uint64_t x[static 16], uint64_t y[static 16], uint64_t t[static 32]); 401extern void bignum_kmul_16_32 (uint64_t z[S2N_BIGNUM_STATIC 32], const uint64_t x[S2N_BIGNUM_STATIC 16], const uint64_t y[S2N_BIGNUM_STATIC 16], uint64_t t[S2N_BIGNUM_STATIC 32]);
305 402
306// Multiply z := x * y 403// Multiply z := x * y
307// Inputs x[32], y[32]; output z[64]; temporary buffer t[>=96] 404// Inputs x[32], y[32]; output z[64]; temporary buffer t[>=96]
308extern void bignum_kmul_32_64 (uint64_t z[static 64], uint64_t x[static 32], uint64_t y[static 32], uint64_t t[static 96]); 405extern void bignum_kmul_32_64 (uint64_t z[S2N_BIGNUM_STATIC 64], const uint64_t x[S2N_BIGNUM_STATIC 32], const uint64_t y[S2N_BIGNUM_STATIC 32], uint64_t t[S2N_BIGNUM_STATIC 96]);
309 406
310// Square, z := x^2 407// Square, z := x^2
311// Input x[16]; output z[32]; temporary buffer t[>=24] 408// Input x[16]; output z[32]; temporary buffer t[>=24]
312extern void bignum_ksqr_16_32 (uint64_t z[static 32], uint64_t x[static 16], uint64_t t[static 24]); 409extern void bignum_ksqr_16_32 (uint64_t z[S2N_BIGNUM_STATIC 32], const uint64_t x[S2N_BIGNUM_STATIC 16], uint64_t t[S2N_BIGNUM_STATIC 24]);
313 410
314// Square, z := x^2 411// Square, z := x^2
315// Input x[32]; output z[64]; temporary buffer t[>=72] 412// Input x[32]; output z[64]; temporary buffer t[>=72]
316extern void bignum_ksqr_32_64 (uint64_t z[static 64], uint64_t x[static 32], uint64_t t[static 72]); 413extern void bignum_ksqr_32_64 (uint64_t z[S2N_BIGNUM_STATIC 64], const uint64_t x[S2N_BIGNUM_STATIC 32], uint64_t t[S2N_BIGNUM_STATIC 72]);
317 414
318// Compare bignums, x <= y 415// Compare bignums, x <= y
319// Inputs x[m], y[n]; output function return 416// Inputs x[m], y[n]; output function return
320extern uint64_t bignum_le (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 417extern uint64_t bignum_le (uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
321 418
322// Convert 4-digit (256-bit) bignum to/from little-endian form 419// Convert 4-digit (256-bit) bignum to/from little-endian form
323// Input x[4]; output z[4] 420// Input x[4]; output z[4]
324extern void bignum_littleendian_4 (uint64_t z[static 4], uint64_t x[static 4]); 421extern void bignum_littleendian_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
325 422
326// Convert 6-digit (384-bit) bignum to/from little-endian form 423// Convert 6-digit (384-bit) bignum to/from little-endian form
327// Input x[6]; output z[6] 424// Input x[6]; output z[6]
328extern void bignum_littleendian_6 (uint64_t z[static 6], uint64_t x[static 6]); 425extern void bignum_littleendian_6 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
329 426
330// Compare bignums, x < y 427// Compare bignums, x < y
331// Inputs x[m], y[n]; output function return 428// Inputs x[m], y[n]; output function return
332extern uint64_t bignum_lt (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 429extern uint64_t bignum_lt (uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
333 430
334// Multiply-add, z := z + x * y 431// Multiply-add, z := z + x * y
335// Inputs x[m], y[n]; outputs function return (carry-out) and z[k] 432// Inputs x[m], y[n]; outputs function return (carry-out) and z[k]
336extern uint64_t bignum_madd (uint64_t k, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 433extern uint64_t bignum_madd (uint64_t k, uint64_t *z, uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
434
435// Multiply-add modulo the order of the curve25519/edwards25519 basepoint
436// Inputs x[4], y[4], c[4]; output z[4]
437extern void bignum_madd_n25519 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4], const uint64_t c[S2N_BIGNUM_STATIC 4]);
438extern void bignum_madd_n25519_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4], const uint64_t c[S2N_BIGNUM_STATIC 4]);
439
440// Reduce modulo group order, z := x mod m_25519
441// Input x[4]; output z[4]
442extern void bignum_mod_m25519_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
443
444// Reduce modulo basepoint order, z := x mod n_25519
445// Input x[k]; output z[4]
446extern void bignum_mod_n25519 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
447
448// Reduce modulo basepoint order, z := x mod n_25519
449// Input x[4]; output z[4]
450extern void bignum_mod_n25519_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
337 451
338// Reduce modulo group order, z := x mod n_256 452// Reduce modulo group order, z := x mod n_256
339// Input x[k]; output z[4] 453// Input x[k]; output z[4]
340extern void bignum_mod_n256 (uint64_t z[static 4], uint64_t k, uint64_t *x); 454extern void bignum_mod_n256 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
341extern void bignum_mod_n256_alt (uint64_t z[static 4], uint64_t k, uint64_t *x); 455extern void bignum_mod_n256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
342 456
343// Reduce modulo group order, z := x mod n_256 457// Reduce modulo group order, z := x mod n_256
344// Input x[4]; output z[4] 458// Input x[4]; output z[4]
345extern void bignum_mod_n256_4 (uint64_t z[static 4], uint64_t x[static 4]); 459extern void bignum_mod_n256_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
346 460
347// Reduce modulo group order, z := x mod n_256k1 461// Reduce modulo group order, z := x mod n_256k1
348// Input x[4]; output z[4] 462// Input x[4]; output z[4]
349extern void bignum_mod_n256k1_4 (uint64_t z[static 4], uint64_t x[static 4]); 463extern void bignum_mod_n256k1_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
350 464
351// Reduce modulo group order, z := x mod n_384 465// Reduce modulo group order, z := x mod n_384
352// Input x[k]; output z[6] 466// Input x[k]; output z[6]
353extern void bignum_mod_n384 (uint64_t z[static 6], uint64_t k, uint64_t *x); 467extern void bignum_mod_n384 (uint64_t z[S2N_BIGNUM_STATIC 6], uint64_t k, const uint64_t *x);
354extern void bignum_mod_n384_alt (uint64_t z[static 6], uint64_t k, uint64_t *x); 468extern void bignum_mod_n384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], uint64_t k, const uint64_t *x);
355 469
356// Reduce modulo group order, z := x mod n_384 470// Reduce modulo group order, z := x mod n_384
357// Input x[6]; output z[6] 471// Input x[6]; output z[6]
358extern void bignum_mod_n384_6 (uint64_t z[static 6], uint64_t x[static 6]); 472extern void bignum_mod_n384_6 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
359 473
360// Reduce modulo group order, z := x mod n_521 474// Reduce modulo group order, z := x mod n_521
361// Input x[9]; output z[9] 475// Input x[9]; output z[9]
362extern void bignum_mod_n521_9 (uint64_t z[static 9], uint64_t x[static 9]); 476extern void bignum_mod_n521_9 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
363extern void bignum_mod_n521_9_alt (uint64_t z[static 9], uint64_t x[static 9]); 477extern void bignum_mod_n521_9_alt (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
478
479// Reduce modulo group order, z := x mod n_sm2
480// Input x[k]; output z[4]
481extern void bignum_mod_nsm2 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
482extern void bignum_mod_nsm2_alt (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
483
484// Reduce modulo group order, z := x mod n_sm2
485// Input x[4]; output z[4]
486extern void bignum_mod_nsm2_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
364 487
365// Reduce modulo field characteristic, z := x mod p_25519 488// Reduce modulo field characteristic, z := x mod p_25519
366// Input x[4]; output z[4] 489// Input x[4]; output z[4]
367extern void bignum_mod_p25519_4 (uint64_t z[static 4], uint64_t x[static 4]); 490extern void bignum_mod_p25519_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
368 491
369// Reduce modulo field characteristic, z := x mod p_256 492// Reduce modulo field characteristic, z := x mod p_256
370// Input x[k]; output z[4] 493// Input x[k]; output z[4]
371extern void bignum_mod_p256 (uint64_t z[static 4], uint64_t k, uint64_t *x); 494extern void bignum_mod_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
372extern void bignum_mod_p256_alt (uint64_t z[static 4], uint64_t k, uint64_t *x); 495extern void bignum_mod_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
373 496
374// Reduce modulo field characteristic, z := x mod p_256 497// Reduce modulo field characteristic, z := x mod p_256
375// Input x[4]; output z[4] 498// Input x[4]; output z[4]
376extern void bignum_mod_p256_4 (uint64_t z[static 4], uint64_t x[static 4]); 499extern void bignum_mod_p256_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
377 500
378// Reduce modulo field characteristic, z := x mod p_256k1 501// Reduce modulo field characteristic, z := x mod p_256k1
379// Input x[4]; output z[4] 502// Input x[4]; output z[4]
380extern void bignum_mod_p256k1_4 (uint64_t z[static 4], uint64_t x[static 4]); 503extern void bignum_mod_p256k1_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
381 504
382// Reduce modulo field characteristic, z := x mod p_384 505// Reduce modulo field characteristic, z := x mod p_384
383// Input x[k]; output z[6] 506// Input x[k]; output z[6]
384extern void bignum_mod_p384 (uint64_t z[static 6], uint64_t k, uint64_t *x); 507extern void bignum_mod_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], uint64_t k, const uint64_t *x);
385extern void bignum_mod_p384_alt (uint64_t z[static 6], uint64_t k, uint64_t *x); 508extern void bignum_mod_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], uint64_t k, const uint64_t *x);
386 509
387// Reduce modulo field characteristic, z := x mod p_384 510// Reduce modulo field characteristic, z := x mod p_384
388// Input x[6]; output z[6] 511// Input x[6]; output z[6]
389extern void bignum_mod_p384_6 (uint64_t z[static 6], uint64_t x[static 6]); 512extern void bignum_mod_p384_6 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
390 513
391// Reduce modulo field characteristic, z := x mod p_521 514// Reduce modulo field characteristic, z := x mod p_521
392// Input x[9]; output z[9] 515// Input x[9]; output z[9]
393extern void bignum_mod_p521_9 (uint64_t z[static 9], uint64_t x[static 9]); 516extern void bignum_mod_p521_9 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
517
518// Reduce modulo field characteristic, z := x mod p_sm2
519// Input x[k]; output z[4]
520extern void bignum_mod_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t k, const uint64_t *x);
521
522// Reduce modulo field characteristic, z := x mod p_sm2
523// Input x[4]; output z[4]
524extern void bignum_mod_sm2_4 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
394 525
395// Add modulo m, z := (x + y) mod m, assuming x and y reduced 526// Add modulo m, z := (x + y) mod m, assuming x and y reduced
396// Inputs x[k], y[k], m[k]; output z[k] 527// Inputs x[k], y[k], m[k]; output z[k]
397extern void bignum_modadd (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); 528extern void bignum_modadd (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *y, const uint64_t *m);
398 529
399// Double modulo m, z := (2 * x) mod m, assuming x reduced 530// Double modulo m, z := (2 * x) mod m, assuming x reduced
400// Inputs x[k], m[k]; output z[k] 531// Inputs x[k], m[k]; output z[k]
401extern void bignum_moddouble (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); 532extern void bignum_moddouble (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *m);
533
534// Modular exponentiation for arbitrary odd modulus, z := (a^p) mod m
535// Inputs a[k], p[k], m[k]; output z[k], temporary buffer t[>=3*k]
536extern void bignum_modexp(uint64_t k,uint64_t *z, const uint64_t *a,const uint64_t *p,const uint64_t *m,uint64_t *t);
402 537
403// Compute "modification" constant z := 2^{64k} mod m 538// Compute "modification" constant z := 2^{64k} mod m
404// Input m[k]; output z[k]; temporary buffer t[>=k] 539// Input m[k]; output z[k]; temporary buffer t[>=k]
405extern void bignum_modifier (uint64_t k, uint64_t *z, uint64_t *m, uint64_t *t); 540extern void bignum_modifier (uint64_t k, uint64_t *z, const uint64_t *m, uint64_t *t);
406 541
407// Invert modulo m, z = (1/a) mod b, assuming b is an odd number > 1, a coprime to b 542// Invert modulo m, z = (1/a) mod b, assuming b is an odd number > 1, a coprime to b
408// Inputs a[k], b[k]; output z[k]; temporary buffer t[>=3*k] 543// Inputs a[k], b[k]; output z[k]; temporary buffer t[>=3*k]
409extern void bignum_modinv (uint64_t k, uint64_t *z, uint64_t *a, uint64_t *b, uint64_t *t); 544extern void bignum_modinv (uint64_t k, uint64_t *z, const uint64_t *a, const uint64_t *b, uint64_t *t);
410 545
411// Optionally negate modulo m, z := (-x) mod m (if p nonzero) or z := x (if p zero), assuming x reduced 546// Optionally negate modulo m, z := (-x) mod m (if p nonzero) or z := x (if p zero), assuming x reduced
412// Inputs p, x[k], m[k]; output z[k] 547// Inputs p, x[k], m[k]; output z[k]
413extern void bignum_modoptneg (uint64_t k, uint64_t *z, uint64_t p, uint64_t *x, uint64_t *m); 548extern void bignum_modoptneg (uint64_t k, uint64_t *z, uint64_t p, const uint64_t *x, const uint64_t *m);
414 549
415// Subtract modulo m, z := (x - y) mod m, assuming x and y reduced 550// Subtract modulo m, z := (x - y) mod m, assuming x and y reduced
416// Inputs x[k], y[k], m[k]; output z[k] 551// Inputs x[k], y[k], m[k]; output z[k]
417extern void bignum_modsub (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); 552extern void bignum_modsub (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *y, const uint64_t *m);
418 553
419// Compute "montification" constant z := 2^{128k} mod m 554// Compute "montification" constant z := 2^{128k} mod m
420// Input m[k]; output z[k]; temporary buffer t[>=k] 555// Input m[k]; output z[k]; temporary buffer t[>=k]
421extern void bignum_montifier (uint64_t k, uint64_t *z, uint64_t *m, uint64_t *t); 556extern void bignum_montifier (uint64_t k, uint64_t *z, const uint64_t *m, uint64_t *t);
557
558// Montgomery inverse modulo p_256 = 2^256 - 2^224 + 2^192 + 2^96 - 1
559// Input x[4]; output z[4]
560extern void bignum_montinv_p256(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
561
562// Montgomery inverse modulo p_384 = 2^384 - 2^128 - 2^96 + 2^32 - 1
563// Input x[6]; output z[6]
564extern void bignum_montinv_p384(uint64_t z[S2N_BIGNUM_STATIC 6],const uint64_t x[S2N_BIGNUM_STATIC 6]);
565
566// Montgomery inverse modulo p_sm2 = 2^256 - 2^224 - 2^96 + 2^64 - 1
567// Input x[4]; output z[4]
568extern void bignum_montinv_sm2(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
422 569
423// Montgomery multiply, z := (x * y / 2^{64k}) mod m 570// Montgomery multiply, z := (x * y / 2^{64k}) mod m
424// Inputs x[k], y[k], m[k]; output z[k] 571// Inputs x[k], y[k], m[k]; output z[k]
425extern void bignum_montmul (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); 572extern void bignum_montmul (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *y, const uint64_t *m);
426 573
427// Montgomery multiply, z := (x * y / 2^256) mod p_256 574// Montgomery multiply, z := (x * y / 2^256) mod p_256
428// Inputs x[4], y[4]; output z[4] 575// Inputs x[4], y[4]; output z[4]
429extern void bignum_montmul_p256 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 576extern void bignum_montmul_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
430extern void bignum_montmul_p256_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 577extern void bignum_montmul_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
431 578
432// Montgomery multiply, z := (x * y / 2^256) mod p_256k1 579// Montgomery multiply, z := (x * y / 2^256) mod p_256k1
433// Inputs x[4], y[4]; output z[4] 580// Inputs x[4], y[4]; output z[4]
434extern void bignum_montmul_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 581extern void bignum_montmul_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
435extern void bignum_montmul_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 582extern void bignum_montmul_p256k1_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
436 583
437// Montgomery multiply, z := (x * y / 2^384) mod p_384 584// Montgomery multiply, z := (x * y / 2^384) mod p_384
438// Inputs x[6], y[6]; output z[6] 585// Inputs x[6], y[6]; output z[6]
439extern void bignum_montmul_p384 (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); 586extern void bignum_montmul_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6], const uint64_t y[S2N_BIGNUM_STATIC 6]);
440extern void bignum_montmul_p384_alt (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); 587extern void bignum_montmul_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6], const uint64_t y[S2N_BIGNUM_STATIC 6]);
441 588
442// Montgomery multiply, z := (x * y / 2^576) mod p_521 589// Montgomery multiply, z := (x * y / 2^576) mod p_521
443// Inputs x[9], y[9]; output z[9] 590// Inputs x[9], y[9]; output z[9]
444extern void bignum_montmul_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); 591extern void bignum_montmul_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9], const uint64_t y[S2N_BIGNUM_STATIC 9]);
445extern void bignum_montmul_p521_alt (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); 592extern void bignum_montmul_p521_alt (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9], const uint64_t y[S2N_BIGNUM_STATIC 9]);
593
594// Montgomery multiply, z := (x * y / 2^256) mod p_sm2
595// Inputs x[4], y[4]; output z[4]
596extern void bignum_montmul_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
597extern void bignum_montmul_sm2_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
446 598
447// Montgomery reduce, z := (x' / 2^{64p}) MOD m 599// Montgomery reduce, z := (x' / 2^{64p}) MOD m
448// Inputs x[n], m[k], p; output z[k] 600// Inputs x[n], m[k], p; output z[k]
449extern void bignum_montredc (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t *m, uint64_t p); 601extern void bignum_montredc (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x, const uint64_t *m, uint64_t p);
450 602
451// Montgomery square, z := (x^2 / 2^{64k}) mod m 603// Montgomery square, z := (x^2 / 2^{64k}) mod m
452// Inputs x[k], m[k]; output z[k] 604// Inputs x[k], m[k]; output z[k]
453extern void bignum_montsqr (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); 605extern void bignum_montsqr (uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *m);
454 606
455// Montgomery square, z := (x^2 / 2^256) mod p_256 607// Montgomery square, z := (x^2 / 2^256) mod p_256
456// Input x[4]; output z[4] 608// Input x[4]; output z[4]
457extern void bignum_montsqr_p256 (uint64_t z[static 4], uint64_t x[static 4]); 609extern void bignum_montsqr_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
458extern void bignum_montsqr_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); 610extern void bignum_montsqr_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
459 611
460// Montgomery square, z := (x^2 / 2^256) mod p_256k1 612// Montgomery square, z := (x^2 / 2^256) mod p_256k1
461// Input x[4]; output z[4] 613// Input x[4]; output z[4]
462extern void bignum_montsqr_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 614extern void bignum_montsqr_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
463extern void bignum_montsqr_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); 615extern void bignum_montsqr_p256k1_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
464 616
465// Montgomery square, z := (x^2 / 2^384) mod p_384 617// Montgomery square, z := (x^2 / 2^384) mod p_384
466// Input x[6]; output z[6] 618// Input x[6]; output z[6]
467extern void bignum_montsqr_p384 (uint64_t z[static 6], uint64_t x[static 6]); 619extern void bignum_montsqr_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
468extern void bignum_montsqr_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); 620extern void bignum_montsqr_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
469 621
470// Montgomery square, z := (x^2 / 2^576) mod p_521 622// Montgomery square, z := (x^2 / 2^576) mod p_521
471// Input x[9]; output z[9] 623// Input x[9]; output z[9]
472extern void bignum_montsqr_p521 (uint64_t z[static 9], uint64_t x[static 9]); 624extern void bignum_montsqr_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
473extern void bignum_montsqr_p521_alt (uint64_t z[static 9], uint64_t x[static 9]); 625extern void bignum_montsqr_p521_alt (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
626
627// Montgomery square, z := (x^2 / 2^256) mod p_sm2
628// Input x[4]; output z[4]
629extern void bignum_montsqr_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
630extern void bignum_montsqr_sm2_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
474 631
475// Multiply z := x * y 632// Multiply z := x * y
476// Inputs x[m], y[n]; output z[k] 633// Inputs x[m], y[n]; output z[k]
477extern void bignum_mul (uint64_t k, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 634extern void bignum_mul (uint64_t k, uint64_t *z, uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
478 635
479// Multiply z := x * y 636// Multiply z := x * y
480// Inputs x[4], y[4]; output z[8] 637// Inputs x[4], y[4]; output z[8]
481extern void bignum_mul_4_8 (uint64_t z[static 8], uint64_t x[static 4], uint64_t y[static 4]); 638extern void bignum_mul_4_8 (uint64_t z[S2N_BIGNUM_STATIC 8], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
482extern void bignum_mul_4_8_alt (uint64_t z[static 8], uint64_t x[static 4], uint64_t y[static 4]); 639extern void bignum_mul_4_8_alt (uint64_t z[S2N_BIGNUM_STATIC 8], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
483 640
484// Multiply z := x * y 641// Multiply z := x * y
485// Inputs x[6], y[6]; output z[12] 642// Inputs x[6], y[6]; output z[12]
486extern void bignum_mul_6_12 (uint64_t z[static 12], uint64_t x[static 6], uint64_t y[static 6]); 643extern void bignum_mul_6_12 (uint64_t z[S2N_BIGNUM_STATIC 12], const uint64_t x[S2N_BIGNUM_STATIC 6], const uint64_t y[S2N_BIGNUM_STATIC 6]);
487extern void bignum_mul_6_12_alt (uint64_t z[static 12], uint64_t x[static 6], uint64_t y[static 6]); 644extern void bignum_mul_6_12_alt (uint64_t z[S2N_BIGNUM_STATIC 12], const uint64_t x[S2N_BIGNUM_STATIC 6], const uint64_t y[S2N_BIGNUM_STATIC 6]);
488 645
489// Multiply z := x * y 646// Multiply z := x * y
490// Inputs x[8], y[8]; output z[16] 647// Inputs x[8], y[8]; output z[16]
491extern void bignum_mul_8_16 (uint64_t z[static 16], uint64_t x[static 8], uint64_t y[static 8]); 648extern void bignum_mul_8_16 (uint64_t z[S2N_BIGNUM_STATIC 16], const uint64_t x[S2N_BIGNUM_STATIC 8], const uint64_t y[S2N_BIGNUM_STATIC 8]);
492extern void bignum_mul_8_16_alt (uint64_t z[static 16], uint64_t x[static 8], uint64_t y[static 8]); 649extern void bignum_mul_8_16_alt (uint64_t z[S2N_BIGNUM_STATIC 16], const uint64_t x[S2N_BIGNUM_STATIC 8], const uint64_t y[S2N_BIGNUM_STATIC 8]);
493 650
494// Multiply modulo p_25519, z := (x * y) mod p_25519 651// Multiply modulo p_25519, z := (x * y) mod p_25519
495// Inputs x[4], y[4]; output z[4] 652// Inputs x[4], y[4]; output z[4]
496extern void bignum_mul_p25519 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 653extern void bignum_mul_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
497extern void bignum_mul_p25519_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 654extern void bignum_mul_p25519_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
498 655
499// Multiply modulo p_256k1, z := (x * y) mod p_256k1 656// Multiply modulo p_256k1, z := (x * y) mod p_256k1
500// Inputs x[4], y[4]; output z[4] 657// Inputs x[4], y[4]; output z[4]
501extern void bignum_mul_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 658extern void bignum_mul_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
502extern void bignum_mul_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 659extern void bignum_mul_p256k1_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
503 660
504// Multiply modulo p_521, z := (x * y) mod p_521, assuming x and y reduced 661// Multiply modulo p_521, z := (x * y) mod p_521, assuming x and y reduced
505// Inputs x[9], y[9]; output z[9] 662// Inputs x[9], y[9]; output z[9]
506extern void bignum_mul_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); 663extern void bignum_mul_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9], const uint64_t y[S2N_BIGNUM_STATIC 9]);
507extern void bignum_mul_p521_alt (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); 664extern void bignum_mul_p521_alt (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9], const uint64_t y[S2N_BIGNUM_STATIC 9]);
508 665
509// Multiply bignum by 10 and add word: z := 10 * z + d 666// Multiply bignum by 10 and add word: z := 10 * z + d
510// Inputs z[k], d; outputs function return (carry) and z[k] 667// Inputs z[k], d; outputs function return (carry) and z[k]
@@ -512,55 +669,59 @@ extern uint64_t bignum_muladd10 (uint64_t k, uint64_t *z, uint64_t d);
512 669
513// Multiplex/select z := x (if p nonzero) or z := y (if p zero) 670// Multiplex/select z := x (if p nonzero) or z := y (if p zero)
514// Inputs p, x[k], y[k]; output z[k] 671// Inputs p, x[k], y[k]; output z[k]
515extern void bignum_mux (uint64_t p, uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y); 672extern void bignum_mux (uint64_t p, uint64_t k, uint64_t *z, const uint64_t *x, const uint64_t *y);
516 673
517// 256-bit multiplex/select z := x (if p nonzero) or z := y (if p zero) 674// 256-bit multiplex/select z := x (if p nonzero) or z := y (if p zero)
518// Inputs p, x[4], y[4]; output z[4] 675// Inputs p, x[4], y[4]; output z[4]
519extern void bignum_mux_4 (uint64_t p, uint64_t z[static 4],uint64_t x[static 4], uint64_t y[static 4]); 676extern void bignum_mux_4 (uint64_t p, uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
520 677
521// 384-bit multiplex/select z := x (if p nonzero) or z := y (if p zero) 678// 384-bit multiplex/select z := x (if p nonzero) or z := y (if p zero)
522// Inputs p, x[6], y[6]; output z[6] 679// Inputs p, x[6], y[6]; output z[6]
523extern void bignum_mux_6 (uint64_t p, uint64_t z[static 6],uint64_t x[static 6], uint64_t y[static 6]); 680extern void bignum_mux_6 (uint64_t p, uint64_t z[S2N_BIGNUM_STATIC 6],const uint64_t x[S2N_BIGNUM_STATIC 6], const uint64_t y[S2N_BIGNUM_STATIC 6]);
524 681
525// Select element from 16-element table, z := xs[k*i] 682// Select element from 16-element table, z := xs[k*i]
526// Inputs xs[16*k], i; output z[k] 683// Inputs xs[16*k], i; output z[k]
527extern void bignum_mux16 (uint64_t k, uint64_t *z, uint64_t *xs, uint64_t i); 684extern void bignum_mux16 (uint64_t k, uint64_t *z, const uint64_t *xs, uint64_t i);
528 685
529// Negate modulo p_25519, z := (-x) mod p_25519, assuming x reduced 686// Negate modulo p_25519, z := (-x) mod p_25519, assuming x reduced
530// Input x[4]; output z[4] 687// Input x[4]; output z[4]
531extern void bignum_neg_p25519 (uint64_t z[static 4], uint64_t x[static 4]); 688extern void bignum_neg_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
532 689
533// Negate modulo p_256, z := (-x) mod p_256, assuming x reduced 690// Negate modulo p_256, z := (-x) mod p_256, assuming x reduced
534// Input x[4]; output z[4] 691// Input x[4]; output z[4]
535extern void bignum_neg_p256 (uint64_t z[static 4], uint64_t x[static 4]); 692extern void bignum_neg_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
536 693
537// Negate modulo p_256k1, z := (-x) mod p_256k1, assuming x reduced 694// Negate modulo p_256k1, z := (-x) mod p_256k1, assuming x reduced
538// Input x[4]; output z[4] 695// Input x[4]; output z[4]
539extern void bignum_neg_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 696extern void bignum_neg_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
540 697
541// Negate modulo p_384, z := (-x) mod p_384, assuming x reduced 698// Negate modulo p_384, z := (-x) mod p_384, assuming x reduced
542// Input x[6]; output z[6] 699// Input x[6]; output z[6]
543extern void bignum_neg_p384 (uint64_t z[static 6], uint64_t x[static 6]); 700extern void bignum_neg_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
544 701
545// Negate modulo p_521, z := (-x) mod p_521, assuming x reduced 702// Negate modulo p_521, z := (-x) mod p_521, assuming x reduced
546// Input x[9]; output z[9] 703// Input x[9]; output z[9]
547extern void bignum_neg_p521 (uint64_t z[static 9], uint64_t x[static 9]); 704extern void bignum_neg_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
705
706// Negate modulo p_sm2, z := (-x) mod p_sm2, assuming x reduced
707// Input x[4]; output z[4]
708extern void bignum_neg_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
548 709
549// Negated modular inverse, z := (-1/x) mod 2^{64k} 710// Negated modular inverse, z := (-1/x) mod 2^{64k}
550// Input x[k]; output z[k] 711// Input x[k]; output z[k]
551extern void bignum_negmodinv (uint64_t k, uint64_t *z, uint64_t *x); 712extern void bignum_negmodinv (uint64_t k, uint64_t *z, const uint64_t *x);
552 713
553// Test bignum for nonzero-ness x =/= 0 714// Test bignum for nonzero-ness x =/= 0
554// Input x[k]; output function return 715// Input x[k]; output function return
555extern uint64_t bignum_nonzero (uint64_t k, uint64_t *x); 716extern uint64_t bignum_nonzero (uint64_t k, const uint64_t *x);
556 717
557// Test 256-bit bignum for nonzero-ness x =/= 0 718// Test 256-bit bignum for nonzero-ness x =/= 0
558// Input x[4]; output function return 719// Input x[4]; output function return
559extern uint64_t bignum_nonzero_4(uint64_t x[static 4]); 720extern uint64_t bignum_nonzero_4(const uint64_t x[S2N_BIGNUM_STATIC 4]);
560 721
561// Test 384-bit bignum for nonzero-ness x =/= 0 722// Test 384-bit bignum for nonzero-ness x =/= 0
562// Input x[6]; output function return 723// Input x[6]; output function return
563extern uint64_t bignum_nonzero_6(uint64_t x[static 6]); 724extern uint64_t bignum_nonzero_6(const uint64_t x[S2N_BIGNUM_STATIC 6]);
564 725
565// Normalize bignum in-place by shifting left till top bit is 1 726// Normalize bignum in-place by shifting left till top bit is 1
566// Input z[k]; outputs function return (bits shifted left) and z[k] 727// Input z[k]; outputs function return (bits shifted left) and z[k]
@@ -568,7 +729,7 @@ extern uint64_t bignum_normalize (uint64_t k, uint64_t *z);
568 729
569// Test bignum for odd-ness 730// Test bignum for odd-ness
570// Input x[k]; output function return 731// Input x[k]; output function return
571extern uint64_t bignum_odd (uint64_t k, uint64_t *x); 732extern uint64_t bignum_odd (uint64_t k, const uint64_t *x);
572 733
573// Convert single digit to bignum, z := n 734// Convert single digit to bignum, z := n
574// Input n; output z[k] 735// Input n; output z[k]
@@ -576,39 +737,43 @@ extern void bignum_of_word (uint64_t k, uint64_t *z, uint64_t n);
576 737
577// Optionally add, z := x + y (if p nonzero) or z := x (if p zero) 738// Optionally add, z := x + y (if p nonzero) or z := x (if p zero)
578// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k] 739// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k]
579extern uint64_t bignum_optadd (uint64_t k, uint64_t *z, uint64_t *x, uint64_t p, uint64_t *y); 740extern uint64_t bignum_optadd (uint64_t k, uint64_t *z, const uint64_t *x, uint64_t p, const uint64_t *y);
580 741
581// Optionally negate, z := -x (if p nonzero) or z := x (if p zero) 742// Optionally negate, z := -x (if p nonzero) or z := x (if p zero)
582// Inputs p, x[k]; outputs function return (nonzero input) and z[k] 743// Inputs p, x[k]; outputs function return (nonzero input) and z[k]
583extern uint64_t bignum_optneg (uint64_t k, uint64_t *z, uint64_t p, uint64_t *x); 744extern uint64_t bignum_optneg (uint64_t k, uint64_t *z, uint64_t p, const uint64_t *x);
584 745
585// Optionally negate modulo p_25519, z := (-x) mod p_25519 (if p nonzero) or z := x (if p zero), assuming x reduced 746// Optionally negate modulo p_25519, z := (-x) mod p_25519 (if p nonzero) or z := x (if p zero), assuming x reduced
586// Inputs p, x[4]; output z[4] 747// Inputs p, x[4]; output z[4]
587extern void bignum_optneg_p25519 (uint64_t z[static 4], uint64_t p, uint64_t x[static 4]); 748extern void bignum_optneg_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t p, const uint64_t x[S2N_BIGNUM_STATIC 4]);
588 749
589// Optionally negate modulo p_256, z := (-x) mod p_256 (if p nonzero) or z := x (if p zero), assuming x reduced 750// Optionally negate modulo p_256, z := (-x) mod p_256 (if p nonzero) or z := x (if p zero), assuming x reduced
590// Inputs p, x[4]; output z[4] 751// Inputs p, x[4]; output z[4]
591extern void bignum_optneg_p256 (uint64_t z[static 4], uint64_t p, uint64_t x[static 4]); 752extern void bignum_optneg_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t p, const uint64_t x[S2N_BIGNUM_STATIC 4]);
592 753
593// Optionally negate modulo p_256k1, z := (-x) mod p_256k1 (if p nonzero) or z := x (if p zero), assuming x reduced 754// Optionally negate modulo p_256k1, z := (-x) mod p_256k1 (if p nonzero) or z := x (if p zero), assuming x reduced
594// Inputs p, x[4]; output z[4] 755// Inputs p, x[4]; output z[4]
595extern void bignum_optneg_p256k1 (uint64_t z[static 4], uint64_t p, uint64_t x[static 4]); 756extern void bignum_optneg_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t p, const uint64_t x[S2N_BIGNUM_STATIC 4]);
596 757
597// Optionally negate modulo p_384, z := (-x) mod p_384 (if p nonzero) or z := x (if p zero), assuming x reduced 758// Optionally negate modulo p_384, z := (-x) mod p_384 (if p nonzero) or z := x (if p zero), assuming x reduced
598// Inputs p, x[6]; output z[6] 759// Inputs p, x[6]; output z[6]
599extern void bignum_optneg_p384 (uint64_t z[static 6], uint64_t p, uint64_t x[static 6]); 760extern void bignum_optneg_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], uint64_t p, const uint64_t x[S2N_BIGNUM_STATIC 6]);
600 761
601// Optionally negate modulo p_521, z := (-x) mod p_521 (if p nonzero) or z := x (if p zero), assuming x reduced 762// Optionally negate modulo p_521, z := (-x) mod p_521 (if p nonzero) or z := x (if p zero), assuming x reduced
602// Inputs p, x[9]; output z[9] 763// Inputs p, x[9]; output z[9]
603extern void bignum_optneg_p521 (uint64_t z[static 9], uint64_t p, uint64_t x[static 9]); 764extern void bignum_optneg_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], uint64_t p, const uint64_t x[S2N_BIGNUM_STATIC 9]);
765
766// Optionally negate modulo p_sm2, z := (-x) mod p_sm2 (if p nonzero) or z := x (if p zero), assuming x reduced
767// Inputs p, x[4]; output z[4]
768extern void bignum_optneg_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], uint64_t p, const uint64_t x[S2N_BIGNUM_STATIC 4]);
604 769
605// Optionally subtract, z := x - y (if p nonzero) or z := x (if p zero) 770// Optionally subtract, z := x - y (if p nonzero) or z := x (if p zero)
606// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k] 771// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k]
607extern uint64_t bignum_optsub (uint64_t k, uint64_t *z, uint64_t *x, uint64_t p, uint64_t *y); 772extern uint64_t bignum_optsub (uint64_t k, uint64_t *z, const uint64_t *x, uint64_t p, const uint64_t *y);
608 773
609// Optionally subtract or add, z := x + sgn(p) * y interpreting p as signed 774// Optionally subtract or add, z := x + sgn(p) * y interpreting p as signed
610// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k] 775// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k]
611extern uint64_t bignum_optsubadd (uint64_t k, uint64_t *z, uint64_t *x, uint64_t p, uint64_t *y); 776extern uint64_t bignum_optsubadd (uint64_t k, uint64_t *z, const uint64_t *x, uint64_t p, const uint64_t *y);
612 777
613// Return bignum of power of 2, z := 2^n 778// Return bignum of power of 2, z := 2^n
614// Input n; output z[k] 779// Input n; output z[k]
@@ -616,216 +781,376 @@ extern void bignum_pow2 (uint64_t k, uint64_t *z, uint64_t n);
616 781
617// Shift bignum left by c < 64 bits z := x * 2^c 782// Shift bignum left by c < 64 bits z := x * 2^c
618// Inputs x[n], c; outputs function return (carry-out) and z[k] 783// Inputs x[n], c; outputs function return (carry-out) and z[k]
619extern uint64_t bignum_shl_small (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t c); 784extern uint64_t bignum_shl_small (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x, uint64_t c);
620 785
621// Shift bignum right by c < 64 bits z := floor(x / 2^c) 786// Shift bignum right by c < 64 bits z := floor(x / 2^c)
622// Inputs x[n], c; outputs function return (bits shifted out) and z[k] 787// Inputs x[n], c; outputs function return (bits shifted out) and z[k]
623extern uint64_t bignum_shr_small (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t c); 788extern uint64_t bignum_shr_small (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x, uint64_t c);
624 789
625// Square, z := x^2 790// Square, z := x^2
626// Input x[n]; output z[k] 791// Input x[n]; output z[k]
627extern void bignum_sqr (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x); 792extern void bignum_sqr (uint64_t k, uint64_t *z, uint64_t n, const uint64_t *x);
628 793
629// Square, z := x^2 794// Square, z := x^2
630// Input x[4]; output z[8] 795// Input x[4]; output z[8]
631extern void bignum_sqr_4_8 (uint64_t z[static 8], uint64_t x[static 4]); 796extern void bignum_sqr_4_8 (uint64_t z[S2N_BIGNUM_STATIC 8], const uint64_t x[S2N_BIGNUM_STATIC 4]);
632extern void bignum_sqr_4_8_alt (uint64_t z[static 8], uint64_t x[static 4]); 797extern void bignum_sqr_4_8_alt (uint64_t z[S2N_BIGNUM_STATIC 8], const uint64_t x[S2N_BIGNUM_STATIC 4]);
633 798
634// Square, z := x^2 799// Square, z := x^2
635// Input x[6]; output z[12] 800// Input x[6]; output z[12]
636extern void bignum_sqr_6_12 (uint64_t z[static 12], uint64_t x[static 6]); 801extern void bignum_sqr_6_12 (uint64_t z[S2N_BIGNUM_STATIC 12], const uint64_t x[S2N_BIGNUM_STATIC 6]);
637extern void bignum_sqr_6_12_alt (uint64_t z[static 12], uint64_t x[static 6]); 802extern void bignum_sqr_6_12_alt (uint64_t z[S2N_BIGNUM_STATIC 12], const uint64_t x[S2N_BIGNUM_STATIC 6]);
638 803
639// Square, z := x^2 804// Square, z := x^2
640// Input x[8]; output z[16] 805// Input x[8]; output z[16]
641extern void bignum_sqr_8_16 (uint64_t z[static 16], uint64_t x[static 8]); 806extern void bignum_sqr_8_16 (uint64_t z[S2N_BIGNUM_STATIC 16], const uint64_t x[S2N_BIGNUM_STATIC 8]);
642extern void bignum_sqr_8_16_alt (uint64_t z[static 16], uint64_t x[static 8]); 807extern void bignum_sqr_8_16_alt (uint64_t z[S2N_BIGNUM_STATIC 16], const uint64_t x[S2N_BIGNUM_STATIC 8]);
643 808
644// Square modulo p_25519, z := (x^2) mod p_25519 809// Square modulo p_25519, z := (x^2) mod p_25519
645// Input x[4]; output z[4] 810// Input x[4]; output z[4]
646extern void bignum_sqr_p25519 (uint64_t z[static 4], uint64_t x[static 4]); 811extern void bignum_sqr_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
647extern void bignum_sqr_p25519_alt (uint64_t z[static 4], uint64_t x[static 4]); 812extern void bignum_sqr_p25519_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
648 813
649// Square modulo p_256k1, z := (x^2) mod p_256k1 814// Square modulo p_256k1, z := (x^2) mod p_256k1
650// Input x[4]; output z[4] 815// Input x[4]; output z[4]
651extern void bignum_sqr_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 816extern void bignum_sqr_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
652extern void bignum_sqr_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); 817extern void bignum_sqr_p256k1_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
653 818
654// Square modulo p_521, z := (x^2) mod p_521, assuming x reduced 819// Square modulo p_521, z := (x^2) mod p_521, assuming x reduced
655// Input x[9]; output z[9] 820// Input x[9]; output z[9]
656extern void bignum_sqr_p521 (uint64_t z[static 9], uint64_t x[static 9]); 821extern void bignum_sqr_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
657extern void bignum_sqr_p521_alt (uint64_t z[static 9], uint64_t x[static 9]); 822extern void bignum_sqr_p521_alt (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
823
824// Square root modulo p_25519
825// Input x[4]; output function return (Legendre symbol) and z[4]
826extern int64_t bignum_sqrt_p25519(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
827extern int64_t bignum_sqrt_p25519_alt(uint64_t z[S2N_BIGNUM_STATIC 4],const uint64_t x[S2N_BIGNUM_STATIC 4]);
658 828
659// Subtract, z := x - y 829// Subtract, z := x - y
660// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] 830// Inputs x[m], y[n]; outputs function return (carry-out) and z[p]
661extern uint64_t bignum_sub (uint64_t p, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); 831extern uint64_t bignum_sub (uint64_t p, uint64_t *z, uint64_t m, const uint64_t *x, uint64_t n, const uint64_t *y);
662 832
663// Subtract modulo p_25519, z := (x - y) mod p_25519, assuming x and y reduced 833// Subtract modulo p_25519, z := (x - y) mod p_25519, assuming x and y reduced
664// Inputs x[4], y[4]; output z[4] 834// Inputs x[4], y[4]; output z[4]
665extern void bignum_sub_p25519 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 835extern void bignum_sub_p25519 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
666 836
667// Subtract modulo p_256, z := (x - y) mod p_256, assuming x and y reduced 837// Subtract modulo p_256, z := (x - y) mod p_256, assuming x and y reduced
668// Inputs x[4], y[4]; output z[4] 838// Inputs x[4], y[4]; output z[4]
669extern void bignum_sub_p256 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 839extern void bignum_sub_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
670 840
671// Subtract modulo p_256k1, z := (x - y) mod p_256k1, assuming x and y reduced 841// Subtract modulo p_256k1, z := (x - y) mod p_256k1, assuming x and y reduced
672// Inputs x[4], y[4]; output z[4] 842// Inputs x[4], y[4]; output z[4]
673extern void bignum_sub_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); 843extern void bignum_sub_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
674 844
675// Subtract modulo p_384, z := (x - y) mod p_384, assuming x and y reduced 845// Subtract modulo p_384, z := (x - y) mod p_384, assuming x and y reduced
676// Inputs x[6], y[6]; output z[6] 846// Inputs x[6], y[6]; output z[6]
677extern void bignum_sub_p384 (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); 847extern void bignum_sub_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6], const uint64_t y[S2N_BIGNUM_STATIC 6]);
678 848
679// Subtract modulo p_521, z := (x - y) mod p_521, assuming x and y reduced 849// Subtract modulo p_521, z := (x - y) mod p_521, assuming x and y reduced
680// Inputs x[9], y[9]; output z[9] 850// Inputs x[9], y[9]; output z[9]
681extern void bignum_sub_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); 851extern void bignum_sub_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9], const uint64_t y[S2N_BIGNUM_STATIC 9]);
852
853// Subtract modulo p_sm2, z := (x - y) mod p_sm2, assuming x and y reduced
854// Inputs x[4], y[4]; output z[4]
855extern void bignum_sub_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4], const uint64_t y[S2N_BIGNUM_STATIC 4]);
682 856
683// Convert 4-digit (256-bit) bignum to big-endian bytes 857// Convert 4-digit (256-bit) bignum to big-endian bytes
684// Input x[4]; output z[32] (bytes) 858// Input x[4]; output z[32] (bytes)
685extern void bignum_tobebytes_4 (uint8_t z[static 32], uint64_t x[static 4]); 859extern void bignum_tobebytes_4 (uint8_t z[S2N_BIGNUM_STATIC 32], const uint64_t x[S2N_BIGNUM_STATIC 4]);
686 860
687// Convert 6-digit (384-bit) bignum to big-endian bytes 861// Convert 6-digit (384-bit) bignum to big-endian bytes
688// Input x[6]; output z[48] (bytes) 862// Input x[6]; output z[48] (bytes)
689extern void bignum_tobebytes_6 (uint8_t z[static 48], uint64_t x[static 6]); 863extern void bignum_tobebytes_6 (uint8_t z[S2N_BIGNUM_STATIC 48], const uint64_t x[S2N_BIGNUM_STATIC 6]);
690 864
691// Convert 4-digit (256-bit) bignum to little-endian bytes 865// Convert 4-digit (256-bit) bignum to little-endian bytes
692// Input x[4]; output z[32] (bytes) 866// Input x[4]; output z[32] (bytes)
693extern void bignum_tolebytes_4 (uint8_t z[static 32], uint64_t x[static 4]); 867extern void bignum_tolebytes_4 (uint8_t z[S2N_BIGNUM_STATIC 32], const uint64_t x[S2N_BIGNUM_STATIC 4]);
694 868
695// Convert 6-digit (384-bit) bignum to little-endian bytes 869// Convert 6-digit (384-bit) bignum to little-endian bytes
696// Input x[6]; output z[48] (bytes) 870// Input x[6]; output z[48] (bytes)
697extern void bignum_tolebytes_6 (uint8_t z[static 48], uint64_t x[static 6]); 871extern void bignum_tolebytes_6 (uint8_t z[S2N_BIGNUM_STATIC 48], const uint64_t x[S2N_BIGNUM_STATIC 6]);
698 872
699// Convert 9-digit 528-bit bignum to little-endian bytes 873// Convert 9-digit 528-bit bignum to little-endian bytes
700// Input x[6]; output z[66] (bytes) 874// Input x[6]; output z[66] (bytes)
701extern void bignum_tolebytes_p521 (uint8_t z[static 66], uint64_t x[static 9]); 875extern void bignum_tolebytes_p521 (uint8_t z[S2N_BIGNUM_STATIC 66], const uint64_t x[S2N_BIGNUM_STATIC 9]);
702 876
703// Convert to Montgomery form z := (2^256 * x) mod p_256 877// Convert to Montgomery form z := (2^256 * x) mod p_256
704// Input x[4]; output z[4] 878// Input x[4]; output z[4]
705extern void bignum_tomont_p256 (uint64_t z[static 4], uint64_t x[static 4]); 879extern void bignum_tomont_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
706extern void bignum_tomont_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); 880extern void bignum_tomont_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
707 881
708// Convert to Montgomery form z := (2^256 * x) mod p_256k1 882// Convert to Montgomery form z := (2^256 * x) mod p_256k1
709// Input x[4]; output z[4] 883// Input x[4]; output z[4]
710extern void bignum_tomont_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 884extern void bignum_tomont_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
711extern void bignum_tomont_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); 885extern void bignum_tomont_p256k1_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
712 886
713// Convert to Montgomery form z := (2^384 * x) mod p_384 887// Convert to Montgomery form z := (2^384 * x) mod p_384
714// Input x[6]; output z[6] 888// Input x[6]; output z[6]
715extern void bignum_tomont_p384 (uint64_t z[static 6], uint64_t x[static 6]); 889extern void bignum_tomont_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
716extern void bignum_tomont_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); 890extern void bignum_tomont_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
717 891
718// Convert to Montgomery form z := (2^576 * x) mod p_521 892// Convert to Montgomery form z := (2^576 * x) mod p_521
719// Input x[9]; output z[9] 893// Input x[9]; output z[9]
720extern void bignum_tomont_p521 (uint64_t z[static 9], uint64_t x[static 9]); 894extern void bignum_tomont_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
895
896// Convert to Montgomery form z := (2^256 * x) mod p_sm2
897// Input x[4]; output z[4]
898extern void bignum_tomont_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
721 899
722// Triple modulo p_256, z := (3 * x) mod p_256 900// Triple modulo p_256, z := (3 * x) mod p_256
723// Input x[4]; output z[4] 901// Input x[4]; output z[4]
724extern void bignum_triple_p256 (uint64_t z[static 4], uint64_t x[static 4]); 902extern void bignum_triple_p256 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
725extern void bignum_triple_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); 903extern void bignum_triple_p256_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
726 904
727// Triple modulo p_256k1, z := (3 * x) mod p_256k1 905// Triple modulo p_256k1, z := (3 * x) mod p_256k1
728// Input x[4]; output z[4] 906// Input x[4]; output z[4]
729extern void bignum_triple_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); 907extern void bignum_triple_p256k1 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
730extern void bignum_triple_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); 908extern void bignum_triple_p256k1_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
731 909
732// Triple modulo p_384, z := (3 * x) mod p_384 910// Triple modulo p_384, z := (3 * x) mod p_384
733// Input x[6]; output z[6] 911// Input x[6]; output z[6]
734extern void bignum_triple_p384 (uint64_t z[static 6], uint64_t x[static 6]); 912extern void bignum_triple_p384 (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
735extern void bignum_triple_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); 913extern void bignum_triple_p384_alt (uint64_t z[S2N_BIGNUM_STATIC 6], const uint64_t x[S2N_BIGNUM_STATIC 6]);
736 914
737// Triple modulo p_521, z := (3 * x) mod p_521, assuming x reduced 915// Triple modulo p_521, z := (3 * x) mod p_521, assuming x reduced
738// Input x[9]; output z[9] 916// Input x[9]; output z[9]
739extern void bignum_triple_p521 (uint64_t z[static 9], uint64_t x[static 9]); 917extern void bignum_triple_p521 (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
740extern void bignum_triple_p521_alt (uint64_t z[static 9], uint64_t x[static 9]); 918extern void bignum_triple_p521_alt (uint64_t z[S2N_BIGNUM_STATIC 9], const uint64_t x[S2N_BIGNUM_STATIC 9]);
919
920// Triple modulo p_sm2, z := (3 * x) mod p_sm2
921// Input x[4]; output z[4]
922extern void bignum_triple_sm2 (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
923extern void bignum_triple_sm2_alt (uint64_t z[S2N_BIGNUM_STATIC 4], const uint64_t x[S2N_BIGNUM_STATIC 4]);
741 924
742// Montgomery ladder step for curve25519 925// Montgomery ladder step for curve25519
743// Inputs point[8], pp[16], b; output rr[16] 926// Inputs point[8], pp[16], b; output rr[16]
744extern void curve25519_ladderstep(uint64_t rr[16],uint64_t point[8],uint64_t pp[16],uint64_t b); 927extern void curve25519_ladderstep(uint64_t rr[16],const uint64_t point[8],const uint64_t pp[16],uint64_t b);
745extern void curve25519_ladderstep_alt(uint64_t rr[16],uint64_t point[8],uint64_t pp[16],uint64_t b); 928extern void curve25519_ladderstep_alt(uint64_t rr[16],const uint64_t point[8],const uint64_t pp[16],uint64_t b);
746 929
747// Projective scalar multiplication, x coordinate only, for curve25519 930// Projective scalar multiplication, x coordinate only, for curve25519
748// Inputs scalar[4], point[4]; output res[8] 931// Inputs scalar[4], point[4]; output res[8]
749extern void curve25519_pxscalarmul(uint64_t res[static 8],uint64_t scalar[static 4],uint64_t point[static 4]); 932extern void curve25519_pxscalarmul(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 4]);
750extern void curve25519_pxscalarmul_alt(uint64_t res[static 8],uint64_t scalar[static 4],uint64_t point[static 4]); 933extern void curve25519_pxscalarmul_alt(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 4]);
751 934
752// x25519 function for curve25519 935// x25519 function for curve25519
753// Inputs scalar[4], point[4]; output res[4] 936// Inputs scalar[4], point[4]; output res[4]
754extern void curve25519_x25519(uint64_t res[static 4],uint64_t scalar[static 4],uint64_t point[static 4]); 937extern void curve25519_x25519(uint64_t res[S2N_BIGNUM_STATIC 4],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 4]);
755extern void curve25519_x25519_alt(uint64_t res[static 4],uint64_t scalar[static 4],uint64_t point[static 4]); 938extern void curve25519_x25519_alt(uint64_t res[S2N_BIGNUM_STATIC 4],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 4]);
939
940// x25519 function for curve25519 (byte array arguments)
941// Inputs scalar[32] (bytes), point[32] (bytes); output res[32] (bytes)
942extern void curve25519_x25519_byte(uint8_t res[S2N_BIGNUM_STATIC 32],const uint8_t scalar[S2N_BIGNUM_STATIC 32],const uint8_t point[S2N_BIGNUM_STATIC 32]);
943extern void curve25519_x25519_byte_alt(uint8_t res[S2N_BIGNUM_STATIC 32],const uint8_t scalar[S2N_BIGNUM_STATIC 32],const uint8_t point[S2N_BIGNUM_STATIC 32]);
756 944
757// x25519 function for curve25519 on base element 9 945// x25519 function for curve25519 on base element 9
758// Input scalar[4]; output res[4] 946// Input scalar[4]; output res[4]
759extern void curve25519_x25519base(uint64_t res[static 4],uint64_t scalar[static 4]); 947extern void curve25519_x25519base(uint64_t res[S2N_BIGNUM_STATIC 4],const uint64_t scalar[S2N_BIGNUM_STATIC 4]);
760extern void curve25519_x25519base_alt(uint64_t res[static 4],uint64_t scalar[static 4]); 948extern void curve25519_x25519base_alt(uint64_t res[S2N_BIGNUM_STATIC 4],const uint64_t scalar[S2N_BIGNUM_STATIC 4]);
949
950// x25519 function for curve25519 on base element 9 (byte array arguments)
951// Input scalar[32] (bytes); output res[32] (bytes)
952extern void curve25519_x25519base_byte(uint8_t res[S2N_BIGNUM_STATIC 32],const uint8_t scalar[S2N_BIGNUM_STATIC 32]);
953extern void curve25519_x25519base_byte_alt(uint8_t res[S2N_BIGNUM_STATIC 32],const uint8_t scalar[S2N_BIGNUM_STATIC 32]);
954
955// Decode compressed 256-bit form of edwards25519 point
956// Input c[32] (bytes); output function return and z[8]
957extern uint64_t edwards25519_decode(uint64_t z[S2N_BIGNUM_STATIC 8], const uint8_t c[S2N_BIGNUM_STATIC 32]);
958extern uint64_t edwards25519_decode_alt(uint64_t z[S2N_BIGNUM_STATIC 8], const uint8_t c[S2N_BIGNUM_STATIC 32]);
959
960// Encode edwards25519 point into compressed form as 256-bit number
961// Input p[8]; output z[32] (bytes)
962extern void edwards25519_encode(uint8_t z[S2N_BIGNUM_STATIC 32], const uint64_t p[S2N_BIGNUM_STATIC 8]);
761 963
762// Extended projective addition for edwards25519 964// Extended projective addition for edwards25519
763// Inputs p1[16], p2[16]; output p3[16] 965// Inputs p1[16], p2[16]; output p3[16]
764extern void edwards25519_epadd(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 16]); 966extern void edwards25519_epadd(uint64_t p3[S2N_BIGNUM_STATIC 16],const uint64_t p1[S2N_BIGNUM_STATIC 16],const uint64_t p2[S2N_BIGNUM_STATIC 16]);
765extern void edwards25519_epadd_alt(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 16]); 967extern void edwards25519_epadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 16],const uint64_t p1[S2N_BIGNUM_STATIC 16],const uint64_t p2[S2N_BIGNUM_STATIC 16]);
766 968
767// Extended projective doubling for edwards25519 969// Extended projective doubling for edwards25519
768// Inputs p1[12]; output p3[16] 970// Inputs p1[12]; output p3[16]
769extern void edwards25519_epdouble(uint64_t p3[static 16],uint64_t p1[static 12]); 971extern void edwards25519_epdouble(uint64_t p3[S2N_BIGNUM_STATIC 16],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
770extern void edwards25519_epdouble_alt(uint64_t p3[static 16],uint64_t p1[static 12]); 972extern void edwards25519_epdouble_alt(uint64_t p3[S2N_BIGNUM_STATIC 16],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
771 973
772// Projective doubling for edwards25519 974// Projective doubling for edwards25519
773// Inputs p1[12]; output p3[12] 975// Inputs p1[12]; output p3[12]
774extern void edwards25519_pdouble(uint64_t p3[static 12],uint64_t p1[static 12]); 976extern void edwards25519_pdouble(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
775extern void edwards25519_pdouble_alt(uint64_t p3[static 12],uint64_t p1[static 12]); 977extern void edwards25519_pdouble_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
776 978
777// Extended projective + precomputed mixed addition for edwards25519 979// Extended projective + precomputed mixed addition for edwards25519
778// Inputs p1[16], p2[12]; output p3[16] 980// Inputs p1[16], p2[12]; output p3[16]
779extern void edwards25519_pepadd(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 12]); 981extern void edwards25519_pepadd(uint64_t p3[S2N_BIGNUM_STATIC 16],const uint64_t p1[S2N_BIGNUM_STATIC 16],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
780extern void edwards25519_pepadd_alt(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 12]); 982extern void edwards25519_pepadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 16],const uint64_t p1[S2N_BIGNUM_STATIC 16],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
983
984// Scalar multiplication by standard basepoint for edwards25519 (Ed25519)
985// Input scalar[4]; output res[8]
986extern void edwards25519_scalarmulbase(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4]);
987extern void edwards25519_scalarmulbase_alt(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4]);
988
989// Double scalar multiplication for edwards25519, fresh and base point
990// Input scalar[4], point[8], bscalar[4]; output res[8]
991extern void edwards25519_scalarmuldouble(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4], const uint64_t point[S2N_BIGNUM_STATIC 8],const uint64_t bscalar[S2N_BIGNUM_STATIC 4]);
992extern void edwards25519_scalarmuldouble_alt(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4], const uint64_t point[S2N_BIGNUM_STATIC 8],const uint64_t bscalar[S2N_BIGNUM_STATIC 4]);
993
994// Scalar product of 2-element polynomial vectors in NTT domain, with mulcache
995// Inputs a[512], b[512], bt[256] (signed 16-bit words); output r[256] (signed 16-bit words)
996extern void mlkem_basemul_k2(int16_t r[S2N_BIGNUM_STATIC 256],const int16_t a[S2N_BIGNUM_STATIC 512],const int16_t b[S2N_BIGNUM_STATIC 512],const int16_t bt[S2N_BIGNUM_STATIC 256]);
997
998// Scalar product of 3-element polynomial vectors in NTT domain, with mulcache
999// Inputs a[768], b[768], bt[384] (signed 16-bit words); output r[256] (signed 16-bit words)
1000extern void mlkem_basemul_k3(int16_t r[S2N_BIGNUM_STATIC 256],const int16_t a[S2N_BIGNUM_STATIC 768],const int16_t b[S2N_BIGNUM_STATIC 768],const int16_t bt[S2N_BIGNUM_STATIC 384]);
1001
1002// Scalar product of 4-element polynomial vectors in NTT domain, with mulcache
1003// Inputs a[1024], b[1024], bt[512] (signed 16-bit words); output r[256] (signed 16-bit words)
1004extern void mlkem_basemul_k4(int16_t r[S2N_BIGNUM_STATIC 256],const int16_t a[S2N_BIGNUM_STATIC 1024],const int16_t b[S2N_BIGNUM_STATIC 1024],const int16_t bt[S2N_BIGNUM_STATIC 512]);
1005
1006// Inverse number-theoretic transform from ML-KEM
1007// Input a[256] (signed 16-bit words), z_01234[80] (signed 16-bit words), z_56[384] (signed 16-bit words); output a[256] (signed 16-bit words)
1008extern void mlkem_intt(int16_t a[S2N_BIGNUM_STATIC 256],const int16_t z_01234[S2N_BIGNUM_STATIC 80],const int16_t z_56[S2N_BIGNUM_STATIC 384]);
1009
1010// Precompute the mulcache data for a polynomial in the NTT domain
1011// Inputs a[256], z[128] and t[128] (signed 16-bit words); output x[128] (signed 16-bit words)
1012extern void mlkem_mulcache_compute(int16_t x[S2N_BIGNUM_STATIC 128],const int16_t a[S2N_BIGNUM_STATIC 256],const int16_t z[S2N_BIGNUM_STATIC 128],const int16_t t[S2N_BIGNUM_STATIC 128]);
1013
1014// Forward number-theoretic transform from ML-KEM
1015// Input a[256] (signed 16-bit words), z_01234[80] (signed 16-bit words), z_56[384] (signed 16-bit words); output a[256] (signed 16-bit words)
1016extern void mlkem_ntt(int16_t a[S2N_BIGNUM_STATIC 256],const int16_t z_01234[S2N_BIGNUM_STATIC 80],const int16_t z_56[S2N_BIGNUM_STATIC 384]);
1017
1018// Canonical modular reduction of polynomial coefficients for ML-KEM
1019// Input a[256] (signed 16-bit words); output a[256] (signed 16-bit words)
1020extern void mlkem_reduce(int16_t a[S2N_BIGNUM_STATIC 256]);
1021
1022// Pack ML-KEM polynomial coefficients as 12-bit numbers
1023// Input a[256] (signed 16-bit words); output r[384] (bytes)
1024extern void mlkem_tobytes(uint8_t r[S2N_BIGNUM_STATIC 384],const int16_t a[S2N_BIGNUM_STATIC 256]);
1025
1026// Conversion of ML-KEM polynomial coefficients to Montgomery form
1027// Input a[256] (signed 16-bit words); output a[256] (signed 16-bit words)
1028extern void mlkem_tomont(int16_t a[S2N_BIGNUM_STATIC 256]);
1029
1030// Uniform rejection sampling for ML-KEM
1031// Inputs *buf (unsigned bytes), buflen, table (unsigned bytes); output r[256] (signed 16-bit words), return
1032extern uint64_t mlkem_rej_uniform_VARIABLE_TIME(int16_t r[S2N_BIGNUM_STATIC 256],const uint8_t *buf,uint64_t buflen,const uint8_t *table);
781 1033
782// Point addition on NIST curve P-256 in Montgomery-Jacobian coordinates 1034// Point addition on NIST curve P-256 in Montgomery-Jacobian coordinates
783// Inputs p1[12], p2[12]; output p3[12] 1035// Inputs p1[12], p2[12]; output p3[12]
784extern void p256_montjadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 12]); 1036extern void p256_montjadd(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
1037extern void p256_montjadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
785 1038
786// Point doubling on NIST curve P-256 in Montgomery-Jacobian coordinates 1039// Point doubling on NIST curve P-256 in Montgomery-Jacobian coordinates
787// Inputs p1[12]; output p3[12] 1040// Inputs p1[12]; output p3[12]
788extern void p256_montjdouble(uint64_t p3[static 12],uint64_t p1[static 12]); 1041extern void p256_montjdouble(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
1042extern void p256_montjdouble_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
789 1043
790// Point mixed addition on NIST curve P-256 in Montgomery-Jacobian coordinates 1044// Point mixed addition on NIST curve P-256 in Montgomery-Jacobian coordinates
791// Inputs p1[12], p2[8]; output p3[12] 1045// Inputs p1[12], p2[8]; output p3[12]
792extern void p256_montjmixadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 8]); 1046extern void p256_montjmixadd(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 8]);
1047extern void p256_montjmixadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 8]);
1048
1049// Montgomery-Jacobian form scalar multiplication for P-256
1050// Input scalar[4], point[12]; output res[12]
1051extern void p256_montjscalarmul(uint64_t res[S2N_BIGNUM_STATIC 12],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 12]);
1052extern void p256_montjscalarmul_alt(uint64_t res[S2N_BIGNUM_STATIC 12],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 12]);
1053
1054// Scalar multiplication for NIST curve P-256
1055// Input scalar[4], point[8]; output res[8]
1056extern void p256_scalarmul(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 8]);
1057extern void p256_scalarmul_alt(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 8]);
1058
1059// Scalar multiplication for precomputed point on NIST curve P-256
1060// Input scalar[4], blocksize, table[]; output res[8]
1061extern void p256_scalarmulbase(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4],uint64_t blocksize,const uint64_t *table);
1062extern void p256_scalarmulbase_alt(uint64_t res[S2N_BIGNUM_STATIC 8],const uint64_t scalar[S2N_BIGNUM_STATIC 4],uint64_t blocksize,const uint64_t *table);
793 1063
794// Point addition on NIST curve P-384 in Montgomery-Jacobian coordinates 1064// Point addition on NIST curve P-384 in Montgomery-Jacobian coordinates
795// Inputs p1[18], p2[18]; output p3[18] 1065// Inputs p1[18], p2[18]; output p3[18]
796extern void p384_montjadd(uint64_t p3[static 18],uint64_t p1[static 18],uint64_t p2[static 18]); 1066extern void p384_montjadd(uint64_t p3[S2N_BIGNUM_STATIC 18],const uint64_t p1[S2N_BIGNUM_STATIC 18],const uint64_t p2[S2N_BIGNUM_STATIC 18]);
1067extern void p384_montjadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 18],const uint64_t p1[S2N_BIGNUM_STATIC 18],const uint64_t p2[S2N_BIGNUM_STATIC 18]);
797 1068
798// Point doubling on NIST curve P-384 in Montgomery-Jacobian coordinates 1069// Point doubling on NIST curve P-384 in Montgomery-Jacobian coordinates
799// Inputs p1[18]; output p3[18] 1070// Inputs p1[18]; output p3[18]
800extern void p384_montjdouble(uint64_t p3[static 18],uint64_t p1[static 18]); 1071extern void p384_montjdouble(uint64_t p3[S2N_BIGNUM_STATIC 18],const uint64_t p1[S2N_BIGNUM_STATIC 18]);
1072extern void p384_montjdouble_alt(uint64_t p3[S2N_BIGNUM_STATIC 18],const uint64_t p1[S2N_BIGNUM_STATIC 18]);
801 1073
802// Point mixed addition on NIST curve P-384 in Montgomery-Jacobian coordinates 1074// Point mixed addition on NIST curve P-384 in Montgomery-Jacobian coordinates
803// Inputs p1[18], p2[12]; output p3[18] 1075// Inputs p1[18], p2[12]; output p3[18]
804extern void p384_montjmixadd(uint64_t p3[static 18],uint64_t p1[static 18],uint64_t p2[static 12]); 1076extern void p384_montjmixadd(uint64_t p3[S2N_BIGNUM_STATIC 18],const uint64_t p1[S2N_BIGNUM_STATIC 18],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
1077extern void p384_montjmixadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 18],const uint64_t p1[S2N_BIGNUM_STATIC 18],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
1078
1079// Montgomery-Jacobian form scalar multiplication for P-384
1080// Input scalar[6], point[18]; output res[18]
1081extern void p384_montjscalarmul(uint64_t res[S2N_BIGNUM_STATIC 18],const uint64_t scalar[S2N_BIGNUM_STATIC 6],const uint64_t point[S2N_BIGNUM_STATIC 18]);
1082extern void p384_montjscalarmul_alt(uint64_t res[S2N_BIGNUM_STATIC 18],const uint64_t scalar[S2N_BIGNUM_STATIC 6],const uint64_t point[S2N_BIGNUM_STATIC 18]);
805 1083
806// Point addition on NIST curve P-521 in Jacobian coordinates 1084// Point addition on NIST curve P-521 in Jacobian coordinates
807// Inputs p1[27], p2[27]; output p3[27] 1085// Inputs p1[27], p2[27]; output p3[27]
808extern void p521_jadd(uint64_t p3[static 27],uint64_t p1[static 27],uint64_t p2[static 27]); 1086extern void p521_jadd(uint64_t p3[S2N_BIGNUM_STATIC 27],const uint64_t p1[S2N_BIGNUM_STATIC 27],const uint64_t p2[S2N_BIGNUM_STATIC 27]);
1087extern void p521_jadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 27],const uint64_t p1[S2N_BIGNUM_STATIC 27],const uint64_t p2[S2N_BIGNUM_STATIC 27]);
809 1088
810// Point doubling on NIST curve P-521 in Jacobian coordinates 1089// Point doubling on NIST curve P-521 in Jacobian coordinates
811// Input p1[27]; output p3[27] 1090// Input p1[27]; output p3[27]
812extern void p521_jdouble(uint64_t p3[static 27],uint64_t p1[static 27]); 1091extern void p521_jdouble(uint64_t p3[S2N_BIGNUM_STATIC 27],const uint64_t p1[S2N_BIGNUM_STATIC 27]);
1092extern void p521_jdouble_alt(uint64_t p3[S2N_BIGNUM_STATIC 27],const uint64_t p1[S2N_BIGNUM_STATIC 27]);
813 1093
814// Point mixed addition on NIST curve P-521 in Jacobian coordinates 1094// Point mixed addition on NIST curve P-521 in Jacobian coordinates
815// Inputs p1[27], p2[18]; output p3[27] 1095// Inputs p1[27], p2[18]; output p3[27]
816extern void p521_jmixadd(uint64_t p3[static 27],uint64_t p1[static 27],uint64_t p2[static 18]); 1096extern void p521_jmixadd(uint64_t p3[S2N_BIGNUM_STATIC 27],const uint64_t p1[S2N_BIGNUM_STATIC 27],const uint64_t p2[S2N_BIGNUM_STATIC 18]);
1097extern void p521_jmixadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 27],const uint64_t p1[S2N_BIGNUM_STATIC 27],const uint64_t p2[S2N_BIGNUM_STATIC 18]);
1098
1099// Jacobian form scalar multiplication for P-521
1100// Input scalar[9], point[27]; output res[27]
1101extern void p521_jscalarmul(uint64_t res[S2N_BIGNUM_STATIC 27],const uint64_t scalar[S2N_BIGNUM_STATIC 9],const uint64_t point[S2N_BIGNUM_STATIC 27]);
1102extern void p521_jscalarmul_alt(uint64_t res[S2N_BIGNUM_STATIC 27],const uint64_t scalar[S2N_BIGNUM_STATIC 9],const uint64_t point[S2N_BIGNUM_STATIC 27]);
817 1103
818// Point addition on SECG curve secp256k1 in Jacobian coordinates 1104// Point addition on SECG curve secp256k1 in Jacobian coordinates
819// Inputs p1[12], p2[12]; output p3[12] 1105// Inputs p1[12], p2[12]; output p3[12]
820extern void secp256k1_jadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 12]); 1106extern void secp256k1_jadd(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
1107extern void secp256k1_jadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
821 1108
822// Point doubling on SECG curve secp256k1 in Jacobian coordinates 1109// Point doubling on SECG curve secp256k1 in Jacobian coordinates
823// Input p1[12]; output p3[12] 1110// Input p1[12]; output p3[12]
824extern void secp256k1_jdouble(uint64_t p3[static 12],uint64_t p1[static 12]); 1111extern void secp256k1_jdouble(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
1112extern void secp256k1_jdouble_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
825 1113
826// Point mixed addition on SECG curve secp256k1 in Jacobian coordinates 1114// Point mixed addition on SECG curve secp256k1 in Jacobian coordinates
827// Inputs p1[12], p2[8]; output p3[12] 1115// Inputs p1[12], p2[8]; output p3[12]
828extern void secp256k1_jmixadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 8]); 1116extern void secp256k1_jmixadd(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 8]);
1117extern void secp256k1_jmixadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 8]);
1118
1119// Keccak-f1600 permutation for SHA3
1120// Inputs a[25], rc[24]; output a[25]
1121extern void sha3_keccak_f1600(uint64_t a[S2N_BIGNUM_STATIC 25],const uint64_t rc[S2N_BIGNUM_STATIC 24]);
1122extern void sha3_keccak_f1600_alt(uint64_t a[S2N_BIGNUM_STATIC 25],const uint64_t rc[S2N_BIGNUM_STATIC 24]);
1123
1124// Batched 2-way Keccak-f1600 permutation for SHA3
1125// Inputs a[50], rc[24]; output a[50]
1126extern void sha3_keccak2_f1600(uint64_t a[S2N_BIGNUM_STATIC 50],const uint64_t rc[S2N_BIGNUM_STATIC 24]);
1127extern void sha3_keccak2_f1600_alt(uint64_t a[S2N_BIGNUM_STATIC 50],const uint64_t rc[S2N_BIGNUM_STATIC 24]);
1128
1129// Batched 4-way Keccak-f1600 permutation for SHA3
1130// Inputs a[100], rc[24]; output a[100]
1131extern void sha3_keccak4_f1600(uint64_t a[S2N_BIGNUM_STATIC 100],const uint64_t rc[S2N_BIGNUM_STATIC 24]);
1132extern void sha3_keccak4_f1600_alt(uint64_t a[S2N_BIGNUM_STATIC 100],const uint64_t rc[S2N_BIGNUM_STATIC 24]);
1133extern void sha3_keccak4_f1600_alt2(uint64_t a[S2N_BIGNUM_STATIC 100],const uint64_t rc[S2N_BIGNUM_STATIC 24]);
1134
1135// Point addition on CC curve SM2 in Montgomery-Jacobian coordinates
1136// Inputs p1[12], p2[12]; output p3[12]
1137extern void sm2_montjadd(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
1138extern void sm2_montjadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 12]);
1139
1140// Point doubling on CC curve SM2 in Montgomery-Jacobian coordinates
1141// Inputs p1[12]; output p3[12]
1142extern void sm2_montjdouble(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
1143extern void sm2_montjdouble_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12]);
1144
1145// Point mixed addition on CC curve SM2 in Montgomery-Jacobian coordinates
1146// Inputs p1[12], p2[8]; output p3[12]
1147extern void sm2_montjmixadd(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 8]);
1148extern void sm2_montjmixadd_alt(uint64_t p3[S2N_BIGNUM_STATIC 12],const uint64_t p1[S2N_BIGNUM_STATIC 12],const uint64_t p2[S2N_BIGNUM_STATIC 8]);
1149
1150// Montgomery-Jacobian form scalar multiplication for CC curve SM2
1151// Input scalar[4], point[12]; output res[12]
1152extern void sm2_montjscalarmul(uint64_t res[S2N_BIGNUM_STATIC 12],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 12]);
1153extern void sm2_montjscalarmul_alt(uint64_t res[S2N_BIGNUM_STATIC 12],const uint64_t scalar[S2N_BIGNUM_STATIC 4],const uint64_t point[S2N_BIGNUM_STATIC 12]);
829 1154
830// Reverse the bytes in a single word 1155// Reverse the bytes in a single word
831// Input a; output function return 1156// Input a; output function return
@@ -839,6 +1164,10 @@ extern uint64_t word_clz (uint64_t a);
839// Input a; output function return 1164// Input a; output function return
840extern uint64_t word_ctz (uint64_t a); 1165extern uint64_t word_ctz (uint64_t a);
841 1166
1167// Perform 59 "divstep" iterations and return signed matrix of updates
1168// Inputs d, f, g; output m[2][2] and function return
1169extern int64_t word_divstep59(int64_t m[2][2],int64_t d,uint64_t f,uint64_t g);
1170
842// Return maximum of two unsigned 64-bit words 1171// Return maximum of two unsigned 64-bit words
843// Inputs a, b; output function return 1172// Inputs a, b; output function return
844extern uint64_t word_max (uint64_t a, uint64_t b); 1173extern uint64_t word_max (uint64_t a, uint64_t b);
@@ -851,6 +1180,10 @@ extern uint64_t word_min (uint64_t a, uint64_t b);
851// Input a; output function return 1180// Input a; output function return
852extern uint64_t word_negmodinv (uint64_t a); 1181extern uint64_t word_negmodinv (uint64_t a);
853 1182
1183// Count number of set bits in a single 64-bit word (population count)
1184// Input a; output function return
1185extern uint64_t word_popcount (uint64_t a);
1186
854// Single-word reciprocal, 2^64 + ret = ceil(2^128/a) - 1 if MSB of "a" is set 1187// Single-word reciprocal, 2^64 + ret = ceil(2^128/a) - 1 if MSB of "a" is set
855// Input a; output function return 1188// Input a; output function return
856extern uint64_t word_recip (uint64_t a); 1189extern uint64_t word_recip (uint64_t a);
diff --git a/src/lib/libcrypto/bn/s2n_bignum_internal.h b/src/lib/libcrypto/bn/s2n_bignum_internal.h
index b82db7d019..37eebb4fd6 100644
--- a/src/lib/libcrypto/bn/s2n_bignum_internal.h
+++ b/src/lib/libcrypto/bn/s2n_bignum_internal.h
@@ -1,3 +1,5 @@
1// $OpenBSD: s2n_bignum_internal.h,v 1.5 2025/08/12 10:01:37 jsing Exp $
2//
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// 4//
3// Permission to use, copy, modify, and/or distribute this software for any 5// Permission to use, copy, modify, and/or distribute this software for any
@@ -14,14 +16,14 @@
14 16
15#ifdef __APPLE__ 17#ifdef __APPLE__
16# define S2N_BN_SYMBOL(NAME) _##NAME 18# define S2N_BN_SYMBOL(NAME) _##NAME
19# if defined(__AARCH64EL__) || defined(__ARMEL__)
20# define __LF %%
21# else
22# define __LF ;
23# endif
17#else 24#else
18# define S2N_BN_SYMBOL(name) name 25# define S2N_BN_SYMBOL(name) name
19#endif 26# define __LF ;
20
21#ifdef __CET__
22# include <cet.h>
23#else
24# define _CET_ENDBR
25#endif 27#endif
26 28
27#define S2N_BN_SYM_VISIBILITY_DIRECTIVE(name) .globl S2N_BN_SYMBOL(name) 29#define S2N_BN_SYM_VISIBILITY_DIRECTIVE(name) .globl S2N_BN_SYMBOL(name)
@@ -34,3 +36,24 @@
34#else 36#else
35# define S2N_BN_SYM_PRIVACY_DIRECTIVE(name) /* NO-OP: S2N_BN_SYM_PRIVACY_DIRECTIVE */ 37# define S2N_BN_SYM_PRIVACY_DIRECTIVE(name) /* NO-OP: S2N_BN_SYM_PRIVACY_DIRECTIVE */
36#endif 38#endif
39
40// Enable indirect branch tracking support unless explicitly disabled
41// with -DNO_IBT. If the platform supports CET, simply inherit this from
42// the usual header. Otherwise manually define _CET_ENDBR, used at each
43// x86 entry point, to be the ENDBR64 instruction, with an explicit byte
44// sequence for compilers/assemblers that don't know about it. Note that
45// it is safe to use ENDBR64 on all platforms, since the encoding is by
46// design interpreted as a NOP on all pre-CET x86_64 processors. The only
47// downside is a small increase in code size and potentially a modest
48// slowdown from executing one more instruction.
49
50#if NO_IBT
51# if defined(_CET_ENDBR)
52# error "The s2n-bignum build option NO_IBT was configured, but _CET_ENDBR is defined in this compilation unit. That is weird, so failing the build."
53# endif
54# define _CET_ENDBR
55#elif defined(__CET__)
56# include <cet.h>
57#elif !defined(_CET_ENDBR)
58# define _CET_ENDBR .byte 0xf3,0x0f,0x1e,0xfa
59#endif
diff --git a/src/lib/libcrypto/buffer/buffer.c b/src/lib/libcrypto/buffer/buffer.c
index 51ce90ff80..4a0c17c598 100644
--- a/src/lib/libcrypto/buffer/buffer.c
+++ b/src/lib/libcrypto/buffer/buffer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: buffer.c,v 1.28 2023/07/08 08:26:26 beck Exp $ */ 1/* $OpenBSD: buffer.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,7 +61,8 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h> 64
65#include "err_local.h"
65 66
66/* 67/*
67 * LIMIT_BEFORE_EXPANSION is the maximum n such that (n + 3) / 3 * 4 < 2**31. 68 * LIMIT_BEFORE_EXPANSION is the maximum n such that (n + 3) / 3 * 4 < 2**31.
diff --git a/src/lib/libcrypto/cert.pem b/src/lib/libcrypto/cert.pem
index a7fd3519fb..aadf2deb9b 100644
--- a/src/lib/libcrypto/cert.pem
+++ b/src/lib/libcrypto/cert.pem
@@ -1,4 +1,4 @@
1# $OpenBSD: cert.pem,v 1.31 2025/03/16 07:44:35 tb Exp $ 1# $OpenBSD: cert.pem,v 1.32 2025/08/06 09:45:53 sthen Exp $
2### /C=ES/CN=Autoridad de Certificacion Firmaprofesional CIF A62634068 2### /C=ES/CN=Autoridad de Certificacion Firmaprofesional CIF A62634068
3 3
4=== /C=ES/CN=Autoridad de Certificacion Firmaprofesional CIF A62634068 4=== /C=ES/CN=Autoridad de Certificacion Firmaprofesional CIF A62634068
@@ -960,49 +960,6 @@ AgEGMAoGCCqGSM49BAMDA2gAMGUCMBq8W9f+qdJUDkpd0m2xQNz0Q9XSSpkZElaA
96043j4ptZLvZuHjw/l1lOWqzzIQNph91Oj9w== 96043j4ptZLvZuHjw/l1lOWqzzIQNph91Oj9w==
961-----END CERTIFICATE----- 961-----END CERTIFICATE-----
962 962
963### Baltimore
964
965=== /C=IE/O=Baltimore/OU=CyberTrust/CN=Baltimore CyberTrust Root
966Certificate:
967 Data:
968 Version: 3 (0x2)
969 Serial Number: 33554617 (0x20000b9)
970 Signature Algorithm: sha1WithRSAEncryption
971 Validity
972 Not Before: May 12 18:46:00 2000 GMT
973 Not After : May 12 23:59:00 2025 GMT
974 Subject: C=IE, O=Baltimore, OU=CyberTrust, CN=Baltimore CyberTrust Root
975 X509v3 extensions:
976 X509v3 Subject Key Identifier:
977 E5:9D:59:30:82:47:58:CC:AC:FA:08:54:36:86:7B:3A:B5:04:4D:F0
978 X509v3 Basic Constraints: critical
979 CA:TRUE, pathlen:3
980 X509v3 Key Usage: critical
981 Certificate Sign, CRL Sign
982SHA1 Fingerprint=D4:DE:20:D0:5E:66:FC:53:FE:1A:50:88:2C:78:DB:28:52:CA:E4:74
983SHA256 Fingerprint=16:AF:57:A9:F6:76:B0:AB:12:60:95:AA:5E:BA:DE:F2:2A:B3:11:19:D6:44:AC:95:CD:4B:93:DB:F3:F2:6A:EB
984-----BEGIN CERTIFICATE-----
985MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ
986RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD
987VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX
988DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y
989ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy
990VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr
991mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr
992IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK
993mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu
994XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy
995dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye
996jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1
997BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3
998DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92
9999hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx
1000jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0
1001Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz
1002ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS
1003R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
1004-----END CERTIFICATE-----
1005
1006### Buypass AS-983163327 963### Buypass AS-983163327
1007 964
1008=== /C=NO/O=Buypass AS-983163327/CN=Buypass Class 2 Root CA 965=== /C=NO/O=Buypass AS-983163327/CN=Buypass Class 2 Root CA
@@ -1728,61 +1685,6 @@ v64fG9PiO/yzcnMcmyiQiRM9HcEARwmWmjgb3bHPDcK0RPOWlc4yOo80nOAXx17O
1728rg3bhzjlP1v9mxnhMUF6cKojawHhRUzNlM47ni3niAIi9G7oyOzWPPO5std3eqx7 1685rg3bhzjlP1v9mxnhMUF6cKojawHhRUzNlM47ni3niAIi9G7oyOzWPPO5std3eqx7
1729-----END CERTIFICATE----- 1686-----END CERTIFICATE-----
1730 1687
1731### Comodo CA Limited
1732
1733=== /C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services
1734Certificate:
1735 Data:
1736 Version: 3 (0x2)
1737 Serial Number: 1 (0x1)
1738 Signature Algorithm: sha1WithRSAEncryption
1739 Validity
1740 Not Before: Jan 1 00:00:00 2004 GMT
1741 Not After : Dec 31 23:59:59 2028 GMT
1742 Subject: C=GB, ST=Greater Manchester, L=Salford, O=Comodo CA Limited, CN=AAA Certificate Services
1743 X509v3 extensions:
1744 X509v3 Subject Key Identifier:
1745 A0:11:0A:23:3E:96:F1:07:EC:E2:AF:29:EF:82:A5:7F:D0:30:A4:B4
1746 X509v3 Key Usage: critical
1747 Certificate Sign, CRL Sign
1748 X509v3 Basic Constraints: critical
1749 CA:TRUE
1750 X509v3 CRL Distribution Points:
1751
1752 Full Name:
1753 URI:http://crl.comodoca.com/AAACertificateServices.crl
1754
1755 Full Name:
1756 URI:http://crl.comodo.net/AAACertificateServices.crl
1757
1758SHA1 Fingerprint=D1:EB:23:A4:6D:17:D6:8F:D9:25:64:C2:F1:F1:60:17:64:D8:E3:49
1759SHA256 Fingerprint=D7:A7:A0:FB:5D:7E:27:31:D7:71:E9:48:4E:BC:DE:F7:1D:5F:0C:3E:0A:29:48:78:2B:C8:3E:E0:EA:69:9E:F4
1760-----BEGIN CERTIFICATE-----
1761MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb
1762MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow
1763GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj
1764YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL
1765MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE
1766BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM
1767GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP
1768ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua
1769BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe
17703M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4
1771YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR
1772rOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cm
1773ez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQU
1774oBEKIz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
1775MAMBAf8wewYDVR0fBHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20v
1776QUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29t
1777b2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2VzLmNybDANBgkqhkiG9w0BAQUF
1778AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q
1779GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
1780Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2
1781G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi
1782l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3
1783smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
1784-----END CERTIFICATE-----
1785
1786### Cybertrust Japan Co., Ltd. 1688### Cybertrust Japan Co., Ltd.
1787 1689
1788=== /C=JP/O=Cybertrust Japan Co., Ltd./CN=SecureSign Root CA12 1690=== /C=JP/O=Cybertrust Japan Co., Ltd./CN=SecureSign Root CA12
@@ -3070,53 +2972,6 @@ eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m
30700vdXcDazv/wor3ElhVsT/h5/WrQ8 29720vdXcDazv/wor3ElhVsT/h5/WrQ8
3071-----END CERTIFICATE----- 2973-----END CERTIFICATE-----
3072 2974
3073### Entrust.net
3074
3075=== /O=Entrust.net/OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Certification Authority (2048)
3076Certificate:
3077 Data:
3078 Version: 3 (0x2)
3079 Serial Number: 946069240 (0x3863def8)
3080 Signature Algorithm: sha1WithRSAEncryption
3081 Validity
3082 Not Before: Dec 24 17:50:51 1999 GMT
3083 Not After : Jul 24 14:15:12 2029 GMT
3084 Subject: O=Entrust.net, OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Certification Authority (2048)
3085 X509v3 extensions:
3086 X509v3 Key Usage: critical
3087 Certificate Sign, CRL Sign
3088 X509v3 Basic Constraints: critical
3089 CA:TRUE
3090 X509v3 Subject Key Identifier:
3091 55:E4:81:D1:11:80:BE:D8:89:B9:08:A3:31:F9:A1:24:09:16:B9:70
3092SHA1 Fingerprint=50:30:06:09:1D:97:D4:F5:AE:39:F7:CB:E7:92:7D:7D:65:2D:34:31
3093SHA256 Fingerprint=6D:C4:71:72:E0:1C:BC:B0:BF:62:58:0D:89:5F:E2:B8:AC:9A:D4:F8:73:80:1E:0C:10:B9:C8:37:D2:1E:B1:77
3094-----BEGIN CERTIFICATE-----
3095MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML
3096RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp
3097bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5
3098IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp
3099ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0yOTA3
3100MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3
3101LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp
3102YWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG
3103A1UEAxMqRW50cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgp
3104MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArU1LqRKGsuqjIAcVFmQq
3105K0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOLGp18EzoOH1u3Hs/lJBQe
3106sYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSrhRSGlVuX
3107MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT
3108XTzWnLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/
3109HoZdenoVve8AjhUiVBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH
31104QIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV
3111HQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJKoZIhvcNAQEFBQADggEBADub
3112j1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPyT/4xmf3IDExo
3113U8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
3114zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5b
3115u/8j72gZyxKTJ1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+
3116bYQLCIt+jerXmCHG8+c8eS9enNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/Er
3117fF6adulZkMV8gzURZVE=
3118-----END CERTIFICATE-----
3119
3120### FNMT-RCM 2975### FNMT-RCM
3121 2976
3122=== /C=ES/O=FNMT-RCM/OU=AC RAIZ FNMT-RCM 2977=== /C=ES/O=FNMT-RCM/OU=AC RAIZ FNMT-RCM
@@ -3559,47 +3414,6 @@ u+YfjyW6hY0XHgL+XVAEV8/+LbzvXMAaq7afJMbfc2hIkCwU9D9SGuTSyxTDYWnP
3559N3ec592kD3ZDZopD8p/7DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3 3414N3ec592kD3ZDZopD8p/7DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3
3560vouXsXgxT7PntgMTzlSdriVZzH81Xwj3QEUxeCp6 3415vouXsXgxT7PntgMTzlSdriVZzH81Xwj3QEUxeCp6
3561-----END CERTIFICATE----- 3416-----END CERTIFICATE-----
3562=== /C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
3563Certificate:
3564 Data:
3565 Version: 3 (0x2)
3566 Serial Number:
3567 04:00:00:00:00:01:15:4b:5a:c3:94
3568 Signature Algorithm: sha1WithRSAEncryption
3569 Validity
3570 Not Before: Sep 1 12:00:00 1998 GMT
3571 Not After : Jan 28 12:00:00 2028 GMT
3572 Subject: C=BE, O=GlobalSign nv-sa, OU=Root CA, CN=GlobalSign Root CA
3573 X509v3 extensions:
3574 X509v3 Key Usage: critical
3575 Certificate Sign, CRL Sign
3576 X509v3 Basic Constraints: critical
3577 CA:TRUE
3578 X509v3 Subject Key Identifier:
3579 60:7B:66:1A:45:0D:97:CA:89:50:2F:7D:04:CD:34:A8:FF:FC:FD:4B
3580SHA1 Fingerprint=B1:BC:96:8B:D4:F4:9D:62:2A:A8:9A:81:F2:15:01:52:A4:1D:82:9C
3581SHA256 Fingerprint=EB:D4:10:40:E4:BB:3E:C7:42:C9:E3:81:D3:1E:F2:A4:1A:48:B6:68:5C:96:E7:CE:F3:C1:DF:6C:D4:33:1C:99
3582-----BEGIN CERTIFICATE-----
3583MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
3584A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
3585b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
3586MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
3587YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
3588aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
3589jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
3590xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
35911Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
3592snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
3593U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
35949iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
3595BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
3596AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
3597yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
359838NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
3599AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
3600DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
3601HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
3602-----END CERTIFICATE-----
3603 3417
3604### GoDaddy.com, Inc. 3418### GoDaddy.com, Inc.
3605 3419
@@ -5481,52 +5295,6 @@ CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
5481 5295
5482### Starfield Technologies, Inc. 5296### Starfield Technologies, Inc.
5483 5297
5484=== /C=US/O=Starfield Technologies, Inc./OU=Starfield Class 2 Certification Authority
5485Certificate:
5486 Data:
5487 Version: 3 (0x2)
5488 Serial Number: 0 (0x0)
5489 Signature Algorithm: sha1WithRSAEncryption
5490 Validity
5491 Not Before: Jun 29 17:39:16 2004 GMT
5492 Not After : Jun 29 17:39:16 2034 GMT
5493 Subject: C=US, O=Starfield Technologies, Inc., OU=Starfield Class 2 Certification Authority
5494 X509v3 extensions:
5495 X509v3 Subject Key Identifier:
5496 BF:5F:B7:D1:CE:DD:1F:86:F4:5B:55:AC:DC:D7:10:C2:0E:A9:88:E7
5497 X509v3 Authority Key Identifier:
5498 keyid:BF:5F:B7:D1:CE:DD:1F:86:F4:5B:55:AC:DC:D7:10:C2:0E:A9:88:E7
5499 DirName:/C=US/O=Starfield Technologies, Inc./OU=Starfield Class 2 Certification Authority
5500 serial:00
5501
5502 X509v3 Basic Constraints:
5503 CA:TRUE
5504SHA1 Fingerprint=AD:7E:1C:28:B0:64:EF:8F:60:03:40:20:14:C3:D0:E3:37:0E:B5:8A
5505SHA256 Fingerprint=14:65:FA:20:53:97:B8:76:FA:A6:F0:A9:95:8E:55:90:E4:0F:CC:7F:AA:4F:B7:C2:C8:67:75:21:FB:5F:B6:58
5506-----BEGIN CERTIFICATE-----
5507MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl
5508MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp
5509U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw
5510NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE
5511ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp
5512ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3
5513DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf
55148MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN
5515+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0
5516X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa
5517K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA
55181W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G
5519A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR
5520zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0
5521YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD
5522bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w
5523DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3
5524L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D
5525eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
5526xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp
5527VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY
5528WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=
5529-----END CERTIFICATE-----
5530=== /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./CN=Starfield Root Certificate Authority - G2 5298=== /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./CN=Starfield Root Certificate Authority - G2
5531Certificate: 5299Certificate:
5532 Data: 5300 Data:
@@ -6020,55 +5788,6 @@ HL/EVlP6Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVx
6020SK236thZiNSQvxaz2emsWWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY= 5788SK236thZiNSQvxaz2emsWWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
6021-----END CERTIFICATE----- 5789-----END CERTIFICATE-----
6022 5790
6023### The Go Daddy Group, Inc.
6024
6025=== /C=US/O=The Go Daddy Group, Inc./OU=Go Daddy Class 2 Certification Authority
6026Certificate:
6027 Data:
6028 Version: 3 (0x2)
6029 Serial Number: 0 (0x0)
6030 Signature Algorithm: sha1WithRSAEncryption
6031 Validity
6032 Not Before: Jun 29 17:06:20 2004 GMT
6033 Not After : Jun 29 17:06:20 2034 GMT
6034 Subject: C=US, O=The Go Daddy Group, Inc., OU=Go Daddy Class 2 Certification Authority
6035 X509v3 extensions:
6036 X509v3 Subject Key Identifier:
6037 D2:C4:B0:D2:91:D4:4C:11:71:B3:61:CB:3D:A1:FE:DD:A8:6A:D4:E3
6038 X509v3 Authority Key Identifier:
6039 keyid:D2:C4:B0:D2:91:D4:4C:11:71:B3:61:CB:3D:A1:FE:DD:A8:6A:D4:E3
6040 DirName:/C=US/O=The Go Daddy Group, Inc./OU=Go Daddy Class 2 Certification Authority
6041 serial:00
6042
6043 X509v3 Basic Constraints:
6044 CA:TRUE
6045SHA1 Fingerprint=27:96:BA:E6:3F:18:01:E2:77:26:1B:A0:D7:77:70:02:8F:20:EE:E4
6046SHA256 Fingerprint=C3:84:6B:F2:4B:9E:93:CA:64:27:4C:0E:C6:7C:1E:CC:5E:02:4F:FC:AC:D2:D7:40:19:35:0E:81:FE:54:6A:E4
6047-----BEGIN CERTIFICATE-----
6048MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh
6049MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE
6050YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3
6051MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo
6052ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg
6053MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN
6054ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA
6055PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w
6056wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi
6057EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY
6058avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+
6059YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE
6060sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h
6061/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5
6062IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj
6063YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
6064ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy
6065OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P
6066TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
6067HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER
6068dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf
6069ReYNnyicsbkqWletNw+vHX/bvZ8=
6070-----END CERTIFICATE-----
6071
6072### The USERTRUST Network 5791### The USERTRUST Network
6073 5792
6074=== /C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust ECC Certification Authority 5793=== /C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust ECC Certification Authority
@@ -6669,63 +6388,6 @@ rYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0EAwMDaAAwZQIwJsdpW9zV
6669Mgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9 6388Mgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
6670-----END CERTIFICATE----- 6389-----END CERTIFICATE-----
6671 6390
6672### XRamp Security Services Inc
6673
6674=== /C=US/OU=www.xrampsecurity.com/O=XRamp Security Services Inc/CN=XRamp Global Certification Authority
6675Certificate:
6676 Data:
6677 Version: 3 (0x2)
6678 Serial Number:
6679 50:94:6c:ec:18:ea:d5:9c:4d:d5:97:ef:75:8f:a0:ad
6680 Signature Algorithm: sha1WithRSAEncryption
6681 Validity
6682 Not Before: Nov 1 17:14:04 2004 GMT
6683 Not After : Jan 1 05:37:19 2035 GMT
6684 Subject: C=US, OU=www.xrampsecurity.com, O=XRamp Security Services Inc, CN=XRamp Global Certification Authority
6685 X509v3 extensions:
6686 1.3.6.1.4.1.311.20.2:
6687 ...C.A
6688 X509v3 Key Usage:
6689 Digital Signature, Certificate Sign, CRL Sign
6690 X509v3 Basic Constraints: critical
6691 CA:TRUE
6692 X509v3 Subject Key Identifier:
6693 C6:4F:A2:3D:06:63:84:09:9C:CE:62:E4:04:AC:8D:5C:B5:E9:B6:1B
6694 X509v3 CRL Distribution Points:
6695
6696 Full Name:
6697 URI:http://crl.xrampsecurity.com/XGCA.crl
6698
6699 1.3.6.1.4.1.311.21.1:
6700 ...
6701SHA1 Fingerprint=B8:01:86:D1:EB:9C:86:A5:41:04:CF:30:54:F3:4C:52:B7:E5:58:C6
6702SHA256 Fingerprint=CE:CD:DC:90:50:99:D8:DA:DF:C5:B1:D2:09:B7:37:CB:E2:C1:8C:FB:2C:10:C0:FF:0B:CF:0D:32:86:FC:1A:A2
6703-----BEGIN CERTIFICATE-----
6704MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB
6705gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk
6706MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY
6707UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTAxMTcx
6708NDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3
6709dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2Vy
6710dmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
6711dXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS6
671238eMpSe2OAtp87ZOqCwuIR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCP
6713KZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMxfoArtYzAQDsRhtDLooY2YKTVMIJt2W7Q
6714DxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FEzG+gSqmUsE3a56k0enI4
6715qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqsAxcZZPRa
6716JSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNVi
6717PvryxS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0P
6718BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASs
6719jVy16bYbMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0
6720eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQEwDQYJKoZIhvcNAQEFBQAD
6721ggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc/Kh4ZzXxHfAR
6722vbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
6723qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLa
6724IR9NmXmd4c8nnxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSy
6725i6mx5O+aGtA9aZnuqCij4Tyz8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQ
6726O+7ETPTsJ3xCwnR8gooJybQDJbw=
6727-----END CERTIFICATE-----
6728
6729### certSIGN 6391### certSIGN
6730 6392
6731=== /C=RO/O=certSIGN/OU=certSIGN ROOT CA 6393=== /C=RO/O=certSIGN/OU=certSIGN ROOT CA
diff --git a/src/lib/libcrypto/cms/cms_dd.c b/src/lib/libcrypto/cms/cms_dd.c
index 0a357094c5..daccbcd988 100644
--- a/src/lib/libcrypto/cms/cms_dd.c
+++ b/src/lib/libcrypto/cms/cms_dd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_dd.c,v 1.17 2023/10/26 09:08:57 tb Exp $ */ 1/* $OpenBSD: cms_dd.c,v 1.18 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -56,11 +56,11 @@
56 56
57#include <openssl/asn1.h> 57#include <openssl/asn1.h>
58#include <openssl/cms.h> 58#include <openssl/cms.h>
59#include <openssl/err.h>
60#include <openssl/evp.h> 59#include <openssl/evp.h>
61#include <openssl/objects.h> 60#include <openssl/objects.h>
62 61
63#include "cms_local.h" 62#include "cms_local.h"
63#include "err_local.h"
64#include "x509_local.h" 64#include "x509_local.h"
65 65
66/* CMS DigestedData Utilities */ 66/* CMS DigestedData Utilities */
diff --git a/src/lib/libcrypto/cms/cms_enc.c b/src/lib/libcrypto/cms/cms_enc.c
index ef6925dbd6..928b396815 100644
--- a/src/lib/libcrypto/cms/cms_enc.c
+++ b/src/lib/libcrypto/cms/cms_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_enc.c,v 1.25 2024/11/01 18:34:06 tb Exp $ */ 1/* $OpenBSD: cms_enc.c,v 1.26 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -58,12 +58,12 @@
58#include <openssl/asn1.h> 58#include <openssl/asn1.h>
59#include <openssl/bio.h> 59#include <openssl/bio.h>
60#include <openssl/cms.h> 60#include <openssl/cms.h>
61#include <openssl/err.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
65 64
66#include "cms_local.h" 65#include "cms_local.h"
66#include "err_local.h"
67#include "evp_local.h" 67#include "evp_local.h"
68 68
69/* CMS EncryptedData Utilities */ 69/* CMS EncryptedData Utilities */
diff --git a/src/lib/libcrypto/cms/cms_env.c b/src/lib/libcrypto/cms/cms_env.c
index 629d23215e..7fa578466d 100644
--- a/src/lib/libcrypto/cms/cms_env.c
+++ b/src/lib/libcrypto/cms/cms_env.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_env.c,v 1.28 2024/11/01 18:42:10 tb Exp $ */ 1/* $OpenBSD: cms_env.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -59,12 +59,12 @@
59#include <openssl/asn1.h> 59#include <openssl/asn1.h>
60#include <openssl/bio.h> 60#include <openssl/bio.h>
61#include <openssl/cms.h> 61#include <openssl/cms.h>
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
67#include "cms_local.h" 66#include "cms_local.h"
67#include "err_local.h"
68#include "evp_local.h" 68#include "evp_local.h"
69 69
70/* CMS EnvelopedData Utilities */ 70/* CMS EnvelopedData Utilities */
diff --git a/src/lib/libcrypto/cms/cms_ess.c b/src/lib/libcrypto/cms/cms_ess.c
index f01dcf73ed..5435fa404c 100644
--- a/src/lib/libcrypto/cms/cms_ess.c
+++ b/src/lib/libcrypto/cms/cms_ess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_ess.c,v 1.26 2024/11/01 18:53:35 tb Exp $ */ 1/* $OpenBSD: cms_ess.c,v 1.27 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -57,13 +57,13 @@
57 57
58#include <openssl/asn1.h> 58#include <openssl/asn1.h>
59#include <openssl/cms.h> 59#include <openssl/cms.h>
60#include <openssl/err.h>
61#include <openssl/evp.h> 60#include <openssl/evp.h>
62#include <openssl/objects.h> 61#include <openssl/objects.h>
63#include <openssl/x509.h> 62#include <openssl/x509.h>
64#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
65 64
66#include "cms_local.h" 65#include "cms_local.h"
66#include "err_local.h"
67 67
68CMS_ReceiptRequest * 68CMS_ReceiptRequest *
69d2i_CMS_ReceiptRequest(CMS_ReceiptRequest **a, const unsigned char **in, long len) 69d2i_CMS_ReceiptRequest(CMS_ReceiptRequest **a, const unsigned char **in, long len)
diff --git a/src/lib/libcrypto/cms/cms_io.c b/src/lib/libcrypto/cms/cms_io.c
index 84ada47c49..a9be5461a3 100644
--- a/src/lib/libcrypto/cms/cms_io.c
+++ b/src/lib/libcrypto/cms/cms_io.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_io.c,v 1.21 2024/03/30 01:53:05 joshua Exp $ */ 1/* $OpenBSD: cms_io.c,v 1.22 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -54,12 +54,12 @@
54 54
55#include <openssl/asn1t.h> 55#include <openssl/asn1t.h>
56#include <openssl/cms.h> 56#include <openssl/cms.h>
57#include <openssl/err.h>
58#include <openssl/pem.h> 57#include <openssl/pem.h>
59#include <openssl/x509.h> 58#include <openssl/x509.h>
60 59
61#include "asn1_local.h" 60#include "asn1_local.h"
62#include "cms_local.h" 61#include "cms_local.h"
62#include "err_local.h"
63 63
64int 64int
65CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) 65CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms)
diff --git a/src/lib/libcrypto/cms/cms_kari.c b/src/lib/libcrypto/cms/cms_kari.c
index 86b1ad9e83..c23da18058 100644
--- a/src/lib/libcrypto/cms/cms_kari.c
+++ b/src/lib/libcrypto/cms/cms_kari.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_kari.c,v 1.17 2024/11/01 18:34:06 tb Exp $ */ 1/* $OpenBSD: cms_kari.c,v 1.18 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -57,10 +57,10 @@
57 57
58#include <openssl/asn1.h> 58#include <openssl/asn1.h>
59#include <openssl/cms.h> 59#include <openssl/cms.h>
60#include <openssl/err.h>
61#include <openssl/evp.h> 60#include <openssl/evp.h>
62 61
63#include "cms_local.h" 62#include "cms_local.h"
63#include "err_local.h"
64 64
65/* Key Agreement Recipient Info (KARI) routines */ 65/* Key Agreement Recipient Info (KARI) routines */
66 66
diff --git a/src/lib/libcrypto/cms/cms_lib.c b/src/lib/libcrypto/cms/cms_lib.c
index 2d7a8d9f21..b9fc5c21c7 100644
--- a/src/lib/libcrypto/cms/cms_lib.c
+++ b/src/lib/libcrypto/cms/cms_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_lib.c,v 1.26 2024/11/01 18:53:35 tb Exp $ */ 1/* $OpenBSD: cms_lib.c,v 1.27 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -57,13 +57,13 @@
57#include <openssl/asn1.h> 57#include <openssl/asn1.h>
58#include <openssl/bio.h> 58#include <openssl/bio.h>
59#include <openssl/cms.h> 59#include <openssl/cms.h>
60#include <openssl/err.h>
61#include <openssl/evp.h> 60#include <openssl/evp.h>
62#include <openssl/objects.h> 61#include <openssl/objects.h>
63#include <openssl/x509.h> 62#include <openssl/x509.h>
64#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
65 64
66#include "cms_local.h" 65#include "cms_local.h"
66#include "err_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
69CMS_ContentInfo * 69CMS_ContentInfo *
diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c
index b6fe5df961..1f64fc71f7 100644
--- a/src/lib/libcrypto/cms/cms_pwri.c
+++ b/src/lib/libcrypto/cms/cms_pwri.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_pwri.c,v 1.31 2024/01/14 18:40:24 tb Exp $ */ 1/* $OpenBSD: cms_pwri.c,v 1.32 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -58,13 +58,13 @@
58#include <string.h> 58#include <string.h>
59 59
60#include <openssl/asn1.h> 60#include <openssl/asn1.h>
61#include <openssl/err.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/cms.h> 62#include <openssl/cms.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
67#include "cms_local.h" 66#include "cms_local.h"
67#include "err_local.h"
68#include "evp_local.h" 68#include "evp_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
70 70
diff --git a/src/lib/libcrypto/cms/cms_sd.c b/src/lib/libcrypto/cms/cms_sd.c
index 9cdd4ce143..abcac83e47 100644
--- a/src/lib/libcrypto/cms/cms_sd.c
+++ b/src/lib/libcrypto/cms/cms_sd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_sd.c,v 1.33 2024/04/20 10:11:55 tb Exp $ */ 1/* $OpenBSD: cms_sd.c,v 1.36 2025/07/31 02:24:21 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -57,7 +57,6 @@
57 57
58#include <openssl/asn1.h> 58#include <openssl/asn1.h>
59#include <openssl/bio.h> 59#include <openssl/bio.h>
60#include <openssl/err.h>
61#include <openssl/evp.h> 60#include <openssl/evp.h>
62#include <openssl/cms.h> 61#include <openssl/cms.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
@@ -66,6 +65,7 @@
66 65
67#include "asn1_local.h" 66#include "asn1_local.h"
68#include "cms_local.h" 67#include "cms_local.h"
68#include "err_local.h"
69#include "evp_local.h" 69#include "evp_local.h"
70#include "x509_local.h" 70#include "x509_local.h"
71 71
@@ -484,35 +484,6 @@ CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, EVP_PKEY *pk,
484} 484}
485LCRYPTO_ALIAS(CMS_add1_signer); 485LCRYPTO_ALIAS(CMS_add1_signer);
486 486
487static int
488cms_add1_signingTime(CMS_SignerInfo *si, ASN1_TIME *t)
489{
490 ASN1_TIME *tt;
491 int r = 0;
492
493 if (t)
494 tt = t;
495 else
496 tt = X509_gmtime_adj(NULL, 0);
497
498 if (!tt)
499 goto merr;
500
501 if (CMS_signed_add1_attr_by_NID(si, NID_pkcs9_signingTime,
502 tt->type, tt, -1) <= 0)
503 goto merr;
504
505 r = 1;
506
507 merr:
508 if (!t)
509 ASN1_TIME_free(tt);
510 if (!r)
511 CMSerror(ERR_R_MALLOC_FAILURE);
512
513 return r;
514}
515
516EVP_PKEY_CTX * 487EVP_PKEY_CTX *
517CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si) 488CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si)
518{ 489{
@@ -778,6 +749,7 @@ cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain)
778int 749int
779CMS_SignerInfo_sign(CMS_SignerInfo *si) 750CMS_SignerInfo_sign(CMS_SignerInfo *si)
780{ 751{
752 ASN1_TIME *at = NULL;
781 const EVP_MD *md; 753 const EVP_MD *md;
782 unsigned char *buf = NULL, *sig = NULL; 754 unsigned char *buf = NULL, *sig = NULL;
783 int buf_len = 0; 755 int buf_len = 0;
@@ -788,7 +760,12 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si)
788 goto err; 760 goto err;
789 761
790 if (CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1) < 0) { 762 if (CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1) < 0) {
791 if (!cms_add1_signingTime(si, NULL)) 763 if ((at = X509_gmtime_adj(NULL, 0)) == NULL) {
764 CMSerror(ERR_R_MALLOC_FAILURE);
765 goto err;
766 }
767 if (!CMS_signed_add1_attr_by_NID(si, NID_pkcs9_signingTime,
768 at->type, at, -1))
792 goto err; 769 goto err;
793 } 770 }
794 771
@@ -828,6 +805,7 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si)
828 ret = 1; 805 ret = 1;
829 806
830 err: 807 err:
808 ASN1_TIME_free(at);
831 (void)EVP_MD_CTX_reset(si->mctx); 809 (void)EVP_MD_CTX_reset(si->mctx);
832 freezero(buf, buf_len); 810 freezero(buf, buf_len);
833 freezero(sig, sig_len); 811 freezero(sig, sig_len);
@@ -1012,6 +990,8 @@ LCRYPTO_ALIAS(CMS_add_smimecap);
1012 * Add AlgorithmIdentifier OID of type |nid| to the SMIMECapability attribute 990 * Add AlgorithmIdentifier OID of type |nid| to the SMIMECapability attribute
1013 * set |*out_algs| (see RFC 3851, section 2.5.2). If keysize > 0, the OID has 991 * set |*out_algs| (see RFC 3851, section 2.5.2). If keysize > 0, the OID has
1014 * an integer parameter of value |keysize|, otherwise parameters are omitted. 992 * an integer parameter of value |keysize|, otherwise parameters are omitted.
993 *
994 * See also PKCS7_simple_smimecap().
1015 */ 995 */
1016int 996int
1017CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **out_algs, int nid, int keysize) 997CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **out_algs, int nid, int keysize)
diff --git a/src/lib/libcrypto/cms/cms_smime.c b/src/lib/libcrypto/cms/cms_smime.c
index 5a194748d9..85a0e6f6e5 100644
--- a/src/lib/libcrypto/cms/cms_smime.c
+++ b/src/lib/libcrypto/cms/cms_smime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_smime.c,v 1.28 2023/12/22 10:23:11 tb Exp $ */ 1/* $OpenBSD: cms_smime.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -59,7 +59,6 @@
59#include <openssl/asn1.h> 59#include <openssl/asn1.h>
60#include <openssl/bio.h> 60#include <openssl/bio.h>
61#include <openssl/cms.h> 61#include <openssl/cms.h>
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/pkcs7.h> 64#include <openssl/pkcs7.h>
@@ -67,6 +66,7 @@
67#include <openssl/x509_vfy.h> 66#include <openssl/x509_vfy.h>
68 67
69#include "cms_local.h" 68#include "cms_local.h"
69#include "err_local.h"
70 70
71static BIO * 71static BIO *
72cms_get_text_bio(BIO *out, unsigned int flags) 72cms_get_text_bio(BIO *out, unsigned int flags)
diff --git a/src/lib/libcrypto/conf/README b/src/lib/libcrypto/conf/README
deleted file mode 100644
index 96e53b34ed..0000000000
--- a/src/lib/libcrypto/conf/README
+++ /dev/null
@@ -1,73 +0,0 @@
1Configuration modules. These are a set of modules which can perform
2various configuration functions.
3
4Currently the routines should be called at most once when an application
5starts up: that is before it starts any threads.
6
7The routines read a configuration file set up like this:
8
9-----
10#default section
11openssl_conf=init_section
12
13[init_section]
14
15module1=value1
16#Second instance of module1
17module1.1=valueX
18module2=value2
19module3=dso_literal
20module4=dso_section
21
22[dso_section]
23
24path=/some/path/to/some/dso.so
25other_stuff=other_value
26----
27
28When this file is loaded a configuration module with the specified string
29(module* in the above example) is looked up and its init function called as:
30
31int conf_init_func(CONF_IMODULE *md, CONF *cnf);
32
33The function can then take whatever action is appropriate, for example further
34lookups based on the value. Multiple instances of the same config module can be
35loaded.
36
37When the application closes down the modules are cleaned up by calling an
38optional finish function:
39
40void conf_finish_func(CONF_IMODULE *md);
41
42The finish functions are called in reverse order: that is the last module
43loaded is the first one cleaned up.
44
45If no module exists with a given name then an attempt is made to load a DSO
46with the supplied name. This might mean that "module3" attempts to load a DSO
47called libmodule3.so or module3.dll for example. An explicit DSO name can be
48given by including a separate section as in the module4 example above.
49
50The DSO is expected to at least contain an initialization function:
51
52int OPENSSL_init(CONF_IMODULE *md, CONF *cnf);
53
54and may also include a finish function:
55
56void OPENSSL_finish(CONF_IMODULE *md);
57
58Static modules can also be added using,
59
60int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func
61*ffunc);
62
63where "name" is the name in the configuration file this function corresponds
64to.
65
66A set of builtin modules (currently only an ASN1 non functional test module)
67can be added by calling OPENSSL_load_builtin_modules().
68
69The function OPENSSL_config() is intended as a simple configuration function
70that any application can call to perform various default configuration tasks.
71It uses the file openssl.cnf in the usual locations.
72
73
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c
index 0173a7117c..fe9391685d 100644
--- a/src/lib/libcrypto/conf/conf_def.c
+++ b/src/lib/libcrypto/conf/conf_def.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: conf_def.c,v 1.44 2024/08/31 09:46:17 tb Exp $ */ 1/* $OpenBSD: conf_def.c,v 1.45 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,12 +63,12 @@
63 63
64#include <openssl/buffer.h> 64#include <openssl/buffer.h>
65#include <openssl/conf.h> 65#include <openssl/conf.h>
66#include <openssl/err.h>
67#include <openssl/lhash.h> 66#include <openssl/lhash.h>
68#include <openssl/stack.h> 67#include <openssl/stack.h>
69 68
70#include "conf_def.h" 69#include "conf_def.h"
71#include "conf_local.h" 70#include "conf_local.h"
71#include "err_local.h"
72 72
73#define MAX_CONF_VALUE_LENGTH 65536 73#define MAX_CONF_VALUE_LENGTH 65536
74 74
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c
index 863e1c9475..84b4f8b0a7 100644
--- a/src/lib/libcrypto/conf/conf_lib.c
+++ b/src/lib/libcrypto/conf/conf_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: conf_lib.c,v 1.25 2025/03/08 09:35:53 tb Exp $ */ 1/* $OpenBSD: conf_lib.c,v 1.26 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -58,11 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <openssl/crypto.h> 60#include <openssl/crypto.h>
61#include <openssl/err.h>
62#include <openssl/conf.h> 61#include <openssl/conf.h>
63#include <openssl/lhash.h> 62#include <openssl/lhash.h>
64 63
65#include "conf_local.h" 64#include "conf_local.h"
65#include "err_local.h"
66 66
67static const CONF_METHOD *default_CONF_method = NULL; 67static const CONF_METHOD *default_CONF_method = NULL;
68 68
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index 0e07bb3ea5..6e697cc478 100644
--- a/src/lib/libcrypto/conf/conf_mod.c
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: conf_mod.c,v 1.40 2024/10/10 06:51:22 tb Exp $ */ 1/* $OpenBSD: conf_mod.c,v 1.41 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL 2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -63,9 +63,10 @@
63 63
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/crypto.h> 65#include <openssl/crypto.h>
66#include <openssl/err.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68 67
68#include "err_local.h"
69
69/* This structure contains data about supported modules. */ 70/* This structure contains data about supported modules. */
70struct conf_module_st { 71struct conf_module_st {
71 /* Name of the module */ 72 /* Name of the module */
diff --git a/src/lib/libcrypto/crypto_ex_data.c b/src/lib/libcrypto/crypto_ex_data.c
index ceb3a92e51..233905f888 100644
--- a/src/lib/libcrypto/crypto_ex_data.c
+++ b/src/lib/libcrypto/crypto_ex_data.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_ex_data.c,v 1.4 2024/08/03 07:45:26 tb Exp $ */ 1/* $OpenBSD: crypto_ex_data.c,v 1.6 2025/06/15 15:58:56 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -52,7 +52,7 @@ crypto_ex_data_classes_init(void)
52 return 1; 52 return 1;
53 53
54 if ((classes_new = calloc(CRYPTO_EX_INDEX__COUNT, 54 if ((classes_new = calloc(CRYPTO_EX_INDEX__COUNT,
55 sizeof(struct crypto_ex_data_index))) == NULL) 55 sizeof(*classes_new))) == NULL)
56 return 0; 56 return 0;
57 57
58 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); 58 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
@@ -100,11 +100,10 @@ CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
100 goto err; 100 goto err;
101 101
102 if ((class = classes[class_index]) == NULL) { 102 if ((class = classes[class_index]) == NULL) {
103 if ((new_class = calloc(1, 103 if ((new_class = calloc(1, sizeof(*new_class))) == NULL)
104 sizeof(struct crypto_ex_data_class))) == NULL)
105 goto err; 104 goto err;
106 if ((new_class->indexes = calloc(CRYPTO_EX_DATA_MAX_INDEX, 105 if ((new_class->indexes = calloc(CRYPTO_EX_DATA_MAX_INDEX,
107 sizeof(struct crypto_ex_data_index *))) == NULL) 106 sizeof(*new_class->indexes))) == NULL)
108 goto err; 107 goto err;
109 new_class->indexes_len = CRYPTO_EX_DATA_MAX_INDEX; 108 new_class->indexes_len = CRYPTO_EX_DATA_MAX_INDEX;
110 new_class->next_index = 1; 109 new_class->next_index = 1;
@@ -119,7 +118,7 @@ CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
119 class = classes[class_index]; 118 class = classes[class_index];
120 } 119 }
121 120
122 if ((index = calloc(1, sizeof(struct crypto_ex_data_index))) == NULL) 121 if ((index = calloc(1, sizeof(*index))) == NULL)
123 goto err; 122 goto err;
124 123
125 index->new_func = new_func; 124 index->new_func = new_func;
@@ -200,12 +199,12 @@ crypto_ex_data_init(CRYPTO_EX_DATA *exdata)
200 if (exdata->sk != NULL) 199 if (exdata->sk != NULL)
201 goto err; 200 goto err;
202 201
203 if ((ced = calloc(1, sizeof(struct crypto_ex_data))) == NULL) 202 if ((ced = calloc(1, sizeof(*ced))) == NULL)
204 goto err; 203 goto err;
205 204
206 ced->class_index = -1; 205 ced->class_index = -1;
207 206
208 if ((ced->slots = calloc(CRYPTO_EX_DATA_MAX_INDEX, sizeof(void *))) == NULL) 207 if ((ced->slots = calloc(CRYPTO_EX_DATA_MAX_INDEX, sizeof(*ced->slots))) == NULL)
209 goto err; 208 goto err;
210 ced->slots_len = CRYPTO_EX_DATA_MAX_INDEX; 209 ced->slots_len = CRYPTO_EX_DATA_MAX_INDEX;
211 210
diff --git a/src/lib/libcrypto/crypto_init.c b/src/lib/libcrypto/crypto_init.c
index 6016d1ae40..ae4914e358 100644
--- a/src/lib/libcrypto/crypto_init.c
+++ b/src/lib/libcrypto/crypto_init.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_init.c,v 1.22 2024/10/17 14:27:57 jsing Exp $ */ 1/* $OpenBSD: crypto_init.c,v 1.26 2025/06/11 07:41:12 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -22,12 +22,12 @@
22 22
23#include <openssl/asn1.h> 23#include <openssl/asn1.h>
24#include <openssl/conf.h> 24#include <openssl/conf.h>
25#include <openssl/err.h>
26#include <openssl/evp.h> 25#include <openssl/evp.h>
27#include <openssl/objects.h> 26#include <openssl/objects.h>
28#include <openssl/x509v3.h> 27#include <openssl/x509v3.h>
29 28
30#include "crypto_internal.h" 29#include "crypto_internal.h"
30#include "err_local.h"
31#include "x509_issuer_cache.h" 31#include "x509_issuer_cache.h"
32 32
33int OpenSSL_config(const char *); 33int OpenSSL_config(const char *);
@@ -37,6 +37,30 @@ static pthread_once_t crypto_init_once = PTHREAD_ONCE_INIT;
37static pthread_t crypto_init_thread; 37static pthread_t crypto_init_thread;
38static int crypto_init_cleaned_up; 38static int crypto_init_cleaned_up;
39 39
40void openssl_init_crypto_constructor(void) __attribute__((constructor));
41
42#ifndef HAVE_CRYPTO_CPU_CAPS_INIT
43void
44crypto_cpu_caps_init(void)
45{
46}
47#endif
48
49/*
50 * This function is invoked as a constructor when the library is loaded. The
51 * code run from here must not allocate memory or trigger signals. The only
52 * safe code is to read data and update global variables.
53 */
54void
55openssl_init_crypto_constructor(void)
56{
57 crypto_cpu_caps_init();
58}
59
60/*
61 * This is used by various configure scripts to check availability of libcrypto,
62 * so we need to keep it.
63 */
40void 64void
41OPENSSL_init(void) 65OPENSSL_init(void)
42{ 66{
@@ -48,8 +72,6 @@ OPENSSL_init_crypto_internal(void)
48{ 72{
49 crypto_init_thread = pthread_self(); 73 crypto_init_thread = pthread_self();
50 74
51 crypto_cpu_caps_init();
52
53 ERR_load_crypto_strings(); 75 ERR_load_crypto_strings();
54} 76}
55 77
diff --git a/src/lib/libcrypto/crypto_internal.h b/src/lib/libcrypto/crypto_internal.h
index 09ae7fa466..058245e95e 100644
--- a/src/lib/libcrypto/crypto_internal.h
+++ b/src/lib/libcrypto/crypto_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_internal.h,v 1.15 2025/01/19 07:51:41 jsing Exp $ */ 1/* $OpenBSD: crypto_internal.h,v 1.16 2025/07/22 09:18:02 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -300,6 +300,4 @@ crypto_ror_u64(uint64_t v, size_t shift)
300 300
301void crypto_cpu_caps_init(void); 301void crypto_cpu_caps_init(void);
302 302
303uint64_t crypto_cpu_caps_ia32(void);
304
305#endif 303#endif
diff --git a/src/lib/libcrypto/crypto_legacy.c b/src/lib/libcrypto/crypto_legacy.c
index d864fc4c3f..dcaa63236c 100644
--- a/src/lib/libcrypto/crypto_legacy.c
+++ b/src/lib/libcrypto/crypto_legacy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_legacy.c,v 1.6 2024/11/06 04:18:42 tb Exp $ */ 1/* $OpenBSD: crypto_legacy.c,v 1.9 2025/07/22 09:18:02 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -123,10 +123,10 @@
123 123
124#include <openssl/opensslconf.h> 124#include <openssl/opensslconf.h>
125#include <openssl/crypto.h> 125#include <openssl/crypto.h>
126#include <openssl/err.h>
127 126
128#include "crypto_internal.h" 127#include "crypto_internal.h"
129#include "crypto_local.h" 128#include "crypto_local.h"
129#include "err_local.h"
130#include "x86_arch.h" 130#include "x86_arch.h"
131 131
132/* Machine independent capabilities. */ 132/* Machine independent capabilities. */
@@ -306,29 +306,6 @@ void
306} 306}
307LCRYPTO_ALIAS(CRYPTO_get_dynlock_destroy_callback); 307LCRYPTO_ALIAS(CRYPTO_get_dynlock_destroy_callback);
308 308
309#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
310void
311OPENSSL_cpuid_setup(void)
312{
313}
314#endif
315
316#ifndef HAVE_CRYPTO_CPU_CAPS_INIT
317void
318crypto_cpu_caps_init(void)
319{
320 OPENSSL_cpuid_setup();
321}
322#endif
323
324#ifndef HAVE_CRYPTO_CPU_CAPS_IA32
325uint64_t
326crypto_cpu_caps_ia32(void)
327{
328 return 0;
329}
330#endif
331
332uint64_t 309uint64_t
333OPENSSL_cpu_caps(void) 310OPENSSL_cpu_caps(void)
334{ 311{
diff --git a/src/lib/libcrypto/crypto_local.h b/src/lib/libcrypto/crypto_local.h
index 2b4c74552f..606f17cefb 100644
--- a/src/lib/libcrypto/crypto_local.h
+++ b/src/lib/libcrypto/crypto_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_local.h,v 1.4 2024/11/05 10:11:58 tb Exp $ */ 1/* $OpenBSD: crypto_local.h,v 1.6 2025/06/09 14:37:48 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -65,6 +65,10 @@
65extern "C" { 65extern "C" {
66#endif 66#endif
67 67
68#ifndef OPENSSLDIR
69#define OPENSSLDIR "/etc/ssl"
70#endif
71
68#define X509_CERT_AREA OPENSSLDIR 72#define X509_CERT_AREA OPENSSLDIR
69#define X509_CERT_DIR OPENSSLDIR "/certs" 73#define X509_CERT_DIR OPENSSLDIR "/certs"
70#define X509_CERT_FILE OPENSSLDIR "/cert.pem" 74#define X509_CERT_FILE OPENSSLDIR "/cert.pem"
@@ -75,8 +79,6 @@ extern "C" {
75#define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf" 79#define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf"
76#define CTLOG_FILE_EVP "CTLOG_FILE" 80#define CTLOG_FILE_EVP "CTLOG_FILE"
77 81
78void OPENSSL_cpuid_setup(void);
79
80#ifdef __cplusplus 82#ifdef __cplusplus
81} 83}
82#endif 84#endif
diff --git a/src/lib/libcrypto/ct/ct_b64.c b/src/lib/libcrypto/ct/ct_b64.c
index 101cd1e2b1..e6e0532add 100644
--- a/src/lib/libcrypto/ct/ct_b64.c
+++ b/src/lib/libcrypto/ct/ct_b64.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_b64.c,v 1.7 2023/07/08 07:22:58 beck Exp $ */ 1/* $OpenBSD: ct_b64.c,v 1.8 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson 3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson
4 * (steve@openssl.org) for the OpenSSL project 2014. 4 * (steve@openssl.org) for the OpenSSL project 2014.
@@ -61,11 +61,11 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/ct.h> 63#include <openssl/ct.h>
64#include <openssl/err.h>
65#include <openssl/evp.h> 64#include <openssl/evp.h>
66 65
67#include "bytestring.h" 66#include "bytestring.h"
68#include "ct_local.h" 67#include "ct_local.h"
68#include "err_local.h"
69 69
70/* 70/*
71 * Decodes the base64 string |in| into |out|. 71 * Decodes the base64 string |in| into |out|.
diff --git a/src/lib/libcrypto/ct/ct_log.c b/src/lib/libcrypto/ct/ct_log.c
index 72045477ac..48611df979 100644
--- a/src/lib/libcrypto/ct/ct_log.c
+++ b/src/lib/libcrypto/ct/ct_log.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_log.c,v 1.9 2024/11/05 09:35:40 tb Exp $ */ 1/* $OpenBSD: ct_log.c,v 1.10 2025/05/10 05:54:38 tb Exp $ */
2/* Author: Adam Eijdenberg <adam.eijdenberg@gmail.com>. */ 2/* Author: Adam Eijdenberg <adam.eijdenberg@gmail.com>. */
3/* ==================================================================== 3/* ====================================================================
4 * Copyright (c) 1998-2016 The OpenSSL Project. All rights reserved. 4 * Copyright (c) 1998-2016 The OpenSSL Project. All rights reserved.
@@ -65,13 +65,13 @@
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#include <openssl/conf.h> 66#include <openssl/conf.h>
67#include <openssl/ct.h> 67#include <openssl/ct.h>
68#include <openssl/err.h>
69#include <openssl/evp.h> 68#include <openssl/evp.h>
70#include <openssl/sha.h> 69#include <openssl/sha.h>
71#include <openssl/x509.h> 70#include <openssl/x509.h>
72 71
73#include "conf_local.h" 72#include "conf_local.h"
74#include "crypto_local.h" 73#include "crypto_local.h"
74#include "err_local.h"
75 75
76 76
77/* 77/*
diff --git a/src/lib/libcrypto/ct/ct_oct.c b/src/lib/libcrypto/ct/ct_oct.c
index 1f5e5c75d0..686d845f11 100644
--- a/src/lib/libcrypto/ct/ct_oct.c
+++ b/src/lib/libcrypto/ct/ct_oct.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_oct.c,v 1.9 2023/07/08 07:22:58 beck Exp $ */ 1/* $OpenBSD: ct_oct.c,v 1.10 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson 3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson
4 * (steve@openssl.org) for the OpenSSL project 2014. 4 * (steve@openssl.org) for the OpenSSL project 2014.
@@ -67,10 +67,10 @@
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68#include <openssl/buffer.h> 68#include <openssl/buffer.h>
69#include <openssl/ct.h> 69#include <openssl/ct.h>
70#include <openssl/err.h>
71 70
72#include "bytestring.h" 71#include "bytestring.h"
73#include "ct_local.h" 72#include "ct_local.h"
73#include "err_local.h"
74 74
75int 75int
76o2i_SCT_signature(SCT *sct, CBS *cbs) 76o2i_SCT_signature(SCT *sct, CBS *cbs)
diff --git a/src/lib/libcrypto/ct/ct_policy.c b/src/lib/libcrypto/ct/ct_policy.c
index eb2b312019..a242b0d8f8 100644
--- a/src/lib/libcrypto/ct/ct_policy.c
+++ b/src/lib/libcrypto/ct/ct_policy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_policy.c,v 1.6 2023/07/08 07:22:58 beck Exp $ */ 1/* $OpenBSD: ct_policy.c,v 1.7 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Implementations of Certificate Transparency SCT policies. 3 * Implementations of Certificate Transparency SCT policies.
4 * Written by Rob Percival (robpercival@google.com) for the OpenSSL project. 4 * Written by Rob Percival (robpercival@google.com) for the OpenSSL project.
@@ -56,11 +56,12 @@
56# error "CT is disabled" 56# error "CT is disabled"
57#endif 57#endif
58 58
59#include <openssl/ct.h>
60#include <openssl/err.h>
61#include <time.h> 59#include <time.h>
62 60
61#include <openssl/ct.h>
62
63#include "ct_local.h" 63#include "ct_local.h"
64#include "err_local.h"
64 65
65/* 66/*
66 * Number of seconds in the future that an SCT timestamp can be, by default, 67 * Number of seconds in the future that an SCT timestamp can be, by default,
diff --git a/src/lib/libcrypto/ct/ct_sct.c b/src/lib/libcrypto/ct/ct_sct.c
index 4b2716e734..d647e34d92 100644
--- a/src/lib/libcrypto/ct/ct_sct.c
+++ b/src/lib/libcrypto/ct/ct_sct.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_sct.c,v 1.10 2023/07/22 17:02:49 tb Exp $ */ 1/* $OpenBSD: ct_sct.c,v 1.11 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Rob Stradling (rob@comodo.com), Stephen Henson (steve@openssl.org) 3 * Written by Rob Stradling (rob@comodo.com), Stephen Henson (steve@openssl.org)
4 * and Adam Eijdenberg (adam.eijdenberg@gmail.com) for the OpenSSL project 2016. 4 * and Adam Eijdenberg (adam.eijdenberg@gmail.com) for the OpenSSL project 2016.
@@ -67,11 +67,11 @@
67 67
68#include <openssl/asn1.h> 68#include <openssl/asn1.h>
69#include <openssl/ct.h> 69#include <openssl/ct.h>
70#include <openssl/err.h>
71#include <openssl/objects.h> 70#include <openssl/objects.h>
72#include <openssl/x509.h> 71#include <openssl/x509.h>
73 72
74#include "ct_local.h" 73#include "ct_local.h"
74#include "err_local.h"
75 75
76SCT * 76SCT *
77SCT_new(void) 77SCT_new(void)
diff --git a/src/lib/libcrypto/ct/ct_sct_ctx.c b/src/lib/libcrypto/ct/ct_sct_ctx.c
index b2b6d4e269..930c7df59b 100644
--- a/src/lib/libcrypto/ct/ct_sct_ctx.c
+++ b/src/lib/libcrypto/ct/ct_sct_ctx.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_sct_ctx.c,v 1.6 2022/06/30 11:14:47 tb Exp $ */ 1/* $OpenBSD: ct_sct_ctx.c,v 1.7 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson 3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson
4 * (steve@openssl.org) for the OpenSSL project 2014. 4 * (steve@openssl.org) for the OpenSSL project 2014.
@@ -64,11 +64,11 @@
64#include <stddef.h> 64#include <stddef.h>
65#include <string.h> 65#include <string.h>
66 66
67#include <openssl/err.h>
68#include <openssl/objects.h> 67#include <openssl/objects.h>
69#include <openssl/x509.h> 68#include <openssl/x509.h>
70 69
71#include "ct_local.h" 70#include "ct_local.h"
71#include "err_local.h"
72 72
73SCT_CTX * 73SCT_CTX *
74SCT_CTX_new(void) 74SCT_CTX_new(void)
diff --git a/src/lib/libcrypto/ct/ct_vfy.c b/src/lib/libcrypto/ct/ct_vfy.c
index 424117263a..5dbb2096e1 100644
--- a/src/lib/libcrypto/ct/ct_vfy.c
+++ b/src/lib/libcrypto/ct/ct_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ct_vfy.c,v 1.6 2022/01/06 14:34:40 jsing Exp $ */ 1/* $OpenBSD: ct_vfy.c,v 1.7 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson 3 * Written by Rob Stradling (rob@comodo.com) and Stephen Henson
4 * (steve@openssl.org) for the OpenSSL project 2014. 4 * (steve@openssl.org) for the OpenSSL project 2014.
@@ -60,11 +60,11 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/ct.h> 62#include <openssl/ct.h>
63#include <openssl/err.h>
64#include <openssl/evp.h> 63#include <openssl/evp.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
67#include "ct_local.h" 66#include "ct_local.h"
67#include "err_local.h"
68 68
69typedef enum sct_signature_type_t { 69typedef enum sct_signature_type_t {
70 SIGNATURE_TYPE_NOT_SET = -1, 70 SIGNATURE_TYPE_NOT_SET = -1,
diff --git a/src/lib/libcrypto/curve25519/curve25519.c b/src/lib/libcrypto/curve25519/curve25519.c
index 4e644c4280..0aa3d2855b 100644
--- a/src/lib/libcrypto/curve25519/curve25519.c
+++ b/src/lib/libcrypto/curve25519/curve25519.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: curve25519.c,v 1.16 2023/07/08 15:12:49 beck Exp $ */ 1/* $OpenBSD: curve25519.c,v 1.18 2025/07/29 10:52:20 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015, Google Inc. 3 * Copyright (c) 2015, Google Inc.
4 * 4 *
@@ -3781,6 +3781,17 @@ ge_double_scalarmult_vartime(ge_p2 *r, const uint8_t *a,
3781 } 3781 }
3782} 3782}
3783 3783
3784/*
3785 * int64_lshift21 returns |a << 21| but is defined when shifting bits into the
3786 * sign bit. This works around a language flaw in C.
3787 *
3788 * XXX: This is a hack to avoid undefined behavior when shifting into the sign bit.
3789 * We match BoringSSL's implementation here.
3790 */
3791static inline int64_t int64_lshift21(int64_t a) {
3792 return (int64_t)((uint64_t)a << 21);
3793}
3794
3784/* The set of scalars is \Z/l 3795/* The set of scalars is \Z/l
3785 * where l = 2^252 + 27742317777372353535851937790883648493. */ 3796 * where l = 2^252 + 27742317777372353535851937790883648493. */
3786 3797
@@ -3885,38 +3896,38 @@ x25519_sc_reduce(uint8_t *s) {
3885 3896
3886 carry6 = (s6 + (1 << 20)) >> 21; 3897 carry6 = (s6 + (1 << 20)) >> 21;
3887 s7 += carry6; 3898 s7 += carry6;
3888 s6 -= carry6 << 21; 3899 s6 -= int64_lshift21(carry6);
3889 carry8 = (s8 + (1 << 20)) >> 21; 3900 carry8 = (s8 + (1 << 20)) >> 21;
3890 s9 += carry8; 3901 s9 += carry8;
3891 s8 -= carry8 << 21; 3902 s8 -= int64_lshift21(carry8);
3892 carry10 = (s10 + (1 << 20)) >> 21; 3903 carry10 = (s10 + (1 << 20)) >> 21;
3893 s11 += carry10; 3904 s11 += carry10;
3894 s10 -= carry10 << 21; 3905 s10 -= int64_lshift21(carry10);
3895 carry12 = (s12 + (1 << 20)) >> 21; 3906 carry12 = (s12 + (1 << 20)) >> 21;
3896 s13 += carry12; 3907 s13 += carry12;
3897 s12 -= carry12 << 21; 3908 s12 -= int64_lshift21(carry12);
3898 carry14 = (s14 + (1 << 20)) >> 21; 3909 carry14 = (s14 + (1 << 20)) >> 21;
3899 s15 += carry14; 3910 s15 += carry14;
3900 s14 -= carry14 << 21; 3911 s14 -= int64_lshift21(carry14);
3901 carry16 = (s16 + (1 << 20)) >> 21; 3912 carry16 = (s16 + (1 << 20)) >> 21;
3902 s17 += carry16; 3913 s17 += carry16;
3903 s16 -= carry16 << 21; 3914 s16 -= int64_lshift21(carry16);
3904 3915
3905 carry7 = (s7 + (1 << 20)) >> 21; 3916 carry7 = (s7 + (1 << 20)) >> 21;
3906 s8 += carry7; 3917 s8 += carry7;
3907 s7 -= carry7 << 21; 3918 s7 -= int64_lshift21(carry7);
3908 carry9 = (s9 + (1 << 20)) >> 21; 3919 carry9 = (s9 + (1 << 20)) >> 21;
3909 s10 += carry9; 3920 s10 += carry9;
3910 s9 -= carry9 << 21; 3921 s9 -= int64_lshift21(carry9);
3911 carry11 = (s11 + (1 << 20)) >> 21; 3922 carry11 = (s11 + (1 << 20)) >> 21;
3912 s12 += carry11; 3923 s12 += carry11;
3913 s11 -= carry11 << 21; 3924 s11 -= int64_lshift21(carry11);
3914 carry13 = (s13 + (1 << 20)) >> 21; 3925 carry13 = (s13 + (1 << 20)) >> 21;
3915 s14 += carry13; 3926 s14 += carry13;
3916 s13 -= carry13 << 21; 3927 s13 -= int64_lshift21(carry13);
3917 carry15 = (s15 + (1 << 20)) >> 21; 3928 carry15 = (s15 + (1 << 20)) >> 21;
3918 s16 += carry15; 3929 s16 += carry15;
3919 s15 -= carry15 << 21; 3930 s15 -= int64_lshift21(carry15);
3920 3931
3921 s5 += s17 * 666643; 3932 s5 += s17 * 666643;
3922 s6 += s17 * 470296; 3933 s6 += s17 * 470296;
@@ -3968,41 +3979,41 @@ x25519_sc_reduce(uint8_t *s) {
3968 3979
3969 carry0 = (s0 + (1 << 20)) >> 21; 3980 carry0 = (s0 + (1 << 20)) >> 21;
3970 s1 += carry0; 3981 s1 += carry0;
3971 s0 -= carry0 << 21; 3982 s0 -= int64_lshift21(carry0);
3972 carry2 = (s2 + (1 << 20)) >> 21; 3983 carry2 = (s2 + (1 << 20)) >> 21;
3973 s3 += carry2; 3984 s3 += carry2;
3974 s2 -= carry2 << 21; 3985 s2 -= int64_lshift21(carry2);
3975 carry4 = (s4 + (1 << 20)) >> 21; 3986 carry4 = (s4 + (1 << 20)) >> 21;
3976 s5 += carry4; 3987 s5 += carry4;
3977 s4 -= carry4 << 21; 3988 s4 -= int64_lshift21(carry4);
3978 carry6 = (s6 + (1 << 20)) >> 21; 3989 carry6 = (s6 + (1 << 20)) >> 21;
3979 s7 += carry6; 3990 s7 += carry6;
3980 s6 -= carry6 << 21; 3991 s6 -= int64_lshift21(carry6);
3981 carry8 = (s8 + (1 << 20)) >> 21; 3992 carry8 = (s8 + (1 << 20)) >> 21;
3982 s9 += carry8; 3993 s9 += carry8;
3983 s8 -= carry8 << 21; 3994 s8 -= int64_lshift21(carry8);
3984 carry10 = (s10 + (1 << 20)) >> 21; 3995 carry10 = (s10 + (1 << 20)) >> 21;
3985 s11 += carry10; 3996 s11 += carry10;
3986 s10 -= carry10 << 21; 3997 s10 -= int64_lshift21(carry10);
3987 3998
3988 carry1 = (s1 + (1 << 20)) >> 21; 3999 carry1 = (s1 + (1 << 20)) >> 21;
3989 s2 += carry1; 4000 s2 += carry1;
3990 s1 -= carry1 << 21; 4001 s1 -= int64_lshift21(carry1);
3991 carry3 = (s3 + (1 << 20)) >> 21; 4002 carry3 = (s3 + (1 << 20)) >> 21;
3992 s4 += carry3; 4003 s4 += carry3;
3993 s3 -= carry3 << 21; 4004 s3 -= int64_lshift21(carry3);
3994 carry5 = (s5 + (1 << 20)) >> 21; 4005 carry5 = (s5 + (1 << 20)) >> 21;
3995 s6 += carry5; 4006 s6 += carry5;
3996 s5 -= carry5 << 21; 4007 s5 -= int64_lshift21(carry5);
3997 carry7 = (s7 + (1 << 20)) >> 21; 4008 carry7 = (s7 + (1 << 20)) >> 21;
3998 s8 += carry7; 4009 s8 += carry7;
3999 s7 -= carry7 << 21; 4010 s7 -= int64_lshift21(carry7);
4000 carry9 = (s9 + (1 << 20)) >> 21; 4011 carry9 = (s9 + (1 << 20)) >> 21;
4001 s10 += carry9; 4012 s10 += carry9;
4002 s9 -= carry9 << 21; 4013 s9 -= int64_lshift21(carry9);
4003 carry11 = (s11 + (1 << 20)) >> 21; 4014 carry11 = (s11 + (1 << 20)) >> 21;
4004 s12 += carry11; 4015 s12 += carry11;
4005 s11 -= carry11 << 21; 4016 s11 -= int64_lshift21(carry11);
4006 4017
4007 s0 += s12 * 666643; 4018 s0 += s12 * 666643;
4008 s1 += s12 * 470296; 4019 s1 += s12 * 470296;
@@ -4014,40 +4025,40 @@ x25519_sc_reduce(uint8_t *s) {
4014 4025
4015 carry0 = s0 >> 21; 4026 carry0 = s0 >> 21;
4016 s1 += carry0; 4027 s1 += carry0;
4017 s0 -= carry0 << 21; 4028 s0 -= int64_lshift21(carry0);
4018 carry1 = s1 >> 21; 4029 carry1 = s1 >> 21;
4019 s2 += carry1; 4030 s2 += carry1;
4020 s1 -= carry1 << 21; 4031 s1 -= int64_lshift21(carry1);
4021 carry2 = s2 >> 21; 4032 carry2 = s2 >> 21;
4022 s3 += carry2; 4033 s3 += carry2;
4023 s2 -= carry2 << 21; 4034 s2 -= int64_lshift21(carry2);
4024 carry3 = s3 >> 21; 4035 carry3 = s3 >> 21;
4025 s4 += carry3; 4036 s4 += carry3;
4026 s3 -= carry3 << 21; 4037 s3 -= int64_lshift21(carry3);
4027 carry4 = s4 >> 21; 4038 carry4 = s4 >> 21;
4028 s5 += carry4; 4039 s5 += carry4;
4029 s4 -= carry4 << 21; 4040 s4 -= int64_lshift21(carry4);
4030 carry5 = s5 >> 21; 4041 carry5 = s5 >> 21;
4031 s6 += carry5; 4042 s6 += carry5;
4032 s5 -= carry5 << 21; 4043 s5 -= int64_lshift21(carry5);
4033 carry6 = s6 >> 21; 4044 carry6 = s6 >> 21;
4034 s7 += carry6; 4045 s7 += carry6;
4035 s6 -= carry6 << 21; 4046 s6 -= int64_lshift21(carry6);
4036 carry7 = s7 >> 21; 4047 carry7 = s7 >> 21;
4037 s8 += carry7; 4048 s8 += carry7;
4038 s7 -= carry7 << 21; 4049 s7 -= int64_lshift21(carry7);
4039 carry8 = s8 >> 21; 4050 carry8 = s8 >> 21;
4040 s9 += carry8; 4051 s9 += carry8;
4041 s8 -= carry8 << 21; 4052 s8 -= int64_lshift21(carry8);
4042 carry9 = s9 >> 21; 4053 carry9 = s9 >> 21;
4043 s10 += carry9; 4054 s10 += carry9;
4044 s9 -= carry9 << 21; 4055 s9 -= int64_lshift21(carry9);
4045 carry10 = s10 >> 21; 4056 carry10 = s10 >> 21;
4046 s11 += carry10; 4057 s11 += carry10;
4047 s10 -= carry10 << 21; 4058 s10 -= int64_lshift21(carry10);
4048 carry11 = s11 >> 21; 4059 carry11 = s11 >> 21;
4049 s12 += carry11; 4060 s12 += carry11;
4050 s11 -= carry11 << 21; 4061 s11 -= int64_lshift21(carry11);
4051 4062
4052 s0 += s12 * 666643; 4063 s0 += s12 * 666643;
4053 s1 += s12 * 470296; 4064 s1 += s12 * 470296;
@@ -4059,37 +4070,37 @@ x25519_sc_reduce(uint8_t *s) {
4059 4070
4060 carry0 = s0 >> 21; 4071 carry0 = s0 >> 21;
4061 s1 += carry0; 4072 s1 += carry0;
4062 s0 -= carry0 << 21; 4073 s0 -= int64_lshift21(carry0);
4063 carry1 = s1 >> 21; 4074 carry1 = s1 >> 21;
4064 s2 += carry1; 4075 s2 += carry1;
4065 s1 -= carry1 << 21; 4076 s1 -= int64_lshift21(carry1);
4066 carry2 = s2 >> 21; 4077 carry2 = s2 >> 21;
4067 s3 += carry2; 4078 s3 += carry2;
4068 s2 -= carry2 << 21; 4079 s2 -= int64_lshift21(carry2);
4069 carry3 = s3 >> 21; 4080 carry3 = s3 >> 21;
4070 s4 += carry3; 4081 s4 += carry3;
4071 s3 -= carry3 << 21; 4082 s3 -= int64_lshift21(carry3);
4072 carry4 = s4 >> 21; 4083 carry4 = s4 >> 21;
4073 s5 += carry4; 4084 s5 += carry4;
4074 s4 -= carry4 << 21; 4085 s4 -= int64_lshift21(carry4);
4075 carry5 = s5 >> 21; 4086 carry5 = s5 >> 21;
4076 s6 += carry5; 4087 s6 += carry5;
4077 s5 -= carry5 << 21; 4088 s5 -= int64_lshift21(carry5);
4078 carry6 = s6 >> 21; 4089 carry6 = s6 >> 21;
4079 s7 += carry6; 4090 s7 += carry6;
4080 s6 -= carry6 << 21; 4091 s6 -= int64_lshift21(carry6);
4081 carry7 = s7 >> 21; 4092 carry7 = s7 >> 21;
4082 s8 += carry7; 4093 s8 += carry7;
4083 s7 -= carry7 << 21; 4094 s7 -= int64_lshift21(carry7);
4084 carry8 = s8 >> 21; 4095 carry8 = s8 >> 21;
4085 s9 += carry8; 4096 s9 += carry8;
4086 s8 -= carry8 << 21; 4097 s8 -= int64_lshift21(carry8);
4087 carry9 = s9 >> 21; 4098 carry9 = s9 >> 21;
4088 s10 += carry9; 4099 s10 += carry9;
4089 s9 -= carry9 << 21; 4100 s9 -= int64_lshift21(carry9);
4090 carry10 = s10 >> 21; 4101 carry10 = s10 >> 21;
4091 s11 += carry10; 4102 s11 += carry10;
4092 s10 -= carry10 << 21; 4103 s10 -= int64_lshift21(carry10);
4093 4104
4094 s[0] = s0 >> 0; 4105 s[0] = s0 >> 0;
4095 s[1] = s0 >> 8; 4106 s[1] = s0 >> 8;
@@ -4257,74 +4268,74 @@ sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b,
4257 4268
4258 carry0 = (s0 + (1 << 20)) >> 21; 4269 carry0 = (s0 + (1 << 20)) >> 21;
4259 s1 += carry0; 4270 s1 += carry0;
4260 s0 -= carry0 << 21; 4271 s0 -= int64_lshift21(carry0);
4261 carry2 = (s2 + (1 << 20)) >> 21; 4272 carry2 = (s2 + (1 << 20)) >> 21;
4262 s3 += carry2; 4273 s3 += carry2;
4263 s2 -= carry2 << 21; 4274 s2 -= int64_lshift21(carry2);
4264 carry4 = (s4 + (1 << 20)) >> 21; 4275 carry4 = (s4 + (1 << 20)) >> 21;
4265 s5 += carry4; 4276 s5 += carry4;
4266 s4 -= carry4 << 21; 4277 s4 -= int64_lshift21(carry4);
4267 carry6 = (s6 + (1 << 20)) >> 21; 4278 carry6 = (s6 + (1 << 20)) >> 21;
4268 s7 += carry6; 4279 s7 += carry6;
4269 s6 -= carry6 << 21; 4280 s6 -= int64_lshift21(carry6);
4270 carry8 = (s8 + (1 << 20)) >> 21; 4281 carry8 = (s8 + (1 << 20)) >> 21;
4271 s9 += carry8; 4282 s9 += carry8;
4272 s8 -= carry8 << 21; 4283 s8 -= int64_lshift21(carry8);
4273 carry10 = (s10 + (1 << 20)) >> 21; 4284 carry10 = (s10 + (1 << 20)) >> 21;
4274 s11 += carry10; 4285 s11 += carry10;
4275 s10 -= carry10 << 21; 4286 s10 -= int64_lshift21(carry10);
4276 carry12 = (s12 + (1 << 20)) >> 21; 4287 carry12 = (s12 + (1 << 20)) >> 21;
4277 s13 += carry12; 4288 s13 += carry12;
4278 s12 -= carry12 << 21; 4289 s12 -= int64_lshift21(carry12);
4279 carry14 = (s14 + (1 << 20)) >> 21; 4290 carry14 = (s14 + (1 << 20)) >> 21;
4280 s15 += carry14; 4291 s15 += carry14;
4281 s14 -= carry14 << 21; 4292 s14 -= int64_lshift21(carry14);
4282 carry16 = (s16 + (1 << 20)) >> 21; 4293 carry16 = (s16 + (1 << 20)) >> 21;
4283 s17 += carry16; 4294 s17 += carry16;
4284 s16 -= carry16 << 21; 4295 s16 -= int64_lshift21(carry16);
4285 carry18 = (s18 + (1 << 20)) >> 21; 4296 carry18 = (s18 + (1 << 20)) >> 21;
4286 s19 += carry18; 4297 s19 += carry18;
4287 s18 -= carry18 << 21; 4298 s18 -= int64_lshift21(carry18);
4288 carry20 = (s20 + (1 << 20)) >> 21; 4299 carry20 = (s20 + (1 << 20)) >> 21;
4289 s21 += carry20; 4300 s21 += carry20;
4290 s20 -= carry20 << 21; 4301 s20 -= int64_lshift21(carry20);
4291 carry22 = (s22 + (1 << 20)) >> 21; 4302 carry22 = (s22 + (1 << 20)) >> 21;
4292 s23 += carry22; 4303 s23 += carry22;
4293 s22 -= carry22 << 21; 4304 s22 -= int64_lshift21(carry22);
4294 4305
4295 carry1 = (s1 + (1 << 20)) >> 21; 4306 carry1 = (s1 + (1 << 20)) >> 21;
4296 s2 += carry1; 4307 s2 += carry1;
4297 s1 -= carry1 << 21; 4308 s1 -= int64_lshift21(carry1);
4298 carry3 = (s3 + (1 << 20)) >> 21; 4309 carry3 = (s3 + (1 << 20)) >> 21;
4299 s4 += carry3; 4310 s4 += carry3;
4300 s3 -= carry3 << 21; 4311 s3 -= int64_lshift21(carry3);
4301 carry5 = (s5 + (1 << 20)) >> 21; 4312 carry5 = (s5 + (1 << 20)) >> 21;
4302 s6 += carry5; 4313 s6 += carry5;
4303 s5 -= carry5 << 21; 4314 s5 -= int64_lshift21(carry5);
4304 carry7 = (s7 + (1 << 20)) >> 21; 4315 carry7 = (s7 + (1 << 20)) >> 21;
4305 s8 += carry7; 4316 s8 += carry7;
4306 s7 -= carry7 << 21; 4317 s7 -= int64_lshift21(carry7);
4307 carry9 = (s9 + (1 << 20)) >> 21; 4318 carry9 = (s9 + (1 << 20)) >> 21;
4308 s10 += carry9; 4319 s10 += carry9;
4309 s9 -= carry9 << 21; 4320 s9 -= int64_lshift21(carry9);
4310 carry11 = (s11 + (1 << 20)) >> 21; 4321 carry11 = (s11 + (1 << 20)) >> 21;
4311 s12 += carry11; 4322 s12 += carry11;
4312 s11 -= carry11 << 21; 4323 s11 -= int64_lshift21(carry11);
4313 carry13 = (s13 + (1 << 20)) >> 21; 4324 carry13 = (s13 + (1 << 20)) >> 21;
4314 s14 += carry13; 4325 s14 += carry13;
4315 s13 -= carry13 << 21; 4326 s13 -= int64_lshift21(carry13);
4316 carry15 = (s15 + (1 << 20)) >> 21; 4327 carry15 = (s15 + (1 << 20)) >> 21;
4317 s16 += carry15; 4328 s16 += carry15;
4318 s15 -= carry15 << 21; 4329 s15 -= int64_lshift21(carry15);
4319 carry17 = (s17 + (1 << 20)) >> 21; 4330 carry17 = (s17 + (1 << 20)) >> 21;
4320 s18 += carry17; 4331 s18 += carry17;
4321 s17 -= carry17 << 21; 4332 s17 -= int64_lshift21(carry17);
4322 carry19 = (s19 + (1 << 20)) >> 21; 4333 carry19 = (s19 + (1 << 20)) >> 21;
4323 s20 += carry19; 4334 s20 += carry19;
4324 s19 -= carry19 << 21; 4335 s19 -= int64_lshift21(carry19);
4325 carry21 = (s21 + (1 << 20)) >> 21; 4336 carry21 = (s21 + (1 << 20)) >> 21;
4326 s22 += carry21; 4337 s22 += carry21;
4327 s21 -= carry21 << 21; 4338 s21 -= int64_lshift21(carry21);
4328 4339
4329 s11 += s23 * 666643; 4340 s11 += s23 * 666643;
4330 s12 += s23 * 470296; 4341 s12 += s23 * 470296;
@@ -4376,38 +4387,38 @@ sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b,
4376 4387
4377 carry6 = (s6 + (1 << 20)) >> 21; 4388 carry6 = (s6 + (1 << 20)) >> 21;
4378 s7 += carry6; 4389 s7 += carry6;
4379 s6 -= carry6 << 21; 4390 s6 -= int64_lshift21(carry6);
4380 carry8 = (s8 + (1 << 20)) >> 21; 4391 carry8 = (s8 + (1 << 20)) >> 21;
4381 s9 += carry8; 4392 s9 += carry8;
4382 s8 -= carry8 << 21; 4393 s8 -= int64_lshift21(carry8);
4383 carry10 = (s10 + (1 << 20)) >> 21; 4394 carry10 = (s10 + (1 << 20)) >> 21;
4384 s11 += carry10; 4395 s11 += carry10;
4385 s10 -= carry10 << 21; 4396 s10 -= int64_lshift21(carry10);
4386 carry12 = (s12 + (1 << 20)) >> 21; 4397 carry12 = (s12 + (1 << 20)) >> 21;
4387 s13 += carry12; 4398 s13 += carry12;
4388 s12 -= carry12 << 21; 4399 s12 -= int64_lshift21(carry12);
4389 carry14 = (s14 + (1 << 20)) >> 21; 4400 carry14 = (s14 + (1 << 20)) >> 21;
4390 s15 += carry14; 4401 s15 += carry14;
4391 s14 -= carry14 << 21; 4402 s14 -= int64_lshift21(carry14);
4392 carry16 = (s16 + (1 << 20)) >> 21; 4403 carry16 = (s16 + (1 << 20)) >> 21;
4393 s17 += carry16; 4404 s17 += carry16;
4394 s16 -= carry16 << 21; 4405 s16 -= int64_lshift21(carry16);
4395 4406
4396 carry7 = (s7 + (1 << 20)) >> 21; 4407 carry7 = (s7 + (1 << 20)) >> 21;
4397 s8 += carry7; 4408 s8 += carry7;
4398 s7 -= carry7 << 21; 4409 s7 -= int64_lshift21(carry7);
4399 carry9 = (s9 + (1 << 20)) >> 21; 4410 carry9 = (s9 + (1 << 20)) >> 21;
4400 s10 += carry9; 4411 s10 += carry9;
4401 s9 -= carry9 << 21; 4412 s9 -= int64_lshift21(carry9);
4402 carry11 = (s11 + (1 << 20)) >> 21; 4413 carry11 = (s11 + (1 << 20)) >> 21;
4403 s12 += carry11; 4414 s12 += carry11;
4404 s11 -= carry11 << 21; 4415 s11 -= int64_lshift21(carry11);
4405 carry13 = (s13 + (1 << 20)) >> 21; 4416 carry13 = (s13 + (1 << 20)) >> 21;
4406 s14 += carry13; 4417 s14 += carry13;
4407 s13 -= carry13 << 21; 4418 s13 -= int64_lshift21(carry13);
4408 carry15 = (s15 + (1 << 20)) >> 21; 4419 carry15 = (s15 + (1 << 20)) >> 21;
4409 s16 += carry15; 4420 s16 += carry15;
4410 s15 -= carry15 << 21; 4421 s15 -= int64_lshift21(carry15);
4411 4422
4412 s5 += s17 * 666643; 4423 s5 += s17 * 666643;
4413 s6 += s17 * 470296; 4424 s6 += s17 * 470296;
@@ -4459,41 +4470,41 @@ sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b,
4459 4470
4460 carry0 = (s0 + (1 << 20)) >> 21; 4471 carry0 = (s0 + (1 << 20)) >> 21;
4461 s1 += carry0; 4472 s1 += carry0;
4462 s0 -= carry0 << 21; 4473 s0 -= int64_lshift21(carry0);
4463 carry2 = (s2 + (1 << 20)) >> 21; 4474 carry2 = (s2 + (1 << 20)) >> 21;
4464 s3 += carry2; 4475 s3 += carry2;
4465 s2 -= carry2 << 21; 4476 s2 -= int64_lshift21(carry2);
4466 carry4 = (s4 + (1 << 20)) >> 21; 4477 carry4 = (s4 + (1 << 20)) >> 21;
4467 s5 += carry4; 4478 s5 += carry4;
4468 s4 -= carry4 << 21; 4479 s4 -= int64_lshift21(carry4);
4469 carry6 = (s6 + (1 << 20)) >> 21; 4480 carry6 = (s6 + (1 << 20)) >> 21;
4470 s7 += carry6; 4481 s7 += carry6;
4471 s6 -= carry6 << 21; 4482 s6 -= int64_lshift21(carry6);
4472 carry8 = (s8 + (1 << 20)) >> 21; 4483 carry8 = (s8 + (1 << 20)) >> 21;
4473 s9 += carry8; 4484 s9 += carry8;
4474 s8 -= carry8 << 21; 4485 s8 -= int64_lshift21(carry8);
4475 carry10 = (s10 + (1 << 20)) >> 21; 4486 carry10 = (s10 + (1 << 20)) >> 21;
4476 s11 += carry10; 4487 s11 += carry10;
4477 s10 -= carry10 << 21; 4488 s10 -= int64_lshift21(carry10);
4478 4489
4479 carry1 = (s1 + (1 << 20)) >> 21; 4490 carry1 = (s1 + (1 << 20)) >> 21;
4480 s2 += carry1; 4491 s2 += carry1;
4481 s1 -= carry1 << 21; 4492 s1 -= int64_lshift21(carry1);
4482 carry3 = (s3 + (1 << 20)) >> 21; 4493 carry3 = (s3 + (1 << 20)) >> 21;
4483 s4 += carry3; 4494 s4 += carry3;
4484 s3 -= carry3 << 21; 4495 s3 -= int64_lshift21(carry3);
4485 carry5 = (s5 + (1 << 20)) >> 21; 4496 carry5 = (s5 + (1 << 20)) >> 21;
4486 s6 += carry5; 4497 s6 += carry5;
4487 s5 -= carry5 << 21; 4498 s5 -= int64_lshift21(carry5);
4488 carry7 = (s7 + (1 << 20)) >> 21; 4499 carry7 = (s7 + (1 << 20)) >> 21;
4489 s8 += carry7; 4500 s8 += carry7;
4490 s7 -= carry7 << 21; 4501 s7 -= int64_lshift21(carry7);
4491 carry9 = (s9 + (1 << 20)) >> 21; 4502 carry9 = (s9 + (1 << 20)) >> 21;
4492 s10 += carry9; 4503 s10 += carry9;
4493 s9 -= carry9 << 21; 4504 s9 -= int64_lshift21(carry9);
4494 carry11 = (s11 + (1 << 20)) >> 21; 4505 carry11 = (s11 + (1 << 20)) >> 21;
4495 s12 += carry11; 4506 s12 += carry11;
4496 s11 -= carry11 << 21; 4507 s11 -= int64_lshift21(carry11);
4497 4508
4498 s0 += s12 * 666643; 4509 s0 += s12 * 666643;
4499 s1 += s12 * 470296; 4510 s1 += s12 * 470296;
@@ -4505,40 +4516,40 @@ sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b,
4505 4516
4506 carry0 = s0 >> 21; 4517 carry0 = s0 >> 21;
4507 s1 += carry0; 4518 s1 += carry0;
4508 s0 -= carry0 << 21; 4519 s0 -= int64_lshift21(carry0);
4509 carry1 = s1 >> 21; 4520 carry1 = s1 >> 21;
4510 s2 += carry1; 4521 s2 += carry1;
4511 s1 -= carry1 << 21; 4522 s1 -= int64_lshift21(carry1);
4512 carry2 = s2 >> 21; 4523 carry2 = s2 >> 21;
4513 s3 += carry2; 4524 s3 += carry2;
4514 s2 -= carry2 << 21; 4525 s2 -= int64_lshift21(carry2);
4515 carry3 = s3 >> 21; 4526 carry3 = s3 >> 21;
4516 s4 += carry3; 4527 s4 += carry3;
4517 s3 -= carry3 << 21; 4528 s3 -= int64_lshift21(carry3);
4518 carry4 = s4 >> 21; 4529 carry4 = s4 >> 21;
4519 s5 += carry4; 4530 s5 += carry4;
4520 s4 -= carry4 << 21; 4531 s4 -= int64_lshift21(carry4);
4521 carry5 = s5 >> 21; 4532 carry5 = s5 >> 21;
4522 s6 += carry5; 4533 s6 += carry5;
4523 s5 -= carry5 << 21; 4534 s5 -= int64_lshift21(carry5);
4524 carry6 = s6 >> 21; 4535 carry6 = s6 >> 21;
4525 s7 += carry6; 4536 s7 += carry6;
4526 s6 -= carry6 << 21; 4537 s6 -= int64_lshift21(carry6);
4527 carry7 = s7 >> 21; 4538 carry7 = s7 >> 21;
4528 s8 += carry7; 4539 s8 += carry7;
4529 s7 -= carry7 << 21; 4540 s7 -= int64_lshift21(carry7);
4530 carry8 = s8 >> 21; 4541 carry8 = s8 >> 21;
4531 s9 += carry8; 4542 s9 += carry8;
4532 s8 -= carry8 << 21; 4543 s8 -= int64_lshift21(carry8);
4533 carry9 = s9 >> 21; 4544 carry9 = s9 >> 21;
4534 s10 += carry9; 4545 s10 += carry9;
4535 s9 -= carry9 << 21; 4546 s9 -= int64_lshift21(carry9);
4536 carry10 = s10 >> 21; 4547 carry10 = s10 >> 21;
4537 s11 += carry10; 4548 s11 += carry10;
4538 s10 -= carry10 << 21; 4549 s10 -= int64_lshift21(carry10);
4539 carry11 = s11 >> 21; 4550 carry11 = s11 >> 21;
4540 s12 += carry11; 4551 s12 += carry11;
4541 s11 -= carry11 << 21; 4552 s11 -= int64_lshift21(carry11);
4542 4553
4543 s0 += s12 * 666643; 4554 s0 += s12 * 666643;
4544 s1 += s12 * 470296; 4555 s1 += s12 * 470296;
@@ -4550,37 +4561,37 @@ sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b,
4550 4561
4551 carry0 = s0 >> 21; 4562 carry0 = s0 >> 21;
4552 s1 += carry0; 4563 s1 += carry0;
4553 s0 -= carry0 << 21; 4564 s0 -= int64_lshift21(carry0);
4554 carry1 = s1 >> 21; 4565 carry1 = s1 >> 21;
4555 s2 += carry1; 4566 s2 += carry1;
4556 s1 -= carry1 << 21; 4567 s1 -= int64_lshift21(carry1);
4557 carry2 = s2 >> 21; 4568 carry2 = s2 >> 21;
4558 s3 += carry2; 4569 s3 += carry2;
4559 s2 -= carry2 << 21; 4570 s2 -= int64_lshift21(carry2);
4560 carry3 = s3 >> 21; 4571 carry3 = s3 >> 21;
4561 s4 += carry3; 4572 s4 += carry3;
4562 s3 -= carry3 << 21; 4573 s3 -= int64_lshift21(carry3);
4563 carry4 = s4 >> 21; 4574 carry4 = s4 >> 21;
4564 s5 += carry4; 4575 s5 += carry4;
4565 s4 -= carry4 << 21; 4576 s4 -= int64_lshift21(carry4);
4566 carry5 = s5 >> 21; 4577 carry5 = s5 >> 21;
4567 s6 += carry5; 4578 s6 += carry5;
4568 s5 -= carry5 << 21; 4579 s5 -= int64_lshift21(carry5);
4569 carry6 = s6 >> 21; 4580 carry6 = s6 >> 21;
4570 s7 += carry6; 4581 s7 += carry6;
4571 s6 -= carry6 << 21; 4582 s6 -= int64_lshift21(carry6);
4572 carry7 = s7 >> 21; 4583 carry7 = s7 >> 21;
4573 s8 += carry7; 4584 s8 += carry7;
4574 s7 -= carry7 << 21; 4585 s7 -= int64_lshift21(carry7);
4575 carry8 = s8 >> 21; 4586 carry8 = s8 >> 21;
4576 s9 += carry8; 4587 s9 += carry8;
4577 s8 -= carry8 << 21; 4588 s8 -= int64_lshift21(carry8);
4578 carry9 = s9 >> 21; 4589 carry9 = s9 >> 21;
4579 s10 += carry9; 4590 s10 += carry9;
4580 s9 -= carry9 << 21; 4591 s9 -= int64_lshift21(carry9);
4581 carry10 = s10 >> 21; 4592 carry10 = s10 >> 21;
4582 s11 += carry10; 4593 s11 += carry10;
4583 s10 -= carry10 << 21; 4594 s10 -= int64_lshift21(carry10);
4584 4595
4585 s[0] = s0 >> 0; 4596 s[0] = s0 >> 0;
4586 s[1] = s0 >> 8; 4597 s[1] = s0 >> 8;
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
index 2d957a192c..ad7a418c01 100644
--- a/src/lib/libcrypto/des/des.h
+++ b/src/lib/libcrypto/des/des.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: des.h,v 1.23 2025/01/25 17:59:44 tb Exp $ */ 1/* $OpenBSD: des.h,v 1.26 2025/06/09 17:49:45 tb Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,11 +56,20 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef HEADER_NEW_DES_H 59#ifndef HEADER_DES_H
60#define HEADER_NEW_DES_H 60#define HEADER_DES_H
61 61
62#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63 63
64#ifndef DES_LONG
65/* XXX - typedef to unsigned int everywhere. */
66#ifdef __i386__
67#define DES_LONG unsigned long
68#else
69#define DES_LONG unsigned int
70#endif
71#endif
72
64#ifdef __cplusplus 73#ifdef __cplusplus
65extern "C" { 74extern "C" {
66#endif 75#endif
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index deec50bffb..cb89784fb0 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: des_enc.c,v 1.20 2024/08/31 16:17:13 jsing Exp $ */ 1/* $OpenBSD: des_enc.c,v 1.21 2025/07/27 13:26:24 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -210,10 +210,8 @@ void
210DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) 210DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
211{ 211{
212 DES_LONG l, r, t, u; 212 DES_LONG l, r, t, u;
213#ifndef DES_UNROLL
214 int i;
215#endif
216 DES_LONG *s; 213 DES_LONG *s;
214 int i;
217 215
218 r = data[0]; 216 r = data[0];
219 l = data[1]; 217 l = data[1];
@@ -231,56 +229,21 @@ DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
231 l = ROTATE(l, 29) & 0xffffffffL; 229 l = ROTATE(l, 29) & 0xffffffffL;
232 230
233 s = ks->ks->deslong; 231 s = ks->ks->deslong;
234 /* I don't know if it is worth the effort of loop unrolling the 232
235 * inner loop */
236 if (enc) { 233 if (enc) {
237#ifdef DES_UNROLL 234 for (i = 0; i < 32; i += 8) {
238 D_ENCRYPT(l, r, 0); /* 1 */ 235 D_ENCRYPT(l, r, i + 0);
239 D_ENCRYPT(r, l, 2); /* 2 */ 236 D_ENCRYPT(r, l, i + 2);
240 D_ENCRYPT(l, r, 4); /* 3 */ 237 D_ENCRYPT(l, r, i + 4);
241 D_ENCRYPT(r, l, 6); /* 4 */ 238 D_ENCRYPT(r, l, i + 6);
242 D_ENCRYPT(l, r, 8); /* 5 */
243 D_ENCRYPT(r, l, 10); /* 6 */
244 D_ENCRYPT(l, r, 12); /* 7 */
245 D_ENCRYPT(r, l, 14); /* 8 */
246 D_ENCRYPT(l, r, 16); /* 9 */
247 D_ENCRYPT(r, l, 18); /* 10 */
248 D_ENCRYPT(l, r, 20); /* 11 */
249 D_ENCRYPT(r, l, 22); /* 12 */
250 D_ENCRYPT(l, r, 24); /* 13 */
251 D_ENCRYPT(r, l, 26); /* 14 */
252 D_ENCRYPT(l, r, 28); /* 15 */
253 D_ENCRYPT(r, l, 30); /* 16 */
254#else
255 for (i = 0; i < 32; i += 4) {
256 D_ENCRYPT(l, r, i + 0); /* 1 */
257 D_ENCRYPT(r, l, i + 2); /* 2 */
258 } 239 }
259#endif
260 } else { 240 } else {
261#ifdef DES_UNROLL 241 for (i = 32; i > 0; i -= 8) {
262 D_ENCRYPT(l, r, 30); /* 16 */ 242 D_ENCRYPT(l, r, i - 2);
263 D_ENCRYPT(r, l, 28); /* 15 */ 243 D_ENCRYPT(r, l, i - 4);
264 D_ENCRYPT(l, r, 26); /* 14 */ 244 D_ENCRYPT(l, r, i - 6);
265 D_ENCRYPT(r, l, 24); /* 13 */ 245 D_ENCRYPT(r, l, i - 8);
266 D_ENCRYPT(l, r, 22); /* 12 */
267 D_ENCRYPT(r, l, 20); /* 11 */
268 D_ENCRYPT(l, r, 18); /* 10 */
269 D_ENCRYPT(r, l, 16); /* 9 */
270 D_ENCRYPT(l, r, 14); /* 8 */
271 D_ENCRYPT(r, l, 12); /* 7 */
272 D_ENCRYPT(l, r, 10); /* 6 */
273 D_ENCRYPT(r, l, 8); /* 5 */
274 D_ENCRYPT(l, r, 6); /* 4 */
275 D_ENCRYPT(r, l, 4); /* 3 */
276 D_ENCRYPT(l, r, 2); /* 2 */
277 D_ENCRYPT(r, l, 0); /* 1 */
278#else
279 for (i = 30; i > 0; i -= 4) {
280 D_ENCRYPT(l, r, i - 0); /* 16 */
281 D_ENCRYPT(r, l, i - 2); /* 15 */
282 } 246 }
283#endif
284 } 247 }
285 248
286 /* rotate and clear the top bits on machines with 8byte longs */ 249 /* rotate and clear the top bits on machines with 8byte longs */
@@ -298,10 +261,8 @@ void
298DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) 261DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
299{ 262{
300 DES_LONG l, r, t, u; 263 DES_LONG l, r, t, u;
301#ifndef DES_UNROLL
302 int i;
303#endif
304 DES_LONG *s; 264 DES_LONG *s;
265 int i;
305 266
306 r = data[0]; 267 r = data[0];
307 l = data[1]; 268 l = data[1];
@@ -320,53 +281,19 @@ DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
320 /* I don't know if it is worth the effort of loop unrolling the 281 /* I don't know if it is worth the effort of loop unrolling the
321 * inner loop */ 282 * inner loop */
322 if (enc) { 283 if (enc) {
323#ifdef DES_UNROLL 284 for (i = 0; i < 32; i += 8) {
324 D_ENCRYPT(l, r, 0); /* 1 */ 285 D_ENCRYPT(l, r, i + 0);
325 D_ENCRYPT(r, l, 2); /* 2 */ 286 D_ENCRYPT(r, l, i + 2);
326 D_ENCRYPT(l, r, 4); /* 3 */ 287 D_ENCRYPT(l, r, i + 4);
327 D_ENCRYPT(r, l, 6); /* 4 */ 288 D_ENCRYPT(r, l, i + 6);
328 D_ENCRYPT(l, r, 8); /* 5 */
329 D_ENCRYPT(r, l, 10); /* 6 */
330 D_ENCRYPT(l, r, 12); /* 7 */
331 D_ENCRYPT(r, l, 14); /* 8 */
332 D_ENCRYPT(l, r, 16); /* 9 */
333 D_ENCRYPT(r, l, 18); /* 10 */
334 D_ENCRYPT(l, r, 20); /* 11 */
335 D_ENCRYPT(r, l, 22); /* 12 */
336 D_ENCRYPT(l, r, 24); /* 13 */
337 D_ENCRYPT(r, l, 26); /* 14 */
338 D_ENCRYPT(l, r, 28); /* 15 */
339 D_ENCRYPT(r, l, 30); /* 16 */
340#else
341 for (i = 0; i < 32; i += 4) {
342 D_ENCRYPT(l, r, i + 0); /* 1 */
343 D_ENCRYPT(r, l, i + 2); /* 2 */
344 } 289 }
345#endif
346 } else { 290 } else {
347#ifdef DES_UNROLL 291 for (i = 32; i > 0; i -= 8) {
348 D_ENCRYPT(l, r, 30); /* 16 */ 292 D_ENCRYPT(l, r, i - 2);
349 D_ENCRYPT(r, l, 28); /* 15 */ 293 D_ENCRYPT(r, l, i - 4);
350 D_ENCRYPT(l, r, 26); /* 14 */ 294 D_ENCRYPT(l, r, i - 6);
351 D_ENCRYPT(r, l, 24); /* 13 */ 295 D_ENCRYPT(r, l, i - 8);
352 D_ENCRYPT(l, r, 22); /* 12 */
353 D_ENCRYPT(r, l, 20); /* 11 */
354 D_ENCRYPT(l, r, 18); /* 10 */
355 D_ENCRYPT(r, l, 16); /* 9 */
356 D_ENCRYPT(l, r, 14); /* 8 */
357 D_ENCRYPT(r, l, 12); /* 7 */
358 D_ENCRYPT(l, r, 10); /* 6 */
359 D_ENCRYPT(r, l, 8); /* 5 */
360 D_ENCRYPT(l, r, 6); /* 4 */
361 D_ENCRYPT(r, l, 4); /* 3 */
362 D_ENCRYPT(l, r, 2); /* 2 */
363 D_ENCRYPT(r, l, 0); /* 1 */
364#else
365 for (i = 30; i > 0; i -= 4) {
366 D_ENCRYPT(l, r, i - 0); /* 16 */
367 D_ENCRYPT(r, l, i - 2); /* 15 */
368 } 296 }
369#endif
370 } 297 }
371 /* rotate and clear the top bits on machines with 8byte longs */ 298 /* rotate and clear the top bits on machines with 8byte longs */
372 data[0] = ROTATE(l, 3) & 0xffffffffL; 299 data[0] = ROTATE(l, 3) & 0xffffffffL;
diff --git a/src/lib/libcrypto/des/des_fcrypt.c b/src/lib/libcrypto/des/des_fcrypt.c
index b33b1240c2..2dd071f5d0 100644
--- a/src/lib/libcrypto/des/des_fcrypt.c
+++ b/src/lib/libcrypto/des/des_fcrypt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: des_fcrypt.c,v 1.4 2024/08/31 16:22:18 jsing Exp $ */ 1/* $OpenBSD: des_fcrypt.c,v 1.5 2025/07/27 13:26:24 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -90,8 +90,8 @@ fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
90{ 90{
91 DES_LONG l, r, t, u; 91 DES_LONG l, r, t, u;
92 DES_LONG *s; 92 DES_LONG *s;
93 int j;
94 DES_LONG E0, E1; 93 DES_LONG E0, E1;
94 int i, j;
95 95
96 l = 0; 96 l = 0;
97 r = 0; 97 r = 0;
@@ -101,32 +101,12 @@ fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
101 E1 = Eswap1; 101 E1 = Eswap1;
102 102
103 for (j = 0; j < 25; j++) { 103 for (j = 0; j < 25; j++) {
104#ifndef DES_UNROLL 104 for (i = 0; i < 32; i += 8) {
105 int i; 105 D_ENCRYPT(l, r, i + 0);
106 106 D_ENCRYPT(r, l, i + 2);
107 for (i = 0; i < 32; i += 4) { 107 D_ENCRYPT(l, r, i + 4);
108 D_ENCRYPT(l, r, i + 0); /* 1 */ 108 D_ENCRYPT(r, l, i + 6);
109 D_ENCRYPT(r, l, i + 2); /* 2 */
110 } 109 }
111#else
112 D_ENCRYPT(l, r, 0); /* 1 */
113 D_ENCRYPT(r, l, 2); /* 2 */
114 D_ENCRYPT(l, r, 4); /* 3 */
115 D_ENCRYPT(r, l, 6); /* 4 */
116 D_ENCRYPT(l, r, 8); /* 5 */
117 D_ENCRYPT(r, l, 10); /* 6 */
118 D_ENCRYPT(l, r, 12); /* 7 */
119 D_ENCRYPT(r, l, 14); /* 8 */
120 D_ENCRYPT(l, r, 16); /* 9 */
121 D_ENCRYPT(r, l, 18); /* 10 */
122 D_ENCRYPT(l, r, 20); /* 11 */
123 D_ENCRYPT(r, l, 22); /* 12 */
124 D_ENCRYPT(l, r, 24); /* 13 */
125 D_ENCRYPT(r, l, 26); /* 14 */
126 D_ENCRYPT(l, r, 28); /* 15 */
127 D_ENCRYPT(r, l, 30); /* 16 */
128#endif
129
130 t = l; 110 t = l;
131 l = r; 111 l = r;
132 r = t; 112 r = t;
diff --git a/src/lib/libcrypto/dh/dh_ameth.c b/src/lib/libcrypto/dh/dh_ameth.c
index 289307bfd6..ec59245b9c 100644
--- a/src/lib/libcrypto/dh/dh_ameth.c
+++ b/src/lib/libcrypto/dh/dh_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_ameth.c,v 1.42 2025/01/17 05:04:25 tb Exp $ */ 1/* $OpenBSD: dh_ameth.c,v 1.43 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -61,12 +61,12 @@
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64#include <openssl/err.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
67#include "asn1_local.h" 66#include "asn1_local.h"
68#include "bn_local.h" 67#include "bn_local.h"
69#include "dh_local.h" 68#include "dh_local.h"
69#include "err_local.h"
70#include "evp_local.h" 70#include "evp_local.h"
71 71
72static void 72static void
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c
index a880f9fca1..1ba85bc824 100644
--- a/src/lib/libcrypto/dh/dh_check.c
+++ b/src/lib/libcrypto/dh/dh_check.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_check.c,v 1.30 2024/11/29 15:59:57 tb Exp $ */ 1/* $OpenBSD: dh_check.c,v 1.31 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,7 +60,6 @@
60 60
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63#include <openssl/err.h>
64 63
65#include "bn_local.h" 64#include "bn_local.h"
66#include "dh_local.h" 65#include "dh_local.h"
diff --git a/src/lib/libcrypto/dh/dh_gen.c b/src/lib/libcrypto/dh/dh_gen.c
index 3ffa5d80f1..f28f75909c 100644
--- a/src/lib/libcrypto/dh/dh_gen.c
+++ b/src/lib/libcrypto/dh/dh_gen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_gen.c,v 1.21 2023/07/08 15:29:03 beck Exp $ */ 1/* $OpenBSD: dh_gen.c,v 1.22 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,10 +60,10 @@
60 60
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63#include <openssl/err.h>
64 63
65#include "bn_local.h" 64#include "bn_local.h"
66#include "dh_local.h" 65#include "dh_local.h"
66#include "err_local.h"
67 67
68static int dh_builtin_genparams(DH *ret, int prime_len, int generator, 68static int dh_builtin_genparams(DH *ret, int prime_len, int generator,
69 BN_GENCB *cb); 69 BN_GENCB *cb);
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index 93b04f398f..89a02c8309 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_key.c,v 1.42 2024/05/09 20:43:36 tb Exp $ */ 1/* $OpenBSD: dh_key.c,v 1.43 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,10 +60,10 @@
60 60
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63#include <openssl/err.h>
64 63
65#include "bn_local.h" 64#include "bn_local.h"
66#include "dh_local.h" 65#include "dh_local.h"
66#include "err_local.h"
67 67
68static int 68static int
69generate_key(DH *dh) 69generate_key(DH *dh)
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 803aca6421..db76244550 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_lib.c,v 1.46 2024/11/29 15:59:57 tb Exp $ */ 1/* $OpenBSD: dh_lib.c,v 1.47 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,9 +63,9 @@
63 63
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/dh.h> 65#include <openssl/dh.h>
66#include <openssl/err.h>
67 66
68#include "dh_local.h" 67#include "dh_local.h"
68#include "err_local.h"
69 69
70static const DH_METHOD *default_DH_method = NULL; 70static const DH_METHOD *default_DH_method = NULL;
71 71
diff --git a/src/lib/libcrypto/dh/dh_pmeth.c b/src/lib/libcrypto/dh/dh_pmeth.c
index 1e5327b11f..18517b0cde 100644
--- a/src/lib/libcrypto/dh/dh_pmeth.c
+++ b/src/lib/libcrypto/dh/dh_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_pmeth.c,v 1.17 2024/08/26 22:00:47 op Exp $ */ 1/* $OpenBSD: dh_pmeth.c,v 1.18 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -64,12 +64,12 @@
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/bn.h> 65#include <openssl/bn.h>
66#include <openssl/dh.h> 66#include <openssl/dh.h>
67#include <openssl/err.h>
68#include <openssl/evp.h> 67#include <openssl/evp.h>
69#include <openssl/x509.h> 68#include <openssl/x509.h>
70 69
71#include "bn_local.h" 70#include "bn_local.h"
72#include "dh_local.h" 71#include "dh_local.h"
72#include "err_local.h"
73#include "evp_local.h" 73#include "evp_local.h"
74 74
75/* DH pkey context structure */ 75/* DH pkey context structure */
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c
index 866e5ec476..8e65cf68f7 100644
--- a/src/lib/libcrypto/dsa/dsa_ameth.c
+++ b/src/lib/libcrypto/dsa/dsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ameth.c,v 1.59 2024/04/13 14:02:51 tb Exp $ */ 1/* $OpenBSD: dsa_ameth.c,v 1.60 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -64,12 +64,12 @@
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/cms.h> 65#include <openssl/cms.h>
66#include <openssl/dsa.h> 66#include <openssl/dsa.h>
67#include <openssl/err.h>
68#include <openssl/x509.h> 67#include <openssl/x509.h>
69 68
70#include "asn1_local.h" 69#include "asn1_local.h"
71#include "bn_local.h" 70#include "bn_local.h"
72#include "dsa_local.h" 71#include "dsa_local.h"
72#include "err_local.h"
73#include "evp_local.h" 73#include "evp_local.h"
74#include "x509_local.h" 74#include "x509_local.h"
75 75
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c
index de6ec46195..e8957a99ff 100644
--- a/src/lib/libcrypto/dsa/dsa_asn1.c
+++ b/src/lib/libcrypto/dsa/dsa_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_asn1.c,v 1.33 2024/07/08 17:11:05 beck Exp $ */ 1/* $OpenBSD: dsa_asn1.c,v 1.34 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -63,9 +63,9 @@
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/dsa.h> 65#include <openssl/dsa.h>
66#include <openssl/err.h>
67 66
68#include "dsa_local.h" 67#include "dsa_local.h"
68#include "err_local.h"
69 69
70/* Override the default new methods */ 70/* Override the default new methods */
71static int 71static int
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index daf2fa135b..ecd517cf8a 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_lib.c,v 1.48 2024/03/27 01:49:31 tb Exp $ */ 1/* $OpenBSD: dsa_lib.c,v 1.49 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -65,7 +65,6 @@
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#include <openssl/bn.h> 66#include <openssl/bn.h>
67#include <openssl/dsa.h> 67#include <openssl/dsa.h>
68#include <openssl/err.h>
69 68
70#ifndef OPENSSL_NO_DH 69#ifndef OPENSSL_NO_DH
71#include <openssl/dh.h> 70#include <openssl/dh.h>
@@ -73,6 +72,7 @@
73 72
74#include "dh_local.h" 73#include "dh_local.h"
75#include "dsa_local.h" 74#include "dsa_local.h"
75#include "err_local.h"
76 76
77static const DSA_METHOD *default_DSA_method = NULL; 77static const DSA_METHOD *default_DSA_method = NULL;
78 78
diff --git a/src/lib/libcrypto/dsa/dsa_meth.c b/src/lib/libcrypto/dsa/dsa_meth.c
index c84b5287e1..c961bb13b4 100644
--- a/src/lib/libcrypto/dsa/dsa_meth.c
+++ b/src/lib/libcrypto/dsa/dsa_meth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_meth.c,v 1.7 2023/07/08 14:28:15 beck Exp $ */ 1/* $OpenBSD: dsa_meth.c,v 1.8 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -19,9 +19,9 @@
19#include <string.h> 19#include <string.h>
20 20
21#include <openssl/dsa.h> 21#include <openssl/dsa.h>
22#include <openssl/err.h>
23 22
24#include "dsa_local.h" 23#include "dsa_local.h"
24#include "err_local.h"
25 25
26DSA_METHOD * 26DSA_METHOD *
27DSA_meth_new(const char *name, int flags) 27DSA_meth_new(const char *name, int flags)
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index c53c8b9001..6d1546f4fc 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ossl.c,v 1.56 2024/05/11 06:43:50 tb Exp $ */ 1/* $OpenBSD: dsa_ossl.c,v 1.57 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,11 +63,11 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64#include <openssl/bn.h> 64#include <openssl/bn.h>
65#include <openssl/dsa.h> 65#include <openssl/dsa.h>
66#include <openssl/err.h>
67#include <openssl/sha.h> 66#include <openssl/sha.h>
68 67
69#include "bn_local.h" 68#include "bn_local.h"
70#include "dsa_local.h" 69#include "dsa_local.h"
70#include "err_local.h"
71 71
72/* 72/*
73 * Since DSA parameters are entirely arbitrary and checking them to be 73 * Since DSA parameters are entirely arbitrary and checking them to be
diff --git a/src/lib/libcrypto/dsa/dsa_pmeth.c b/src/lib/libcrypto/dsa/dsa_pmeth.c
index adc7319731..73889a8307 100644
--- a/src/lib/libcrypto/dsa/dsa_pmeth.c
+++ b/src/lib/libcrypto/dsa/dsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_pmeth.c,v 1.21 2024/10/19 14:39:44 tb Exp $ */ 1/* $OpenBSD: dsa_pmeth.c,v 1.22 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -63,12 +63,12 @@
63 63
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/bn.h> 65#include <openssl/bn.h>
66#include <openssl/err.h>
67#include <openssl/evp.h> 66#include <openssl/evp.h>
68#include <openssl/x509.h> 67#include <openssl/x509.h>
69 68
70#include "bn_local.h" 69#include "bn_local.h"
71#include "dsa_local.h" 70#include "dsa_local.h"
71#include "err_local.h"
72#include "evp_local.h" 72#include "evp_local.h"
73 73
74/* DSA pkey context structure */ 74/* DSA pkey context structure */
diff --git a/src/lib/libcrypto/dsa/dsa_prn.c b/src/lib/libcrypto/dsa/dsa_prn.c
index f276d82482..058b7d9ffd 100644
--- a/src/lib/libcrypto/dsa/dsa_prn.c
+++ b/src/lib/libcrypto/dsa/dsa_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_prn.c,v 1.10 2023/07/08 14:28:15 beck Exp $ */ 1/* $OpenBSD: dsa_prn.c,v 1.11 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -59,9 +59,10 @@
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/dsa.h> 61#include <openssl/dsa.h>
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64 63
64#include "err_local.h"
65
65int 66int
66DSA_print_fp(FILE *fp, const DSA *x, int off) 67DSA_print_fp(FILE *fp, const DSA *x, int off)
67{ 68{
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c
index 903b18a8db..ddc8adea1e 100644
--- a/src/lib/libcrypto/ec/ec_ameth.c
+++ b/src/lib/libcrypto/ec/ec_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_ameth.c,v 1.73 2024/11/25 06:51:39 tb Exp $ */ 1/* $OpenBSD: ec_ameth.c,v 1.74 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -66,7 +66,6 @@
66#include <openssl/bn.h> 66#include <openssl/bn.h>
67#include <openssl/cms.h> 67#include <openssl/cms.h>
68#include <openssl/ec.h> 68#include <openssl/ec.h>
69#include <openssl/err.h>
70#include <openssl/evp.h> 69#include <openssl/evp.h>
71#include <openssl/pkcs7.h> 70#include <openssl/pkcs7.h>
72#include <openssl/objects.h> 71#include <openssl/objects.h>
@@ -74,6 +73,7 @@
74 73
75#include "asn1_local.h" 74#include "asn1_local.h"
76#include "bn_local.h" 75#include "bn_local.h"
76#include "err_local.h"
77#include "evp_local.h" 77#include "evp_local.h"
78#include "x509_local.h" 78#include "x509_local.h"
79 79
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c
index ef318f8d43..35f4f5b0ba 100644
--- a/src/lib/libcrypto/ec/ec_asn1.c
+++ b/src/lib/libcrypto/ec/ec_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_asn1.c,v 1.111 2025/03/13 10:31:12 tb Exp $ */ 1/* $OpenBSD: ec_asn1.c,v 1.112 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -66,12 +66,12 @@
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/bn.h> 67#include <openssl/bn.h>
68#include <openssl/ec.h> 68#include <openssl/ec.h>
69#include <openssl/err.h>
70#include <openssl/asn1t.h> 69#include <openssl/asn1t.h>
71#include <openssl/objects.h> 70#include <openssl/objects.h>
72 71
73#include "asn1_local.h" 72#include "asn1_local.h"
74#include "ec_local.h" 73#include "ec_local.h"
74#include "err_local.h"
75 75
76int 76int
77EC_GROUP_get_basis_type(const EC_GROUP *group) 77EC_GROUP_get_basis_type(const EC_GROUP *group)
diff --git a/src/lib/libcrypto/ec/ec_convert.c b/src/lib/libcrypto/ec/ec_convert.c
index a18bc49132..84641a4e72 100644
--- a/src/lib/libcrypto/ec/ec_convert.c
+++ b/src/lib/libcrypto/ec/ec_convert.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_convert.c,v 1.14 2025/01/05 16:07:08 tb Exp $ */ 1/* $OpenBSD: ec_convert.c,v 1.15 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -64,10 +64,10 @@
64#include <string.h> 64#include <string.h>
65 65
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/err.h>
68 67
69#include "asn1_local.h" 68#include "asn1_local.h"
70#include "ec_local.h" 69#include "ec_local.h"
70#include "err_local.h"
71 71
72/* 72/*
73 * Internal handling of the point conversion octet 73 * Internal handling of the point conversion octet
diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c
index a3ec2de7fb..2cfb219b50 100644
--- a/src/lib/libcrypto/ec/ec_curve.c
+++ b/src/lib/libcrypto/ec/ec_curve.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_curve.c,v 1.54 2025/03/09 17:53:11 tb Exp $ */ 1/* $OpenBSD: ec_curve.c,v 1.58 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -78,10 +78,10 @@
78 78
79#include <openssl/bn.h> 79#include <openssl/bn.h>
80#include <openssl/ec.h> 80#include <openssl/ec.h>
81#include <openssl/err.h>
82#include <openssl/objects.h> 81#include <openssl/objects.h>
83 82
84#include "ec_local.h" 83#include "ec_local.h"
84#include "err_local.h"
85 85
86static const struct { 86static const struct {
87 uint8_t seed[20]; 87 uint8_t seed[20];
@@ -130,6 +130,57 @@ static const struct {
130 130
131static const struct { 131static const struct {
132 uint8_t seed[20]; 132 uint8_t seed[20];
133 uint8_t p[32];
134 uint8_t a[32];
135 uint8_t b[32];
136 uint8_t x[32];
137 uint8_t y[32];
138 uint8_t order[32];
139} _EC_NIST_PRIME_256 = {
140 .seed = {
141 0xc4, 0x9d, 0x36, 0x08, 0x86, 0xe7, 0x04, 0x93, 0x6a, 0x66,
142 0x78, 0xe1, 0x13, 0x9d, 0x26, 0xb7, 0x81, 0x9f, 0x7e, 0x90,
143 },
144 .p = {
145 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
148 0xff, 0xff,
149 },
150 .a = {
151 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
154 0xff, 0xfc,
155 },
156 .b = {
157 0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, 0xb3, 0xeb,
158 0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc, 0x65, 0x1d, 0x06, 0xb0,
159 0xcc, 0x53, 0xb0, 0xf6, 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2,
160 0x60, 0x4b,
161 },
162 .x = {
163 0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, 0xf8, 0xbc,
164 0xe6, 0xe5, 0x63, 0xa4, 0x40, 0xf2, 0x77, 0x03, 0x7d, 0x81,
165 0x2d, 0xeb, 0x33, 0xa0, 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98,
166 0xc2, 0x96,
167 },
168 .y = {
169 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7,
170 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, 0x57,
171 0x6b, 0x31, 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf,
172 0x51, 0xf5,
173 },
174 .order = {
175 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
176 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad,
177 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63,
178 0x25, 0x51,
179 },
180};
181
182static const struct {
183 uint8_t seed[20];
133 uint8_t p[48]; 184 uint8_t p[48];
134 uint8_t a[48]; 185 uint8_t a[48];
135 uint8_t b[48]; 186 uint8_t b[48];
@@ -255,192 +306,6 @@ static const struct {
255}; 306};
256 307
257static const struct { 308static const struct {
258 uint8_t seed[20];
259 uint8_t p[30];
260 uint8_t a[30];
261 uint8_t b[30];
262 uint8_t x[30];
263 uint8_t y[30];
264 uint8_t order[30];
265} _EC_X9_62_PRIME_239V1 = {
266 .seed = {
267 0xe4, 0x3b, 0xb4, 0x60, 0xf0, 0xb8, 0x0c, 0xc0, 0xc0, 0xb0,
268 0x75, 0x79, 0x8e, 0x94, 0x80, 0x60, 0xf8, 0x32, 0x1b, 0x7d,
269 },
270 .p = {
271 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
272 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
273 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
274 },
275 .a = {
276 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
277 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
278 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfc,
279 },
280 .b = {
281 0x6b, 0x01, 0x6c, 0x3b, 0xdc, 0xf1, 0x89, 0x41, 0xd0, 0xd6,
282 0x54, 0x92, 0x14, 0x75, 0xca, 0x71, 0xa9, 0xdb, 0x2f, 0xb2,
283 0x7d, 0x1d, 0x37, 0x79, 0x61, 0x85, 0xc2, 0x94, 0x2c, 0x0a,
284 },
285 .x = {
286 0x0f, 0xfa, 0x96, 0x3c, 0xdc, 0xa8, 0x81, 0x6c, 0xcc, 0x33,
287 0xb8, 0x64, 0x2b, 0xed, 0xf9, 0x05, 0xc3, 0xd3, 0x58, 0x57,
288 0x3d, 0x3f, 0x27, 0xfb, 0xbd, 0x3b, 0x3c, 0xb9, 0xaa, 0xaf,
289 },
290 .y = {
291 0x7d, 0xeb, 0xe8, 0xe4, 0xe9, 0x0a, 0x5d, 0xae, 0x6e, 0x40,
292 0x54, 0xca, 0x53, 0x0b, 0xa0, 0x46, 0x54, 0xb3, 0x68, 0x18,
293 0xce, 0x22, 0x6b, 0x39, 0xfc, 0xcb, 0x7b, 0x02, 0xf1, 0xae,
294 },
295 .order = {
296 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
297 0xff, 0xff, 0x7f, 0xff, 0xff, 0x9e, 0x5e, 0x9a, 0x9f, 0x5d,
298 0x90, 0x71, 0xfb, 0xd1, 0x52, 0x26, 0x88, 0x90, 0x9d, 0x0b,
299 },
300};
301
302static const struct {
303 uint8_t seed[20];
304 uint8_t p[30];
305 uint8_t a[30];
306 uint8_t b[30];
307 uint8_t x[30];
308 uint8_t y[30];
309 uint8_t order[30];
310} _EC_X9_62_PRIME_239V2 = {
311 .seed = {
312 0xe8, 0xb4, 0x01, 0x16, 0x04, 0x09, 0x53, 0x03, 0xca, 0x3b,
313 0x80, 0x99, 0x98, 0x2b, 0xe0, 0x9f, 0xcb, 0x9a, 0xe6, 0x16,
314 },
315 .p = {
316 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
317 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
318 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
319 },
320 .a = {
321 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
322 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
323 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfc,
324 },
325 .b = {
326 0x61, 0x7f, 0xab, 0x68, 0x32, 0x57, 0x6c, 0xbb, 0xfe, 0xd5,
327 0x0d, 0x99, 0xf0, 0x24, 0x9c, 0x3f, 0xee, 0x58, 0xb9, 0x4b,
328 0xa0, 0x03, 0x8c, 0x7a, 0xe8, 0x4c, 0x8c, 0x83, 0x2f, 0x2c,
329 },
330 .x = {
331 0x38, 0xaf, 0x09, 0xd9, 0x87, 0x27, 0x70, 0x51, 0x20, 0xc9,
332 0x21, 0xbb, 0x5e, 0x9e, 0x26, 0x29, 0x6a, 0x3c, 0xdc, 0xf2,
333 0xf3, 0x57, 0x57, 0xa0, 0xea, 0xfd, 0x87, 0xb8, 0x30, 0xe7,
334 },
335 .y = {
336 0x5b, 0x01, 0x25, 0xe4, 0xdb, 0xea, 0x0e, 0xc7, 0x20, 0x6d,
337 0xa0, 0xfc, 0x01, 0xd9, 0xb0, 0x81, 0x32, 0x9f, 0xb5, 0x55,
338 0xde, 0x6e, 0xf4, 0x60, 0x23, 0x7d, 0xff, 0x8b, 0xe4, 0xba,
339 },
340 .order = {
341 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
342 0xff, 0xff, 0x80, 0x00, 0x00, 0xcf, 0xa7, 0xe8, 0x59, 0x43,
343 0x77, 0xd4, 0x14, 0xc0, 0x38, 0x21, 0xbc, 0x58, 0x20, 0x63,
344 },
345};
346
347static const struct {
348 uint8_t seed[20];
349 uint8_t p[30];
350 uint8_t a[30];
351 uint8_t b[30];
352 uint8_t x[30];
353 uint8_t y[30];
354 uint8_t order[30];
355} _EC_X9_62_PRIME_239V3 = {
356 .seed = {
357 0x7d, 0x73, 0x74, 0x16, 0x8f, 0xfe, 0x34, 0x71, 0xb6, 0x0a,
358 0x85, 0x76, 0x86, 0xa1, 0x94, 0x75, 0xd3, 0xbf, 0xa2, 0xff,
359 },
360 .p = {
361 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
362 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
363 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
364 },
365 .a = {
366 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
367 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
368 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfc,
369 },
370 .b = {
371 0x25, 0x57, 0x05, 0xfa, 0x2a, 0x30, 0x66, 0x54, 0xb1, 0xf4,
372 0xcb, 0x03, 0xd6, 0xa7, 0x50, 0xa3, 0x0c, 0x25, 0x01, 0x02,
373 0xd4, 0x98, 0x87, 0x17, 0xd9, 0xba, 0x15, 0xab, 0x6d, 0x3e,
374 },
375 .x = {
376 0x67, 0x68, 0xae, 0x8e, 0x18, 0xbb, 0x92, 0xcf, 0xcf, 0x00,
377 0x5c, 0x94, 0x9a, 0xa2, 0xc6, 0xd9, 0x48, 0x53, 0xd0, 0xe6,
378 0x60, 0xbb, 0xf8, 0x54, 0xb1, 0xc9, 0x50, 0x5f, 0xe9, 0x5a,
379 },
380 .y = {
381 0x16, 0x07, 0xe6, 0x89, 0x8f, 0x39, 0x0c, 0x06, 0xbc, 0x1d,
382 0x55, 0x2b, 0xad, 0x22, 0x6f, 0x3b, 0x6f, 0xcf, 0xe4, 0x8b,
383 0x6e, 0x81, 0x84, 0x99, 0xaf, 0x18, 0xe3, 0xed, 0x6c, 0xf3,
384 },
385 .order = {
386 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
387 0xff, 0xff, 0x7f, 0xff, 0xff, 0x97, 0x5d, 0xeb, 0x41, 0xb3,
388 0xa6, 0x05, 0x7c, 0x3c, 0x43, 0x21, 0x46, 0x52, 0x65, 0x51,
389 },
390};
391
392static const struct {
393 uint8_t seed[20];
394 uint8_t p[32];
395 uint8_t a[32];
396 uint8_t b[32];
397 uint8_t x[32];
398 uint8_t y[32];
399 uint8_t order[32];
400} _EC_X9_62_PRIME_256V1 = {
401 .seed = {
402 0xc4, 0x9d, 0x36, 0x08, 0x86, 0xe7, 0x04, 0x93, 0x6a, 0x66,
403 0x78, 0xe1, 0x13, 0x9d, 0x26, 0xb7, 0x81, 0x9f, 0x7e, 0x90,
404 },
405 .p = {
406 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
409 0xff, 0xff,
410 },
411 .a = {
412 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
414 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
415 0xff, 0xfc,
416 },
417 .b = {
418 0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, 0xb3, 0xeb,
419 0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc, 0x65, 0x1d, 0x06, 0xb0,
420 0xcc, 0x53, 0xb0, 0xf6, 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2,
421 0x60, 0x4b,
422 },
423 .x = {
424 0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, 0xf8, 0xbc,
425 0xe6, 0xe5, 0x63, 0xa4, 0x40, 0xf2, 0x77, 0x03, 0x7d, 0x81,
426 0x2d, 0xeb, 0x33, 0xa0, 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98,
427 0xc2, 0x96,
428 },
429 .y = {
430 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7,
431 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, 0x57,
432 0x6b, 0x31, 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf,
433 0x51, 0xf5,
434 },
435 .order = {
436 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
437 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad,
438 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63,
439 0x25, 0x51,
440 },
441};
442
443static const struct {
444 uint8_t p[29]; 309 uint8_t p[29];
445 uint8_t a[29]; 310 uint8_t a[29];
446 uint8_t b[29]; 311 uint8_t b[29];
@@ -1121,7 +986,21 @@ static const struct ec_curve {
1121 .order = _EC_SECG_PRIME_256K1.order, 986 .order = _EC_SECG_PRIME_256K1.order,
1122 .cofactor = 1, 987 .cofactor = 1,
1123 }, 988 },
1124 /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ 989 {
990 /* Everyone except OpenSSL calls this secp256r1 or P-256. */
991 .comment = "X9.62/SECG curve prime256v1",
992 .nid = NID_X9_62_prime256v1,
993 .seed_len = sizeof(_EC_NIST_PRIME_256.seed),
994 .param_len = sizeof(_EC_NIST_PRIME_256.p),
995 .seed = _EC_NIST_PRIME_256.seed,
996 .p = _EC_NIST_PRIME_256.p,
997 .a = _EC_NIST_PRIME_256.a,
998 .b = _EC_NIST_PRIME_256.b,
999 .x = _EC_NIST_PRIME_256.x,
1000 .y = _EC_NIST_PRIME_256.y,
1001 .order = _EC_NIST_PRIME_256.order,
1002 .cofactor = 1,
1003 },
1125 { 1004 {
1126 .comment = "NIST/SECG curve secp384r1", 1005 .comment = "NIST/SECG curve secp384r1",
1127 .nid = NID_secp384r1, 1006 .nid = NID_secp384r1,
@@ -1150,63 +1029,6 @@ static const struct ec_curve {
1150 .order = _EC_NIST_PRIME_521.order, 1029 .order = _EC_NIST_PRIME_521.order,
1151 .cofactor = 1, 1030 .cofactor = 1,
1152 }, 1031 },
1153 /* X9.62 curves */
1154 {
1155 .comment = "X9.62 curve prime239v1",
1156 .nid = NID_X9_62_prime239v1,
1157 .seed_len = sizeof(_EC_X9_62_PRIME_239V1.seed),
1158 .param_len = sizeof(_EC_X9_62_PRIME_239V1.p),
1159 .seed = _EC_X9_62_PRIME_239V1.seed,
1160 .p = _EC_X9_62_PRIME_239V1.p,
1161 .a = _EC_X9_62_PRIME_239V1.a,
1162 .b = _EC_X9_62_PRIME_239V1.b,
1163 .x = _EC_X9_62_PRIME_239V1.x,
1164 .y = _EC_X9_62_PRIME_239V1.y,
1165 .order = _EC_X9_62_PRIME_239V1.order,
1166 .cofactor = 1,
1167 },
1168 {
1169 .comment = "X9.62 curve prime239v2",
1170 .nid = NID_X9_62_prime239v2,
1171 .seed_len = sizeof(_EC_X9_62_PRIME_239V2.seed),
1172 .param_len = sizeof(_EC_X9_62_PRIME_239V2.p),
1173 .seed = _EC_X9_62_PRIME_239V2.seed,
1174 .p = _EC_X9_62_PRIME_239V2.p,
1175 .a = _EC_X9_62_PRIME_239V2.a,
1176 .b = _EC_X9_62_PRIME_239V2.b,
1177 .x = _EC_X9_62_PRIME_239V2.x,
1178 .y = _EC_X9_62_PRIME_239V2.y,
1179 .order = _EC_X9_62_PRIME_239V2.order,
1180 .cofactor = 1,
1181 },
1182 {
1183 .comment = "X9.62 curve prime239v3",
1184 .nid = NID_X9_62_prime239v3,
1185 .seed_len = sizeof(_EC_X9_62_PRIME_239V3.seed),
1186 .param_len = sizeof(_EC_X9_62_PRIME_239V3.p),
1187 .seed = _EC_X9_62_PRIME_239V3.seed,
1188 .p = _EC_X9_62_PRIME_239V3.p,
1189 .a = _EC_X9_62_PRIME_239V3.a,
1190 .b = _EC_X9_62_PRIME_239V3.b,
1191 .x = _EC_X9_62_PRIME_239V3.x,
1192 .y = _EC_X9_62_PRIME_239V3.y,
1193 .order = _EC_X9_62_PRIME_239V3.order,
1194 .cofactor = 1,
1195 },
1196 {
1197 .comment = "X9.62/SECG curve prime256v1",
1198 .nid = NID_X9_62_prime256v1,
1199 .seed_len = sizeof(_EC_X9_62_PRIME_256V1.seed),
1200 .param_len = sizeof(_EC_X9_62_PRIME_256V1.p),
1201 .seed = _EC_X9_62_PRIME_256V1.seed,
1202 .p = _EC_X9_62_PRIME_256V1.p,
1203 .a = _EC_X9_62_PRIME_256V1.a,
1204 .b = _EC_X9_62_PRIME_256V1.b,
1205 .x = _EC_X9_62_PRIME_256V1.x,
1206 .y = _EC_X9_62_PRIME_256V1.y,
1207 .order = _EC_X9_62_PRIME_256V1.order,
1208 .cofactor = 1,
1209 },
1210 /* RFC 5639 curves */ 1032 /* RFC 5639 curves */
1211 { 1033 {
1212 .comment = "RFC 5639 curve brainpoolP224r1", 1034 .comment = "RFC 5639 curve brainpoolP224r1",
@@ -1221,7 +1043,7 @@ static const struct ec_curve {
1221 .cofactor = 1, 1043 .cofactor = 1,
1222 }, 1044 },
1223 { 1045 {
1224 .comment = "RFC 5639 curve brainpoolP224r2", 1046 .comment = "RFC 5639 curve brainpoolP224t1",
1225 .nid = NID_brainpoolP224t1, 1047 .nid = NID_brainpoolP224t1,
1226 .param_len = sizeof(_EC_brainpoolP224t1.p), 1048 .param_len = sizeof(_EC_brainpoolP224t1.p),
1227 .p = _EC_brainpoolP224t1.p, 1049 .p = _EC_brainpoolP224t1.p,
diff --git a/src/lib/libcrypto/ec/ec_field.c b/src/lib/libcrypto/ec/ec_field.c
new file mode 100644
index 0000000000..6576526e77
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec_field.c
@@ -0,0 +1,202 @@
1/* $OpenBSD: ec_field.c,v 1.3 2025/08/02 16:20:00 jsing Exp $ */
2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <string.h>
19
20#include <openssl/ec.h>
21
22#include "bn_local.h"
23#include "bn_internal.h"
24#include "ec_local.h"
25#include "ec_internal.h"
26
27int
28ec_field_modulus_from_bn(EC_FIELD_MODULUS *fm, const BIGNUM *bn, BN_CTX *ctx)
29{
30 BN_MONT_CTX *mctx = NULL;
31 size_t i;
32 int ret = 0;
33
34 if (BN_is_negative(bn))
35 goto err;
36 if (BN_num_bits(bn) > EC_FIELD_ELEMENT_MAX_BITS)
37 goto err;
38
39 memset(fm, 0, sizeof(*fm));
40
41 fm->n = (BN_num_bits(bn) + BN_BITS2 - 1) / BN_BITS2;
42
43 for (i = 0; i < bn->top; i++)
44 fm->m.w[i] = bn->d[i];
45
46 /* XXX - implement this without BN_MONT_CTX. */
47 if ((mctx = BN_MONT_CTX_new()) == NULL)
48 goto err;
49 if (!BN_MONT_CTX_set(mctx, bn, ctx))
50 goto err;
51
52 for (i = 0; i < mctx->RR.top; i++)
53 fm->rr.w[i] = mctx->RR.d[i];
54
55 fm->minv0 = mctx->n0[0];
56
57 ret = 1;
58
59 err:
60 BN_MONT_CTX_free(mctx);
61
62 return ret;
63}
64
65int
66ec_field_element_from_bn(const EC_FIELD_MODULUS *fm, const EC_GROUP *group,
67 EC_FIELD_ELEMENT *fe, const BIGNUM *bn, BN_CTX *ctx)
68{
69 BN_ULONG t[EC_FIELD_ELEMENT_MAX_WORDS * 2 + 2];
70 BIGNUM *tmp;
71 size_t i;
72 int ret = 0;
73
74 BN_CTX_start(ctx);
75
76 if ((tmp = BN_CTX_get(ctx)) == NULL)
77 goto err;
78
79 /* XXX - enforce 0 <= n < p. */
80
81 if (BN_num_bits(bn) > EC_FIELD_ELEMENT_MAX_BITS)
82 goto err;
83
84 /* XXX - do this without BN. */
85 if (!BN_nnmod(tmp, bn, group->p, ctx))
86 goto err;
87
88 if (BN_num_bits(tmp) > EC_FIELD_ELEMENT_MAX_BITS)
89 abort();
90
91 memset(fe->w, 0, sizeof(fe->w));
92
93 for (i = 0; i < tmp->top; i++)
94 fe->w[i] = tmp->d[i];
95
96 bn_mod_mul_words(fe->w, fe->w, fm->rr.w, fm->m.w, t, fm->minv0, fm->n);
97
98 ret = 1;
99
100 err:
101 BN_CTX_end(ctx);
102
103 return ret;
104}
105
106int
107ec_field_element_to_bn(const EC_FIELD_MODULUS *fm, const EC_FIELD_ELEMENT *fe,
108 BIGNUM *bn, BN_CTX *ctx)
109{
110 BN_ULONG t[EC_FIELD_ELEMENT_MAX_WORDS * 2 + 2];
111 size_t i;
112
113 if (!bn_wexpand(bn, fm->n))
114 return 0;
115
116 memset(t, 0, sizeof(t));
117 for (i = 0; i < fm->n; i++)
118 t[i] = fe->w[i];
119
120 bn_montgomery_reduce_words(bn->d, t, fm->m.w, fm->minv0, fm->n);
121
122 bn->top = fm->n;
123 bn_correct_top(bn);
124
125 return 1;
126}
127
128void
129ec_field_element_copy(EC_FIELD_ELEMENT *dst, const EC_FIELD_ELEMENT *src)
130{
131 memcpy(dst, src, sizeof(EC_FIELD_ELEMENT));
132}
133
134void
135ec_field_element_select(const EC_FIELD_MODULUS *fm, EC_FIELD_ELEMENT *r,
136 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b, int conditional)
137{
138 BN_ULONG mask;
139 int i;
140
141 mask = bn_ct_eq_zero_mask(conditional);
142
143 for (i = 0; i < fm->n; i++)
144 r->w[i] = (a->w[i] & mask) | (b->w[i] & ~mask);
145}
146
147int
148ec_field_element_equal(const EC_FIELD_MODULUS *fm, const EC_FIELD_ELEMENT *a,
149 const EC_FIELD_ELEMENT *b)
150{
151 BN_ULONG v = 0;
152 int i;
153
154 for (i = 0; i < fm->n; i++)
155 v |= a->w[i] ^ b->w[i];
156
157 return bn_ct_eq_zero(v);
158}
159
160int
161ec_field_element_is_zero(const EC_FIELD_MODULUS *fm, const EC_FIELD_ELEMENT *fe)
162{
163 BN_ULONG v = 0;
164 int i;
165
166 for (i = 0; i < fm->n; i++)
167 v |= fe->w[i];
168
169 return bn_ct_eq_zero(v);
170}
171
172void
173ec_field_element_add(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
174 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b)
175{
176 bn_mod_add_words(r->w, a->w, b->w, m->m.w, m->n);
177}
178
179void
180ec_field_element_sub(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
181 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b)
182{
183 bn_mod_sub_words(r->w, a->w, b->w, m->m.w, m->n);
184}
185
186void
187ec_field_element_mul(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
188 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b)
189{
190 BN_ULONG t[EC_FIELD_ELEMENT_MAX_WORDS * 2 + 2];
191
192 bn_mod_mul_words(r->w, a->w, b->w, m->m.w, t, m->minv0, m->n);
193}
194
195void
196ec_field_element_sqr(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
197 const EC_FIELD_ELEMENT *a)
198{
199 BN_ULONG t[EC_FIELD_ELEMENT_MAX_WORDS * 2 + 2];
200
201 bn_mod_sqr_words(r->w, a->w, m->m.w, t, m->minv0, m->n);
202}
diff --git a/src/lib/libcrypto/ec/ec_internal.h b/src/lib/libcrypto/ec/ec_internal.h
new file mode 100644
index 0000000000..327d9ea94d
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec_internal.h
@@ -0,0 +1,65 @@
1/* $OpenBSD: ec_internal.h,v 1.2 2025/08/02 15:44:09 jsing Exp $ */
2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <openssl/bn.h>
19
20#ifndef HEADER_EC_INTERNAL_H
21#define HEADER_EC_INTERNAL_H
22
23#define EC_FIELD_ELEMENT_MAX_BITS 521
24#define EC_FIELD_ELEMENT_MAX_BYTES \
25 (EC_FIELD_ELEMENT_MAX_BITS + 7) / 8
26#define EC_FIELD_ELEMENT_MAX_WORDS \
27 ((EC_FIELD_ELEMENT_MAX_BYTES + BN_BYTES - 1) / BN_BYTES)
28
29typedef struct {
30 BN_ULONG w[EC_FIELD_ELEMENT_MAX_WORDS];
31} EC_FIELD_ELEMENT;
32
33typedef struct {
34 size_t n;
35 EC_FIELD_ELEMENT m;
36 EC_FIELD_ELEMENT rr;
37 BN_ULONG minv0;
38} EC_FIELD_MODULUS;
39
40int ec_field_modulus_from_bn(EC_FIELD_MODULUS *fm, const BIGNUM *bn,
41 BN_CTX *ctx);
42
43int ec_field_element_from_bn(const EC_FIELD_MODULUS *fm, const EC_GROUP *group,
44 EC_FIELD_ELEMENT *fe, const BIGNUM *bn, BN_CTX *ctx);
45int ec_field_element_to_bn(const EC_FIELD_MODULUS *fm, const EC_FIELD_ELEMENT *fe,
46 BIGNUM *bn, BN_CTX *ctx);
47
48void ec_field_element_copy(EC_FIELD_ELEMENT *dst, const EC_FIELD_ELEMENT *src);
49void ec_field_element_select(const EC_FIELD_MODULUS *fm, EC_FIELD_ELEMENT *r,
50 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b, int conditional);
51
52int ec_field_element_equal(const EC_FIELD_MODULUS *fm, const EC_FIELD_ELEMENT *a,
53 const EC_FIELD_ELEMENT *b);
54int ec_field_element_is_zero(const EC_FIELD_MODULUS *fm, const EC_FIELD_ELEMENT *fe);
55
56void ec_field_element_add(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
57 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b);
58void ec_field_element_sub(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
59 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b);
60void ec_field_element_mul(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
61 const EC_FIELD_ELEMENT *a, const EC_FIELD_ELEMENT *b);
62void ec_field_element_sqr(const EC_FIELD_MODULUS *m, EC_FIELD_ELEMENT *r,
63 const EC_FIELD_ELEMENT *a);
64
65#endif
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c
index 6257d67cd1..e9777019c8 100644
--- a/src/lib/libcrypto/ec/ec_key.c
+++ b/src/lib/libcrypto/ec/ec_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_key.c,v 1.51 2025/01/25 10:34:36 tb Exp $ */ 1/* $OpenBSD: ec_key.c,v 1.52 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -66,11 +66,11 @@
66#include <openssl/opensslconf.h> 66#include <openssl/opensslconf.h>
67 67
68#include <openssl/ec.h> 68#include <openssl/ec.h>
69#include <openssl/err.h>
70 69
71#include "bn_local.h" 70#include "bn_local.h"
72#include "ec_local.h" 71#include "ec_local.h"
73#include "ecdsa_local.h" 72#include "ecdsa_local.h"
73#include "err_local.h"
74 74
75EC_KEY * 75EC_KEY *
76EC_KEY_new(void) 76EC_KEY_new(void)
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index 7982d23f06..36f42ecc05 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_lib.c,v 1.123 2025/03/24 13:07:04 jsing Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.126 2025/08/02 15:47:27 jsing Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -68,12 +68,12 @@
68 68
69#include <openssl/bn.h> 69#include <openssl/bn.h>
70#include <openssl/ec.h> 70#include <openssl/ec.h>
71#include <openssl/err.h>
72#include <openssl/objects.h> 71#include <openssl/objects.h>
73#include <openssl/opensslv.h> 72#include <openssl/opensslv.h>
74 73
75#include "bn_local.h" 74#include "bn_local.h"
76#include "ec_local.h" 75#include "ec_local.h"
76#include "err_local.h"
77 77
78EC_GROUP * 78EC_GROUP *
79EC_GROUP_new(const EC_METHOD *meth) 79EC_GROUP_new(const EC_METHOD *meth)
@@ -165,6 +165,10 @@ EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src)
165 165
166 dst->a_is_minus3 = src->a_is_minus3; 166 dst->a_is_minus3 = src->a_is_minus3;
167 167
168 memcpy(&dst->fm, &src->fm, sizeof(src->fm));
169 memcpy(&dst->fe_a, &src->fe_a, sizeof(src->fe_a));
170 memcpy(&dst->fe_b, &src->fe_b, sizeof(src->fe_b));
171
168 BN_MONT_CTX_free(dst->mont_ctx); 172 BN_MONT_CTX_free(dst->mont_ctx);
169 dst->mont_ctx = NULL; 173 dst->mont_ctx = NULL;
170 if (src->mont_ctx != NULL) { 174 if (src->mont_ctx != NULL) {
@@ -860,6 +864,10 @@ EC_POINT_copy(EC_POINT *dst, const EC_POINT *src)
860 return 0; 864 return 0;
861 dst->Z_is_one = src->Z_is_one; 865 dst->Z_is_one = src->Z_is_one;
862 866
867 memcpy(&dst->fe_x, &src->fe_x, sizeof(dst->fe_x));
868 memcpy(&dst->fe_y, &src->fe_y, sizeof(dst->fe_y));
869 memcpy(&dst->fe_z, &src->fe_z, sizeof(dst->fe_z));
870
863 return 1; 871 return 1;
864} 872}
865LCRYPTO_ALIAS(EC_POINT_copy); 873LCRYPTO_ALIAS(EC_POINT_copy);
@@ -894,11 +902,7 @@ EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
894 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 902 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
895 return 0; 903 return 0;
896 } 904 }
897 905 return point->meth->point_set_to_infinity(group, point);
898 BN_zero(point->Z);
899 point->Z_is_one = 0;
900
901 return 1;
902} 906}
903LCRYPTO_ALIAS(EC_POINT_set_to_infinity); 907LCRYPTO_ALIAS(EC_POINT_set_to_infinity);
904 908
@@ -1200,8 +1204,7 @@ EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
1200 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 1204 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
1201 return 0; 1205 return 0;
1202 } 1206 }
1203 1207 return point->meth->point_is_at_infinity(group, point);
1204 return BN_is_zero(point->Z);
1205} 1208}
1206LCRYPTO_ALIAS(EC_POINT_is_at_infinity); 1209LCRYPTO_ALIAS(EC_POINT_is_at_infinity);
1207 1210
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h
index c7a54d3a2b..eac9e6d26c 100644
--- a/src/lib/libcrypto/ec/ec_local.h
+++ b/src/lib/libcrypto/ec/ec_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_local.h,v 1.67 2025/03/24 13:07:04 jsing Exp $ */ 1/* $OpenBSD: ec_local.h,v 1.70 2025/08/03 15:07:57 jsing Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -76,6 +76,7 @@
76#include <openssl/objects.h> 76#include <openssl/objects.h>
77 77
78#include "bn_local.h" 78#include "bn_local.h"
79#include "ec_internal.h"
79 80
80__BEGIN_HIDDEN_DECLS 81__BEGIN_HIDDEN_DECLS
81 82
@@ -85,6 +86,9 @@ typedef struct ec_method_st {
85 int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, 86 int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
86 BIGNUM *b, BN_CTX *); 87 BIGNUM *b, BN_CTX *);
87 88
89 int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *);
90 int (*point_is_at_infinity)(const EC_GROUP *, const EC_POINT *);
91
88 int (*point_is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *); 92 int (*point_is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *);
89 int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, 93 int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,
90 BN_CTX *); 94 BN_CTX *);
@@ -155,6 +159,10 @@ struct ec_group_st {
155 159
156 /* Montgomery context used by EC_GFp_mont_method. */ 160 /* Montgomery context used by EC_GFp_mont_method. */
157 BN_MONT_CTX *mont_ctx; 161 BN_MONT_CTX *mont_ctx;
162
163 EC_FIELD_MODULUS fm;
164 EC_FIELD_ELEMENT fe_a;
165 EC_FIELD_ELEMENT fe_b;
158} /* EC_GROUP */; 166} /* EC_GROUP */;
159 167
160struct ec_point_st { 168struct ec_point_st {
@@ -168,10 +176,15 @@ struct ec_point_st {
168 BIGNUM *Y; 176 BIGNUM *Y;
169 BIGNUM *Z; 177 BIGNUM *Z;
170 int Z_is_one; /* enable optimized point arithmetics for special case */ 178 int Z_is_one; /* enable optimized point arithmetics for special case */
179
180 EC_FIELD_ELEMENT fe_x;
181 EC_FIELD_ELEMENT fe_y;
182 EC_FIELD_ELEMENT fe_z;
171} /* EC_POINT */; 183} /* EC_POINT */;
172 184
173const EC_METHOD *EC_GFp_simple_method(void); 185const EC_METHOD *EC_GFp_simple_method(void);
174const EC_METHOD *EC_GFp_mont_method(void); 186const EC_METHOD *EC_GFp_mont_method(void);
187const EC_METHOD *EC_GFp_homogeneous_projective_method(void);
175 188
176/* Compute r = scalar1 * point1 + scalar2 * point2 in non-constant time. */ 189/* Compute r = scalar1 * point1 + scalar2 * point2 in non-constant time. */
177int ec_wnaf_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar1, 190int ec_wnaf_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar1,
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c
index 673696a9fd..d74c89cfe2 100644
--- a/src/lib/libcrypto/ec/ec_mult.c
+++ b/src/lib/libcrypto/ec/ec_mult.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_mult.c,v 1.58 2025/03/24 13:07:04 jsing Exp $ */ 1/* $OpenBSD: ec_mult.c,v 1.59 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. 3 * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -67,9 +67,9 @@
67 67
68#include <openssl/bn.h> 68#include <openssl/bn.h>
69#include <openssl/ec.h> 69#include <openssl/ec.h>
70#include <openssl/err.h>
71 70
72#include "ec_local.h" 71#include "ec_local.h"
72#include "err_local.h"
73 73
74/* Holds the wNAF digits of bn and the corresponding odd multiples of point. */ 74/* Holds the wNAF digits of bn and the corresponding odd multiples of point. */
75struct ec_wnaf { 75struct ec_wnaf {
diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c
index 85ac4822d1..69bf7e741a 100644
--- a/src/lib/libcrypto/ec/ec_pmeth.c
+++ b/src/lib/libcrypto/ec/ec_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_pmeth.c,v 1.26 2025/03/13 10:39:51 tb Exp $ */ 1/* $OpenBSD: ec_pmeth.c,v 1.27 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -62,12 +62,12 @@
62 62
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/ec.h> 64#include <openssl/ec.h>
65#include <openssl/err.h>
66#include <openssl/evp.h> 65#include <openssl/evp.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68 67
69#include "bn_local.h" 68#include "bn_local.h"
70#include "ec_local.h" 69#include "ec_local.h"
70#include "err_local.h"
71#include "evp_local.h" 71#include "evp_local.h"
72 72
73/* EC pkey context structure */ 73/* EC pkey context structure */
diff --git a/src/lib/libcrypto/ec/eck_prn.c b/src/lib/libcrypto/ec/eck_prn.c
index c40a64966a..ed5fdce9c1 100644
--- a/src/lib/libcrypto/ec/eck_prn.c
+++ b/src/lib/libcrypto/ec/eck_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eck_prn.c,v 1.41 2025/01/25 10:30:17 tb Exp $ */ 1/* $OpenBSD: eck_prn.c,v 1.42 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -66,12 +66,12 @@
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/bn.h> 67#include <openssl/bn.h>
68#include <openssl/ec.h> 68#include <openssl/ec.h>
69#include <openssl/err.h>
70#include <openssl/evp.h> 69#include <openssl/evp.h>
71#include <openssl/objects.h> 70#include <openssl/objects.h>
72 71
73#include "bn_local.h" 72#include "bn_local.h"
74#include "ec_local.h" 73#include "ec_local.h"
74#include "err_local.h"
75 75
76int 76int
77EC_KEY_print(BIO *bio, const EC_KEY *ec_key, int off) 77EC_KEY_print(BIO *bio, const EC_KEY *ec_key, int off)
diff --git a/src/lib/libcrypto/ec/ecp_hp_methods.c b/src/lib/libcrypto/ec/ecp_hp_methods.c
new file mode 100644
index 0000000000..0b34a55b9d
--- /dev/null
+++ b/src/lib/libcrypto/ec/ecp_hp_methods.c
@@ -0,0 +1,943 @@
1/* $OpenBSD: ecp_hp_methods.c,v 1.5 2025/08/03 15:44:00 jsing Exp $ */
2/*
3 * Copyright (c) 2024-2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <string.h>
19
20#include <openssl/bn.h>
21#include <openssl/ec.h>
22#include <openssl/err.h>
23
24#include "bn_internal.h"
25#include "crypto_internal.h"
26#include "ec_local.h"
27#include "ec_internal.h"
28#include "err_local.h"
29
30static int
31ec_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
32 const BIGNUM *b, BN_CTX *ctx)
33{
34 BIGNUM *t;
35 int ret = 0;
36
37 BN_CTX_start(ctx);
38
39 /* XXX - p must be a prime > 3. */
40
41 if (!bn_copy(group->p, p))
42 goto err;
43 if (!bn_copy(group->a, a))
44 goto err;
45 if (!bn_copy(group->b, b))
46 goto err;
47
48 /* XXX */
49 BN_set_negative(group->p, 0);
50
51 /* XXX */
52 if (!BN_nnmod(group->a, group->a, group->p, ctx))
53 goto err;
54 if (!BN_nnmod(group->b, group->b, group->p, ctx))
55 goto err;
56
57 if ((t = BN_CTX_get(ctx)) == NULL)
58 goto err;
59 if (!BN_set_word(t, 3))
60 goto err;
61 if (!BN_mod_add(t, t, a, group->p, ctx))
62 goto err;
63
64 group->a_is_minus3 = BN_is_zero(t);
65
66 if (!ec_field_modulus_from_bn(&group->fm, group->p, ctx))
67 goto err;
68 if (!ec_field_element_from_bn(&group->fm, group, &group->fe_a, group->a, ctx))
69 goto err;
70 if (!ec_field_element_from_bn(&group->fm, group, &group->fe_b, group->b, ctx))
71 goto err;
72
73 ret = 1;
74
75 err:
76 BN_CTX_end(ctx);
77
78 return ret;
79}
80
81static int
82ec_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
83 BIGNUM *b, BN_CTX *ctx)
84{
85 if (p != NULL) {
86 if (!bn_copy(p, group->p))
87 return 0;
88 }
89 if (a != NULL) {
90 if (!bn_copy(a, group->a))
91 return 0;
92 }
93 if (b != NULL) {
94 if (!bn_copy(b, group->b))
95 return 0;
96 }
97 return 1;
98}
99
100static int
101ec_point_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
102{
103 /* Check if Z is equal to zero. */
104 return ec_field_element_is_zero(&group->fm, &point->fe_z);
105}
106
107static int
108ec_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
109{
110 /* Infinity is (x = 0, y = 1, z = 0). */
111
112 memset(&point->fe_x, 0, sizeof(point->fe_x));
113 memset(&point->fe_y, 0, sizeof(point->fe_y));
114 memset(&point->fe_z, 0, sizeof(point->fe_z));
115
116 point->fe_y.w[0] = 1;
117
118 return 1;
119}
120
121static int
122ec_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
123 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
124{
125 if (x == NULL || y == NULL) {
126 ECerror(ERR_R_PASSED_NULL_PARAMETER);
127 return 0;
128 }
129
130 if (!bn_copy(point->X, x))
131 return 0;
132 if (!bn_copy(point->Y, y))
133 return 0;
134 if (!BN_one(point->Z))
135 return 0;
136
137 /* XXX */
138 if (!BN_nnmod(point->X, point->X, group->p, ctx))
139 return 0;
140 if (!BN_nnmod(point->Y, point->Y, group->p, ctx))
141 return 0;
142
143 if (!ec_field_element_from_bn(&group->fm, group, &point->fe_x, point->X, ctx))
144 return 0;
145 if (!ec_field_element_from_bn(&group->fm, group, &point->fe_y, point->Y, ctx))
146 return 0;
147 if (!ec_field_element_from_bn(&group->fm, group, &point->fe_z, point->Z, ctx))
148 return 0;
149
150 return 1;
151}
152
153static int
154ec_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
155 BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
156{
157 BIGNUM *zinv;
158 int ret = 0;
159
160 /*
161 * Convert homogeneous projective coordinates (XZ, YZ, Z) to affine
162 * coordinates (x = X/Z, y = Y/Z).
163 */
164 if (!ec_field_element_to_bn(&group->fm, &point->fe_x, point->X, ctx))
165 return 0;
166 if (!ec_field_element_to_bn(&group->fm, &point->fe_y, point->Y, ctx))
167 return 0;
168 if (!ec_field_element_to_bn(&group->fm, &point->fe_z, point->Z, ctx))
169 return 0;
170
171 BN_CTX_start(ctx);
172
173 if ((zinv = BN_CTX_get(ctx)) == NULL)
174 goto err;
175
176 if (BN_mod_inverse_ct(zinv, point->Z, group->p, ctx) == NULL)
177 goto err;
178
179 if (x != NULL) {
180 if (!BN_mod_mul(x, point->X, zinv, group->p, ctx))
181 goto err;
182 }
183 if (y != NULL) {
184 if (!BN_mod_mul(y, point->Y, zinv, group->p, ctx))
185 goto err;
186 }
187
188 ret = 1;
189
190 err:
191 BN_CTX_end(ctx);
192
193 return ret;
194}
195
196static int
197ec_point_add_a1(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
198 const EC_POINT *b, BN_CTX *ctx)
199{
200 EC_FIELD_ELEMENT X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3;
201 EC_FIELD_ELEMENT b3, t0, t1, t2, t3, t4, t5;
202 EC_FIELD_ELEMENT ga, gb;
203
204 /*
205 * Complete, projective point addition for arbitrary prime order short
206 * Weierstrass curves with arbitrary a - see
207 * https://eprint.iacr.org/2015/1060, algorithm 1 and appendix A.1.
208 */
209
210 ec_field_element_copy(&ga, &group->fe_a);
211 ec_field_element_copy(&gb, &group->fe_b);
212
213 ec_field_element_copy(&X1, &a->fe_x);
214 ec_field_element_copy(&Y1, &a->fe_y);
215 ec_field_element_copy(&Z1, &a->fe_z);
216
217 ec_field_element_copy(&X2, &b->fe_x);
218 ec_field_element_copy(&Y2, &b->fe_y);
219 ec_field_element_copy(&Z2, &b->fe_z);
220
221 /* b3 := 3 * b ; */
222 ec_field_element_add(&group->fm, &b3, &gb, &gb);
223 ec_field_element_add(&group->fm, &b3, &b3, &gb);
224
225 /* t0 := X1 * X2 ; t1 := Y1 * Y2 ; t2 := Z1 * Z2 ; */
226 ec_field_element_mul(&group->fm, &t0, &X1, &X2);
227 ec_field_element_mul(&group->fm, &t1, &Y1, &Y2);
228 ec_field_element_mul(&group->fm, &t2, &Z1, &Z2);
229
230 /* t3 := X1 + Y1 ; t4 := X2 + Y2 ; t3 := t3 * t4 ; */
231 ec_field_element_add(&group->fm, &t3, &X1, &Y1);
232 ec_field_element_add(&group->fm, &t4, &X2, &Y2);
233 ec_field_element_mul(&group->fm, &t3, &t3, &t4);
234
235 /* t4 := t0 + t1 ; t3 := t3 - t4 ; t4 := X1 + Z1 ; */
236 ec_field_element_add(&group->fm, &t4, &t0, &t1);
237 ec_field_element_sub(&group->fm, &t3, &t3, &t4);
238 ec_field_element_add(&group->fm, &t4, &X1, &Z1);
239
240 /* t5 := X2 + Z2 ; t4 := t4 * t5 ; t5 := t0 + t2 ; */
241 ec_field_element_add(&group->fm, &t5, &X2, &Z2);
242 ec_field_element_mul(&group->fm, &t4, &t4, &t5);
243 ec_field_element_add(&group->fm, &t5, &t0, &t2);
244
245 /* t4 := t4 - t5 ; t5 := Y1 + Z1 ; X3 := Y2 + Z2 ; */
246 ec_field_element_sub(&group->fm, &t4, &t4, &t5);
247 ec_field_element_add(&group->fm, &t5, &Y1, &Z1);
248 ec_field_element_add(&group->fm, &X3, &Y2, &Z2);
249
250 /* t5 := t5 * X3 ; X3 := t1 + t2 ; t5 := t5 - X3 ; */
251 ec_field_element_mul(&group->fm, &t5, &t5, &X3);
252 ec_field_element_add(&group->fm, &X3, &t1, &t2);
253 ec_field_element_sub(&group->fm, &t5, &t5, &X3);
254
255 /* Z3 := a * t4 ; X3 := b3 * t2 ; Z3 := X3 + Z3 ; */
256 ec_field_element_mul(&group->fm, &Z3, &ga, &t4);
257 ec_field_element_mul(&group->fm, &X3, &b3, &t2);
258 ec_field_element_add(&group->fm, &Z3, &X3, &Z3);
259
260 /* X3 := t1 - Z3 ; Z3 := t1 + Z3 ; Y3 := X3 * Z3 ; */
261 ec_field_element_sub(&group->fm, &X3, &t1, &Z3);
262 ec_field_element_add(&group->fm, &Z3, &t1, &Z3);
263 ec_field_element_mul(&group->fm, &Y3, &X3, &Z3);
264
265 /* t1 := t0 + t0 ; t1 := t1 + t0 ; t2 := a * t2 ; */
266 ec_field_element_add(&group->fm, &t1, &t0, &t0);
267 ec_field_element_add(&group->fm, &t1, &t1, &t0);
268 ec_field_element_mul(&group->fm, &t2, &ga, &t2);
269
270 /* t4 := b3 * t4 ; t1 := t1 + t2 ; t2 := t0 - t2 ; */
271 ec_field_element_mul(&group->fm, &t4, &b3, &t4);
272 ec_field_element_add(&group->fm, &t1, &t1, &t2);
273 ec_field_element_sub(&group->fm, &t2, &t0, &t2);
274
275 /* t2 := a * t2 ; t4 := t4 + t2 ; t0 := t1 * t4 ; */
276 ec_field_element_mul(&group->fm, &t2, &ga, &t2);
277 ec_field_element_add(&group->fm, &t4, &t4, &t2);
278 ec_field_element_mul(&group->fm, &t0, &t1, &t4);
279
280 /* Y3 := Y3 + t0 ; t0 := t5 * t4 ; X3 := t3 * X3 ; */
281 ec_field_element_add(&group->fm, &Y3, &Y3, &t0);
282 ec_field_element_mul(&group->fm, &t0, &t5, &t4);
283 ec_field_element_mul(&group->fm, &X3, &t3, &X3);
284
285 /* X3 := X3 - t0 ; t0 := t3 * t1 ; Z3 := t5 * Z3 ; */
286 ec_field_element_sub(&group->fm, &X3, &X3, &t0);
287 ec_field_element_mul(&group->fm, &t0, &t3, &t1);
288 ec_field_element_mul(&group->fm, &Z3, &t5, &Z3);
289
290 /* Z3 := Z3 + t0 ; */
291 ec_field_element_add(&group->fm, &Z3, &Z3, &t0);
292
293 ec_field_element_copy(&r->fe_x, &X3);
294 ec_field_element_copy(&r->fe_y, &Y3);
295 ec_field_element_copy(&r->fe_z, &Z3);
296
297 return 1;
298}
299
300static int
301ec_point_add_a2(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
302 const EC_POINT *b, BN_CTX *ctx)
303{
304 EC_FIELD_ELEMENT X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3;
305 EC_FIELD_ELEMENT t0, t1, t2, t3, t4;
306 EC_FIELD_ELEMENT gb;
307
308 /*
309 * Complete, projective point addition for arbitrary prime order short
310 * Weierstrass curves with a = -3 - see https://eprint.iacr.org/2015/1060,
311 * algorithm 4 and appendix A.2.
312 */
313
314 ec_field_element_copy(&gb, &group->fe_b);
315
316 ec_field_element_copy(&X1, &a->fe_x);
317 ec_field_element_copy(&Y1, &a->fe_y);
318 ec_field_element_copy(&Z1, &a->fe_z);
319
320 ec_field_element_copy(&X2, &b->fe_x);
321 ec_field_element_copy(&Y2, &b->fe_y);
322 ec_field_element_copy(&Z2, &b->fe_z);
323
324 /* t0 := X1 * X2 ; t1 := Y1 * Y2 ; t2 := Z1 * Z2 ; */
325 ec_field_element_mul(&group->fm, &t0, &X1, &X2);
326 ec_field_element_mul(&group->fm, &t1, &Y1, &Y2);
327 ec_field_element_mul(&group->fm, &t2, &Z1, &Z2);
328
329 /* t3 := X1 + Y1 ; t4 := X2 + Y2 ; t3 := t3 * t4 ; */
330 ec_field_element_add(&group->fm, &t3, &X1, &Y1);
331 ec_field_element_add(&group->fm, &t4, &X2, &Y2);
332 ec_field_element_mul(&group->fm, &t3, &t3, &t4);
333
334 /* t4 := t0 + t1 ; t3 := t3 - t4 ; t4 := Y1 + Z1 ; */
335 ec_field_element_add(&group->fm, &t4, &t0, &t1);
336 ec_field_element_sub(&group->fm, &t3, &t3, &t4);
337 ec_field_element_add(&group->fm, &t4, &Y1, &Z1);
338
339 /* X3 := Y2 + Z2 ; t4 := t4 * X3 ; X3 := t1 + t2 ; */
340 ec_field_element_add(&group->fm, &X3, &Y2, &Z2);
341 ec_field_element_mul(&group->fm, &t4, &t4, &X3);
342 ec_field_element_add(&group->fm, &X3, &t1, &t2);
343
344 /* t4 := t4 - X3 ; X3 := X1 + Z1 ; Y3 := X2 + Z2 ; */
345 ec_field_element_sub(&group->fm, &t4, &t4, &X3);
346 ec_field_element_add(&group->fm, &X3, &X1, &Z1);
347 ec_field_element_add(&group->fm, &Y3, &X2, &Z2);
348
349 /* X3 := X3 * Y3 ; Y3 := t0 + t2 ; Y3 := X3 - Y3 ; */
350 ec_field_element_mul(&group->fm, &X3, &X3, &Y3);
351 ec_field_element_add(&group->fm, &Y3, &t0, &t2);
352 ec_field_element_sub(&group->fm, &Y3, &X3, &Y3);
353
354 /* Z3 := b * t2 ; X3 := Y3 - Z3 ; Z3 := X3 + X3 ; */
355 ec_field_element_mul(&group->fm, &Z3, &gb, &t2);
356 ec_field_element_sub(&group->fm, &X3, &Y3, &Z3);
357 ec_field_element_add(&group->fm, &Z3, &X3, &X3);
358
359 /* X3 := X3 + Z3 ; Z3 := t1 - X3 ; X3 := t1 + X3 ; */
360 ec_field_element_add(&group->fm, &X3, &X3, &Z3);
361 ec_field_element_sub(&group->fm, &Z3, &t1, &X3);
362 ec_field_element_add(&group->fm, &X3, &t1, &X3);
363
364 /* Y3 := b * Y3 ; t1 := t2 + t2 ; t2 := t1 + t2 ; */
365 ec_field_element_mul(&group->fm, &Y3, &gb, &Y3);
366 ec_field_element_add(&group->fm, &t1, &t2, &t2);
367 ec_field_element_add(&group->fm, &t2, &t1, &t2);
368
369 /* Y3 := Y3 - t2 ; Y3 := Y3 - t0 ; t1 := Y3 + Y3 ; */
370 ec_field_element_sub(&group->fm, &Y3, &Y3, &t2);
371 ec_field_element_sub(&group->fm, &Y3, &Y3, &t0);
372 ec_field_element_add(&group->fm, &t1, &Y3, &Y3);
373
374 /* Y3 := t1 + Y3 ; t1 := t0 + t0 ; t0 := t1 + t0 ; */
375 ec_field_element_add(&group->fm, &Y3, &t1, &Y3);
376 ec_field_element_add(&group->fm, &t1, &t0, &t0);
377 ec_field_element_add(&group->fm, &t0, &t1, &t0);
378
379 /* t0 := t0 - t2 ; t1 := t4 * Y3 ; t2 := t0 * Y3 ; */
380 ec_field_element_sub(&group->fm, &t0, &t0, &t2);
381 ec_field_element_mul(&group->fm, &t1, &t4, &Y3);
382 ec_field_element_mul(&group->fm, &t2, &t0, &Y3);
383
384 /* Y3 := X3 * Z3 ; Y3 := Y3 + t2 ; X3 := t3 * X3 ; */
385 ec_field_element_mul(&group->fm, &Y3, &X3, &Z3);
386 ec_field_element_add(&group->fm, &Y3, &Y3, &t2);
387 ec_field_element_mul(&group->fm, &X3, &t3, &X3);
388
389 /* X3 := X3 - t1 ; Z3 := t4 * Z3 ; t1 := t3 * t0 ; */
390 ec_field_element_sub(&group->fm, &X3, &X3, &t1);
391 ec_field_element_mul(&group->fm, &Z3, &t4, &Z3);
392 ec_field_element_mul(&group->fm, &t1, &t3, &t0);
393
394 /* Z3 := Z3 + t1 ; */
395 ec_field_element_add(&group->fm, &Z3, &Z3, &t1);
396
397 ec_field_element_copy(&r->fe_x, &X3);
398 ec_field_element_copy(&r->fe_y, &Y3);
399 ec_field_element_copy(&r->fe_z, &Z3);
400
401 return 1;
402}
403
404static int
405ec_point_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
406 const EC_POINT *b, BN_CTX *ctx)
407{
408 if (group->a_is_minus3)
409 return ec_point_add_a2(group, r, a, b, ctx);
410
411 return ec_point_add_a1(group, r, a, b, ctx);
412}
413
414static int
415ec_point_dbl_a1(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
416{
417 EC_FIELD_ELEMENT X1, Y1, Z1, X3, Y3, Z3;
418 EC_FIELD_ELEMENT b3, t0, t1, t2, t3;
419 EC_FIELD_ELEMENT ga, gb;
420
421 /*
422 * Exception-free point doubling for arbitrary prime order short
423 * Weierstrass curves with arbitrary a - see
424 * https://eprint.iacr.org/2015/1060, algorithm 3 and appendix A.1.
425 */
426
427 ec_field_element_copy(&ga, &group->fe_a);
428 ec_field_element_copy(&gb, &group->fe_b);
429
430 ec_field_element_copy(&X1, &a->fe_x);
431 ec_field_element_copy(&Y1, &a->fe_y);
432 ec_field_element_copy(&Z1, &a->fe_z);
433
434 /* b3 := 3 * b ; */
435 ec_field_element_add(&group->fm, &b3, &gb, &gb);
436 ec_field_element_add(&group->fm, &b3, &b3, &gb);
437
438 /* t0 := X^2; t1 := Y^2; t2 := Z^2 ; */
439 ec_field_element_sqr(&group->fm, &t0, &X1);
440 ec_field_element_sqr(&group->fm, &t1, &Y1);
441 ec_field_element_sqr(&group->fm, &t2, &Z1);
442
443 /* t3 := X * Y ; t3 := t3 + t3 ; Z3 := X * Z ; */
444 ec_field_element_mul(&group->fm, &t3, &X1, &Y1);
445 ec_field_element_add(&group->fm, &t3, &t3, &t3);
446 ec_field_element_mul(&group->fm, &Z3, &X1, &Z1);
447
448 /* Z3 := Z3 + Z3 ; X3 := a * Z3 ; Y3 := b3 * t2 ; */
449 ec_field_element_add(&group->fm, &Z3, &Z3, &Z3);
450 ec_field_element_mul(&group->fm, &X3, &ga, &Z3);
451 ec_field_element_mul(&group->fm, &Y3, &b3, &t2);
452
453 /* Y3 := X3 + Y3 ; X3 := t1 - Y3 ; Y3 := t1 + Y3 ; */
454 ec_field_element_add(&group->fm, &Y3, &X3, &Y3);
455 ec_field_element_sub(&group->fm, &X3, &t1, &Y3);
456 ec_field_element_add(&group->fm, &Y3, &t1, &Y3);
457
458 /* Y3 := X3 * Y3 ; X3 := t3 * X3 ; Z3 := b3 * Z3 ; */
459 ec_field_element_mul(&group->fm, &Y3, &X3, &Y3);
460 ec_field_element_mul(&group->fm, &X3, &t3, &X3);
461 ec_field_element_mul(&group->fm, &Z3, &b3, &Z3);
462
463 /* t2 := a * t2 ; t3 := t0 - t2 ; t3 := a * t3 ; */
464 ec_field_element_mul(&group->fm, &t2, &ga, &t2);
465 ec_field_element_sub(&group->fm, &t3, &t0, &t2);
466 ec_field_element_mul(&group->fm, &t3, &ga, &t3);
467
468 /* t3 := t3 + Z3 ; Z3 := t0 + t0 ; t0 := Z3 + t0 ; */
469 ec_field_element_add(&group->fm, &t3, &t3, &Z3);
470 ec_field_element_add(&group->fm, &Z3, &t0, &t0);
471 ec_field_element_add(&group->fm, &t0, &Z3, &t0);
472
473 /* t0 := t0 + t2 ; t0 := t0 * t3 ; Y3 := Y3 + t0 ; */
474 ec_field_element_add(&group->fm, &t0, &t0, &t2);
475 ec_field_element_mul(&group->fm, &t0, &t0, &t3);
476 ec_field_element_add(&group->fm, &Y3, &Y3, &t0);
477
478 /* t2 := Y * Z ; t2 := t2 + t2 ; t0 := t2 * t3 ; */
479 ec_field_element_mul(&group->fm, &t2, &Y1, &Z1);
480 ec_field_element_add(&group->fm, &t2, &t2, &t2);
481 ec_field_element_mul(&group->fm, &t0, &t2, &t3);
482
483 /* X3 := X3 - t0 ; Z3 := t2 * t1 ; Z3 := Z3 + Z3 ; */
484 ec_field_element_sub(&group->fm, &X3, &X3, &t0);
485 ec_field_element_mul(&group->fm, &Z3, &t2, &t1);
486 ec_field_element_add(&group->fm, &Z3, &Z3, &Z3);
487
488 /* Z3 := Z3 + Z3 ; */
489 ec_field_element_add(&group->fm, &Z3, &Z3, &Z3);
490
491 ec_field_element_copy(&r->fe_x, &X3);
492 ec_field_element_copy(&r->fe_y, &Y3);
493 ec_field_element_copy(&r->fe_z, &Z3);
494
495 return 1;
496}
497
498static int
499ec_point_dbl_a2(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
500{
501 EC_FIELD_ELEMENT X1, Y1, Z1, X3, Y3, Z3;
502 EC_FIELD_ELEMENT t0, t1, t2, t3;
503 EC_FIELD_ELEMENT ga, gb;
504
505 /*
506 * Exception-free point doubling for arbitrary prime order short
507 * Weierstrass curves with a = -3 - see https://eprint.iacr.org/2015/1060,
508 * algorithm 6 and appendix A.2.
509 */
510
511 ec_field_element_copy(&ga, &group->fe_a);
512 ec_field_element_copy(&gb, &group->fe_b);
513
514 ec_field_element_copy(&X1, &a->fe_x);
515 ec_field_element_copy(&Y1, &a->fe_y);
516 ec_field_element_copy(&Z1, &a->fe_z);
517
518 /* t0 := X^2; t1 := Y^2; t2 := Z^2 ; */
519 ec_field_element_sqr(&group->fm, &t0, &X1);
520 ec_field_element_sqr(&group->fm, &t1, &Y1);
521 ec_field_element_sqr(&group->fm, &t2, &Z1);
522
523 /* t3 := X * Y ; t3 := t3 + t3 ; Z3 := X * Z ; */
524 ec_field_element_mul(&group->fm, &t3, &X1, &Y1);
525 ec_field_element_add(&group->fm, &t3, &t3, &t3);
526 ec_field_element_mul(&group->fm, &Z3, &X1, &Z1);
527
528 /* Z3 := Z3 + Z3 ; Y3 := b * t2 ; Y3 := Y3 - Z3 ; */
529 ec_field_element_add(&group->fm, &Z3, &Z3, &Z3);
530 ec_field_element_mul(&group->fm, &Y3, &gb, &t2);
531 ec_field_element_sub(&group->fm, &Y3, &Y3, &Z3);
532
533 /* X3 := Y3 + Y3 ; Y3 := X3 + Y3 ; X3 := t1 - Y3 ; */
534 ec_field_element_add(&group->fm, &X3, &Y3, &Y3);
535 ec_field_element_add(&group->fm, &Y3, &X3, &Y3);
536 ec_field_element_sub(&group->fm, &X3, &t1, &Y3);
537
538 /* Y3 := t1 + Y3 ; Y3 := X3 * Y3 ; X3 := X3 * t3 ; */
539 ec_field_element_add(&group->fm, &Y3, &t1, &Y3);
540 ec_field_element_mul(&group->fm, &Y3, &X3, &Y3);
541 ec_field_element_mul(&group->fm, &X3, &X3, &t3);
542
543 /* t3 := t2 + t2 ; t2 := t2 + t3 ; Z3 := b * Z3 ; */
544 ec_field_element_add(&group->fm, &t3, &t2, &t2);
545 ec_field_element_add(&group->fm, &t2, &t2, &t3);
546 ec_field_element_mul(&group->fm, &Z3, &gb, &Z3);
547
548 /* Z3 := Z3 - t2 ; Z3 := Z3 - t0 ; t3 := Z3 + Z3 ; */
549 ec_field_element_sub(&group->fm, &Z3, &Z3, &t2);
550 ec_field_element_sub(&group->fm, &Z3, &Z3, &t0);
551 ec_field_element_add(&group->fm, &t3, &Z3, &Z3);
552
553 /* Z3 := Z3 + t3 ; t3 := t0 + t0 ; t0 := t3 + t0 ; */
554 ec_field_element_add(&group->fm, &Z3, &Z3, &t3);
555 ec_field_element_add(&group->fm, &t3, &t0, &t0);
556 ec_field_element_add(&group->fm, &t0, &t3, &t0);
557
558 /* t0 := t0 - t2 ; t0 := t0 * Z3 ; Y3 := Y3 + t0 ; */
559 ec_field_element_sub(&group->fm, &t0, &t0, &t2);
560 ec_field_element_mul(&group->fm, &t0, &t0, &Z3);
561 ec_field_element_add(&group->fm, &Y3, &Y3, &t0);
562
563 /* t0 := Y * Z ; t0 := t0 + t0 ; Z3 := t0 * Z3 ; */
564 ec_field_element_mul(&group->fm, &t0, &Y1, &Z1);
565 ec_field_element_add(&group->fm, &t0, &t0, &t0);
566 ec_field_element_mul(&group->fm, &Z3, &t0, &Z3);
567
568 /* X3 := X3 - Z3 ; Z3 := t0 * t1 ; Z3 := Z3 + Z3 ; */
569 ec_field_element_sub(&group->fm, &X3, &X3, &Z3);
570 ec_field_element_mul(&group->fm, &Z3, &t0, &t1);
571 ec_field_element_add(&group->fm, &Z3, &Z3, &Z3);
572
573 /* Z3 := Z3 + Z3 ; */
574 ec_field_element_add(&group->fm, &Z3, &Z3, &Z3);
575
576 ec_field_element_copy(&r->fe_x, &X3);
577 ec_field_element_copy(&r->fe_y, &Y3);
578 ec_field_element_copy(&r->fe_z, &Z3);
579
580 return 1;
581}
582
583static int
584ec_point_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
585{
586 if (group->a_is_minus3)
587 return ec_point_dbl_a2(group, r, a, ctx);
588
589 return ec_point_dbl_a1(group, r, a, ctx);
590}
591
592static int
593ec_point_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
594{
595 EC_FIELD_ELEMENT y;
596 BN_ULONG mask;
597 int i;
598
599 /*
600 * Invert the point by setting Y = p - Y, if Y is non-zero and the point
601 * is not at infinity.
602 */
603
604 mask = ~(0 - (ec_point_is_at_infinity(group, point) |
605 ec_field_element_is_zero(&group->fm, &point->fe_y)));
606
607 /* XXX - masked/conditional subtraction? */
608 ec_field_element_sub(&group->fm, &y, &group->fm.m, &point->fe_y);
609
610 for (i = 0; i < group->fm.n; i++)
611 point->fe_y.w[i] = (point->fe_y.w[i] & ~mask) | (y.w[i] & mask);
612
613 return 1;
614}
615
616static int
617ec_point_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
618{
619 EC_FIELD_ELEMENT sum, axz2, bz3, x3, y2z, z2;
620
621 /*
622 * Curve is defined by a Weierstrass equation y^2 = x^3 + a*x + b.
623 * The given point is in homogeneous projective coordinates
624 * (x = X/Z, y = Y/Z). Substitute and multiply by Z^3 in order to
625 * evaluate as zy^2 = x^3 + axz^2 + bz^3.
626 */
627
628 ec_field_element_sqr(&group->fm, &z2, &point->fe_z);
629
630 ec_field_element_sqr(&group->fm, &y2z, &point->fe_y);
631 ec_field_element_mul(&group->fm, &y2z, &y2z, &point->fe_z);
632
633 ec_field_element_sqr(&group->fm, &x3, &point->fe_x);
634 ec_field_element_mul(&group->fm, &x3, &x3, &point->fe_x);
635
636 ec_field_element_mul(&group->fm, &axz2, &group->fe_a, &point->fe_x);
637 ec_field_element_mul(&group->fm, &axz2, &axz2, &z2);
638
639 ec_field_element_mul(&group->fm, &bz3, &group->fe_b, &point->fe_z);
640 ec_field_element_mul(&group->fm, &bz3, &bz3, &z2);
641
642 ec_field_element_add(&group->fm, &sum, &x3, &axz2);
643 ec_field_element_add(&group->fm, &sum, &sum, &bz3);
644
645 return ec_field_element_equal(&group->fm, &y2z, &sum) |
646 ec_point_is_at_infinity(group, point);
647}
648
649static int
650ec_point_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
651{
652 EC_FIELD_ELEMENT ax, ay, bx, by;
653
654 /*
655 * Compare two points that have homogeneous projection coordinates, that
656 * is (X_a/Z_a, Y_a/Z_a) == (X_b/Z_b, Y_b/Z_b). Return -1 on error, 0 on
657 * equality and 1 on inequality.
658 *
659 * If a and b are both at infinity, Z_a and Z_b will both be zero,
660 * resulting in all values becoming zero, resulting in equality. If a is
661 * at infinity and b is not, then Y_a will be one and Z_b will be
662 * non-zero, hence Y_a * Z_b will be non-zero. Z_a will be zero, hence
663 * Y_b * Z_a will be zero, resulting in inequality. The same applies if
664 * b is at infinity and a is not.
665 */
666
667 ec_field_element_mul(&group->fm, &ax, &a->fe_x, &b->fe_z);
668 ec_field_element_mul(&group->fm, &ay, &a->fe_y, &b->fe_z);
669 ec_field_element_mul(&group->fm, &bx, &b->fe_x, &a->fe_z);
670 ec_field_element_mul(&group->fm, &by, &b->fe_y, &a->fe_z);
671
672 return 1 - (ec_field_element_equal(&group->fm, &ax, &bx) &
673 ec_field_element_equal(&group->fm, &ay, &by));
674}
675
676#if 0
677static int
678ec_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[],
679 BN_CTX *ctx)
680{
681 size_t i;
682
683 /* XXX */
684 for (i = 0; i < num; i++) {
685 if (!EC_POINT_make_affine(group, points[0], ctx))
686 return 0;
687 }
688
689 return 1;
690}
691#else
692
693static int
694ec_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[],
695 BN_CTX *ctx)
696{
697 BIGNUM **prod_Z = NULL;
698 BIGNUM *tmp, *tmp_Z;
699 size_t i;
700 int ret = 0;
701
702 if (num == 0)
703 return 1;
704
705 BN_CTX_start(ctx);
706
707 if ((tmp = BN_CTX_get(ctx)) == NULL)
708 goto err;
709 if ((tmp_Z = BN_CTX_get(ctx)) == NULL)
710 goto err;
711
712 if ((prod_Z = calloc(num, sizeof *prod_Z)) == NULL)
713 goto err;
714 for (i = 0; i < num; i++) {
715 if ((prod_Z[i] = BN_CTX_get(ctx)) == NULL)
716 goto err;
717 }
718
719 if (!BN_is_zero(points[0]->Z)) {
720 if (!bn_copy(prod_Z[0], points[0]->Z))
721 goto err;
722 } else {
723 if (!BN_one(prod_Z[0]))
724 goto err;
725 }
726
727 for (i = 1; i < num; i++) {
728 if (!BN_is_zero(points[i]->Z)) {
729 if (!BN_mod_mul(prod_Z[i], prod_Z[i - 1], points[i]->Z,
730 group->p, ctx))
731 goto err;
732 } else {
733 if (!bn_copy(prod_Z[i], prod_Z[i - 1]))
734 goto err;
735 }
736 }
737
738 if (!BN_mod_inverse_nonct(tmp, prod_Z[num - 1], group->p, ctx)) {
739 ECerror(ERR_R_BN_LIB);
740 goto err;
741 }
742
743 for (i = num - 1; i > 0; i--) {
744 if (BN_is_zero(points[i]->Z))
745 continue;
746
747 if (!BN_mod_mul(tmp_Z, prod_Z[i - 1], tmp, group->p, ctx))
748 goto err;
749 if (!BN_mod_mul(tmp, tmp, points[i]->Z, group->p, ctx))
750 goto err;
751 if (!bn_copy(points[i]->Z, tmp_Z))
752 goto err;
753 }
754
755 for (i = 0; i < num; i++) {
756 EC_POINT *p = points[i];
757
758 if (BN_is_zero(p->Z))
759 continue;
760
761 if (!BN_mod_mul(p->X, p->X, p->Z, group->p, ctx))
762 goto err;
763 if (!BN_mod_mul(p->Y, p->Y, p->Z, group->p, ctx))
764 goto err;
765
766 if (!BN_one(p->Z))
767 goto err;
768 }
769
770 ret = 1;
771
772 err:
773 BN_CTX_end(ctx);
774 free(prod_Z);
775
776 return ret;
777}
778#endif
779
780static void
781ec_point_select(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
782 const EC_POINT *b, int conditional)
783{
784 ec_field_element_select(&group->fm, &r->fe_x, &a->fe_x, &b->fe_x, conditional);
785 ec_field_element_select(&group->fm, &r->fe_y, &a->fe_y, &b->fe_y, conditional);
786 ec_field_element_select(&group->fm, &r->fe_z, &a->fe_z, &b->fe_z, conditional);
787}
788
789static int
790ec_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, const EC_POINT *point,
791 BN_CTX *ctx)
792{
793 BIGNUM *cardinality;
794 EC_POINT *multiples[15];
795 EC_POINT *rr = NULL, *t = NULL;
796 uint8_t *scalar_bytes = NULL;
797 int scalar_len = 0;
798 uint8_t j, wv;
799 int conditional, i;
800 int ret = 0;
801
802 memset(multiples, 0, sizeof(multiples));
803
804 BN_CTX_start(ctx);
805
806 /* XXX - consider blinding. */
807
808 if ((cardinality = BN_CTX_get(ctx)) == NULL)
809 goto err;
810 if (!BN_mul(cardinality, group->order, group->cofactor, ctx))
811 goto err;
812
813 /* XXX - handle scalar > cardinality and/or negative. */
814
815 /* Convert scalar into big endian bytes. */
816 scalar_len = BN_num_bytes(cardinality);
817 if ((scalar_bytes = calloc(1, scalar_len)) == NULL)
818 goto err;
819 if (!BN_bn2binpad(scalar, scalar_bytes, scalar_len))
820 goto err;
821
822 /* Compute multiples of point. */
823 if ((multiples[0] = EC_POINT_dup(point, group)) == NULL)
824 goto err;
825 for (i = 1; i < 15; i += 2) {
826 if ((multiples[i] = EC_POINT_new(group)) == NULL)
827 goto err;
828 if (!EC_POINT_dbl(group, multiples[i], multiples[i / 2], ctx))
829 goto err;
830 if ((multiples[i + 1] = EC_POINT_new(group)) == NULL)
831 goto err;
832 if (!EC_POINT_add(group, multiples[i + 1], multiples[i], point, ctx))
833 goto err;
834 }
835
836 if ((rr = EC_POINT_new(group)) == NULL)
837 goto err;
838 if ((t = EC_POINT_new(group)) == NULL)
839 goto err;
840
841 if (!EC_POINT_set_to_infinity(group, rr))
842 goto err;
843
844 for (i = 0; i < scalar_len; i++) {
845 if (i != 0) {
846 if (!EC_POINT_dbl(group, rr, rr, ctx))
847 goto err;
848 if (!EC_POINT_dbl(group, rr, rr, ctx))
849 goto err;
850 if (!EC_POINT_dbl(group, rr, rr, ctx))
851 goto err;
852 if (!EC_POINT_dbl(group, rr, rr, ctx))
853 goto err;
854 }
855
856 if (!EC_POINT_set_to_infinity(group, t))
857 goto err;
858
859 wv = scalar_bytes[i] >> 4;
860 for (j = 1; j < 16; j++) {
861 conditional = crypto_ct_eq_u8(j, wv);
862 ec_point_select(group, t, t, multiples[j - 1], conditional);
863 }
864 if (!EC_POINT_add(group, rr, rr, t, ctx))
865 goto err;
866
867 if (!EC_POINT_dbl(group, rr, rr, ctx))
868 goto err;
869 if (!EC_POINT_dbl(group, rr, rr, ctx))
870 goto err;
871 if (!EC_POINT_dbl(group, rr, rr, ctx))
872 goto err;
873 if (!EC_POINT_dbl(group, rr, rr, ctx))
874 goto err;
875
876 if (!EC_POINT_set_to_infinity(group, t))
877 goto err;
878
879 wv = scalar_bytes[i] & 0xf;
880 for (j = 1; j < 16; j++) {
881 conditional = crypto_ct_eq_u8(j, wv);
882 ec_point_select(group, t, t, multiples[j - 1], conditional);
883 }
884 if (!EC_POINT_add(group, rr, rr, t, ctx))
885 goto err;
886 }
887
888 if (!EC_POINT_copy(r, rr))
889 goto err;
890
891 ret = 1;
892
893 err:
894 for (i = 0; i < 15; i++)
895 EC_POINT_free(multiples[i]);
896
897 EC_POINT_free(rr);
898 EC_POINT_free(t);
899
900 freezero(scalar_bytes, scalar_len);
901
902 BN_CTX_end(ctx);
903
904 return ret;
905}
906
907static int
908ec_mul_single_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
909 const EC_POINT *point, BN_CTX *ctx)
910{
911 return ec_mul(group, r, scalar, point, ctx);
912}
913
914static int
915ec_mul_double_nonct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar1,
916 const EC_POINT *point1, const BIGNUM *scalar2, const EC_POINT *point2,
917 BN_CTX *ctx)
918{
919 return ec_wnaf_mul(group, r, scalar1, point1, scalar2, point2, ctx);
920}
921
922static const EC_METHOD ec_GFp_homogeneous_projective_method = {
923 .group_set_curve = ec_group_set_curve,
924 .group_get_curve = ec_group_get_curve,
925 .point_set_to_infinity = ec_point_set_to_infinity,
926 .point_is_at_infinity = ec_point_is_at_infinity,
927 .point_set_affine_coordinates = ec_point_set_affine_coordinates,
928 .point_get_affine_coordinates = ec_point_get_affine_coordinates,
929 .add = ec_point_add,
930 .dbl = ec_point_dbl,
931 .invert = ec_point_invert,
932 .point_is_on_curve = ec_point_is_on_curve,
933 .point_cmp = ec_point_cmp,
934 .points_make_affine = ec_points_make_affine,
935 .mul_single_ct = ec_mul_single_ct,
936 .mul_double_nonct = ec_mul_double_nonct,
937};
938
939const EC_METHOD *
940EC_GFp_homogeneous_projective_method(void)
941{
942 return &ec_GFp_homogeneous_projective_method;
943}
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c
index ced85ceb1e..fcb48d9e33 100644
--- a/src/lib/libcrypto/ec/ecp_methods.c
+++ b/src/lib/libcrypto/ec/ecp_methods.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_methods.c,v 1.45 2025/03/24 13:07:04 jsing Exp $ */ 1/* $OpenBSD: ecp_methods.c,v 1.47 2025/05/24 08:25:58 jsing Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. 3 * for the OpenSSL project.
4 * Includes code written by Bodo Moeller for the OpenSSL project. 4 * Includes code written by Bodo Moeller for the OpenSSL project.
@@ -66,11 +66,11 @@
66 66
67#include <openssl/bn.h> 67#include <openssl/bn.h>
68#include <openssl/ec.h> 68#include <openssl/ec.h>
69#include <openssl/err.h>
70#include <openssl/objects.h> 69#include <openssl/objects.h>
71 70
72#include "bn_local.h" 71#include "bn_local.h"
73#include "ec_local.h" 72#include "ec_local.h"
73#include "err_local.h"
74 74
75/* 75/*
76 * Most method functions in this file are designed to work with non-trivial 76 * Most method functions in this file are designed to work with non-trivial
@@ -180,6 +180,21 @@ ec_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
180} 180}
181 181
182static int 182static int
183ec_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
184{
185 BN_zero(point->Z);
186 point->Z_is_one = 0;
187
188 return 1;
189}
190
191static int
192ec_point_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
193{
194 return BN_is_zero(point->Z);
195}
196
197static int
183ec_point_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) 198ec_point_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
184{ 199{
185 BIGNUM *rh, *tmp, *Z4, *Z6; 200 BIGNUM *rh, *tmp, *Z4, *Z6;
@@ -1281,6 +1296,8 @@ ec_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
1281static const EC_METHOD ec_GFp_simple_method = { 1296static const EC_METHOD ec_GFp_simple_method = {
1282 .group_set_curve = ec_group_set_curve, 1297 .group_set_curve = ec_group_set_curve,
1283 .group_get_curve = ec_group_get_curve, 1298 .group_get_curve = ec_group_get_curve,
1299 .point_set_to_infinity = ec_point_set_to_infinity,
1300 .point_is_at_infinity = ec_point_is_at_infinity,
1284 .point_is_on_curve = ec_point_is_on_curve, 1301 .point_is_on_curve = ec_point_is_on_curve,
1285 .point_cmp = ec_point_cmp, 1302 .point_cmp = ec_point_cmp,
1286 .point_set_affine_coordinates = ec_point_set_affine_coordinates, 1303 .point_set_affine_coordinates = ec_point_set_affine_coordinates,
@@ -1304,6 +1321,8 @@ EC_GFp_simple_method(void)
1304static const EC_METHOD ec_GFp_mont_method = { 1321static const EC_METHOD ec_GFp_mont_method = {
1305 .group_set_curve = ec_mont_group_set_curve, 1322 .group_set_curve = ec_mont_group_set_curve,
1306 .group_get_curve = ec_group_get_curve, 1323 .group_get_curve = ec_group_get_curve,
1324 .point_set_to_infinity = ec_point_set_to_infinity,
1325 .point_is_at_infinity = ec_point_is_at_infinity,
1307 .point_is_on_curve = ec_point_is_on_curve, 1326 .point_is_on_curve = ec_point_is_on_curve,
1308 .point_cmp = ec_point_cmp, 1327 .point_cmp = ec_point_cmp,
1309 .point_set_affine_coordinates = ec_point_set_affine_coordinates, 1328 .point_set_affine_coordinates = ec_point_set_affine_coordinates,
diff --git a/src/lib/libcrypto/ec/ecx_methods.c b/src/lib/libcrypto/ec/ecx_methods.c
index 6b5759d4fa..b08456d03b 100644
--- a/src/lib/libcrypto/ec/ecx_methods.c
+++ b/src/lib/libcrypto/ec/ecx_methods.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecx_methods.c,v 1.14 2024/08/28 07:15:04 tb Exp $ */ 1/* $OpenBSD: ecx_methods.c,v 1.15 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -20,13 +20,13 @@
20#include <openssl/cms.h> 20#include <openssl/cms.h>
21#include <openssl/curve25519.h> 21#include <openssl/curve25519.h>
22#include <openssl/ec.h> 22#include <openssl/ec.h>
23#include <openssl/err.h>
24#include <openssl/evp.h> 23#include <openssl/evp.h>
25#include <openssl/x509.h> 24#include <openssl/x509.h>
26 25
27#include "asn1_local.h" 26#include "asn1_local.h"
28#include "bytestring.h" 27#include "bytestring.h"
29#include "curve25519_internal.h" 28#include "curve25519_internal.h"
29#include "err_local.h"
30#include "evp_local.h" 30#include "evp_local.h"
31#include "x509_local.h" 31#include "x509_local.h"
32 32
diff --git a/src/lib/libcrypto/ecdh/ecdh.c b/src/lib/libcrypto/ecdh/ecdh.c
index dbb91f1991..c3affed682 100644
--- a/src/lib/libcrypto/ecdh/ecdh.c
+++ b/src/lib/libcrypto/ecdh/ecdh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdh.c,v 1.11 2025/02/17 09:25:45 tb Exp $ */ 1/* $OpenBSD: ecdh.c,v 1.12 2025/05/10 05:54:38 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -73,10 +73,10 @@
73 73
74#include <openssl/bn.h> 74#include <openssl/bn.h>
75#include <openssl/ec.h> 75#include <openssl/ec.h>
76#include <openssl/err.h>
77#include <openssl/evp.h> 76#include <openssl/evp.h>
78 77
79#include "ec_local.h" 78#include "ec_local.h"
79#include "err_local.h"
80 80
81/* 81/*
82 * Key derivation function from X9.63/SECG. 82 * Key derivation function from X9.63/SECG.
diff --git a/src/lib/libcrypto/ecdsa/ecdsa.c b/src/lib/libcrypto/ecdsa/ecdsa.c
index 5abc3586e3..4e00eb5ec8 100644
--- a/src/lib/libcrypto/ecdsa/ecdsa.c
+++ b/src/lib/libcrypto/ecdsa/ecdsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdsa.c,v 1.19 2024/04/15 15:49:37 tb Exp $ */ 1/* $OpenBSD: ecdsa.c,v 1.20 2025/05/10 05:54:38 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -61,11 +61,11 @@
61#include <openssl/asn1t.h> 61#include <openssl/asn1t.h>
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/ec.h> 63#include <openssl/ec.h>
64#include <openssl/err.h>
65 64
66#include "bn_local.h" 65#include "bn_local.h"
67#include "ec_local.h" 66#include "ec_local.h"
68#include "ecdsa_local.h" 67#include "ecdsa_local.h"
68#include "err_local.h"
69 69
70static const ASN1_TEMPLATE ECDSA_SIG_seq_tt[] = { 70static const ASN1_TEMPLATE ECDSA_SIG_seq_tt[] = {
71 { 71 {
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
index 25fbb03875..a60769fc2a 100644
--- a/src/lib/libcrypto/err/err.c
+++ b/src/lib/libcrypto/err/err.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: err.c,v 1.75 2024/11/02 12:46:36 tb Exp $ */ 1/* $OpenBSD: err.c,v 1.78 2025/06/10 08:53:37 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -484,33 +484,27 @@ err_build_SYS_str_reasons(void)
484{ 484{
485 /* malloc cannot be used here, use static storage instead */ 485 /* malloc cannot be used here, use static storage instead */
486 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; 486 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
487 const char *errstr;
487 int save_errno; 488 int save_errno;
488 int i; 489 int i;
489 490
490 /* strerror(3) will set errno to EINVAL when i is an unknown errno. */ 491 /* strerror(3) will set errno to EINVAL when i is an unknown errno. */
491 save_errno = errno; 492 save_errno = errno;
492 for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { 493 for (i = 0; i < NUM_SYS_STR_REASONS; i++) {
493 ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; 494 ERR_STRING_DATA *str = &SYS_str_reasons[i];
494 495
495 str->error = (unsigned long)i; 496 str->error = i + 1;
496 if (str->string == NULL) { 497 str->string = "unknown";
497 char (*dest)[LEN_SYS_STR_REASON] = 498
498 &(strerror_tab[i - 1]); 499 if ((errstr = strerror((int)str->error)) != NULL) {
499 const char *src = strerror(i); 500 strlcpy(strerror_tab[i], errstr, sizeof(strerror_tab[i]));
500 if (src != NULL) { 501 str->string = strerror_tab[i];
501 strlcpy(*dest, src, sizeof *dest);
502 str->string = *dest;
503 }
504 } 502 }
505 if (str->string == NULL)
506 str->string = "unknown";
507 } 503 }
508 errno = save_errno; 504 errno = save_errno;
509 505
510 /* 506 SYS_str_reasons[NUM_SYS_STR_REASONS].error = 0;
511 * Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, 507 SYS_str_reasons[NUM_SYS_STR_REASONS].string = NULL;
512 * as required by ERR_load_strings.
513 */
514} 508}
515#endif 509#endif
516 510
@@ -830,7 +824,7 @@ err_clear_last_constant_time(int clear)
830 824
831 es = ERR_get_state(); 825 es = ERR_get_state();
832 if (es == NULL) 826 if (es == NULL)
833 return; 827 return;
834 828
835 top = es->top; 829 top = es->top;
836 830
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h
index fe6c34dd0a..093db4316e 100644
--- a/src/lib/libcrypto/err/err.h
+++ b/src/lib/libcrypto/err/err.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: err.h,v 1.36 2025/03/09 15:12:18 tb Exp $ */ 1/* $OpenBSD: err.h,v 1.38 2025/05/10 06:17:09 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -192,80 +192,9 @@ extern "C" {
192#define ERR_LIB_USER 128 192#define ERR_LIB_USER 128
193 193
194#ifndef LIBRESSL_INTERNAL 194#ifndef LIBRESSL_INTERNAL
195#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) 195#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
196#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE) 196#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
197#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE) 197#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
198#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
199#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
200#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
201#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
202#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
203#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
204#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
205#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
206#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
207#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
208#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
209#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
210#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
211#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
212#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
213#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
214#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
215#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
216#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
217#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
218#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
219#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
220#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
221#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
222#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
223#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
224#define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
225#define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
226#define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
227#define GOSTerr(f,r) ERR_PUT_error(ERR_LIB_GOST,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
228#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
229#define CTerr(f, r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
230#define KDFerr(f, r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
231#endif
232
233#ifdef LIBRESSL_INTERNAL
234#define SYSerror(r) ERR_PUT_error(ERR_LIB_SYS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
235#define BNerror(r) ERR_PUT_error(ERR_LIB_BN,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
236#define RSAerror(r) ERR_PUT_error(ERR_LIB_RSA,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
237#define DHerror(r) ERR_PUT_error(ERR_LIB_DH,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
238#define EVPerror(r) ERR_PUT_error(ERR_LIB_EVP,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
239#define BUFerror(r) ERR_PUT_error(ERR_LIB_BUF,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
240#define OBJerror(r) ERR_PUT_error(ERR_LIB_OBJ,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
241#define PEMerror(r) ERR_PUT_error(ERR_LIB_PEM,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
242#define DSAerror(r) ERR_PUT_error(ERR_LIB_DSA,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
243#define X509error(r) ERR_PUT_error(ERR_LIB_X509,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
244#define ASN1error(r) ERR_PUT_error(ERR_LIB_ASN1,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
245#define CONFerror(r) ERR_PUT_error(ERR_LIB_CONF,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
246#define CRYPTOerror(r) ERR_PUT_error(ERR_LIB_CRYPTO,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
247#define ECerror(r) ERR_PUT_error(ERR_LIB_EC,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
248#define BIOerror(r) ERR_PUT_error(ERR_LIB_BIO,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
249#define PKCS7error(r) ERR_PUT_error(ERR_LIB_PKCS7,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
250#define X509V3error(r) ERR_PUT_error(ERR_LIB_X509V3,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
251#define PKCS12error(r) ERR_PUT_error(ERR_LIB_PKCS12,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
252#define RANDerror(r) ERR_PUT_error(ERR_LIB_RAND,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
253#define DSOerror(r) ERR_PUT_error(ERR_LIB_DSO,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
254#define ENGINEerror(r) ERR_PUT_error(ERR_LIB_ENGINE,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
255#define OCSPerror(r) ERR_PUT_error(ERR_LIB_OCSP,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
256#define UIerror(r) ERR_PUT_error(ERR_LIB_UI,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
257#define COMPerror(r) ERR_PUT_error(ERR_LIB_COMP,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
258#define ECDSAerror(r) ERR_PUT_error(ERR_LIB_ECDSA,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
259#define ECDHerror(r) ERR_PUT_error(ERR_LIB_ECDH,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
260#define STOREerror(r) ERR_PUT_error(ERR_LIB_STORE,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
261#define FIPSerror(r) ERR_PUT_error(ERR_LIB_FIPS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
262#define CMSerror(r) ERR_PUT_error(ERR_LIB_CMS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
263#define TSerror(r) ERR_PUT_error(ERR_LIB_TS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
264#define HMACerror(r) ERR_PUT_error(ERR_LIB_HMAC,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
265#define JPAKEerror(r) ERR_PUT_error(ERR_LIB_JPAKE,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
266#define GOSTerror(r) ERR_PUT_error(ERR_LIB_GOST,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
267#define CTerror(r) ERR_PUT_error(ERR_LIB_CT,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
268#define KDFerror(r) ERR_PUT_error(ERR_LIB_KDF,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
269#endif 198#endif
270 199
271#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)<<24L)| \ 200#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)<<24L)| \
diff --git a/src/lib/libcrypto/err/err_local.h b/src/lib/libcrypto/err/err_local.h
index d091b979cc..87cd40f4a8 100644
--- a/src/lib/libcrypto/err/err_local.h
+++ b/src/lib/libcrypto/err/err_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: err_local.h,v 1.1 2024/06/24 06:43:22 tb Exp $ */ 1/* $OpenBSD: err_local.h,v 1.5 2025/05/10 06:45:46 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -118,6 +118,34 @@ __BEGIN_HIDDEN_DECLS
118 118
119void ERR_load_const_strings(const ERR_STRING_DATA *str); 119void ERR_load_const_strings(const ERR_STRING_DATA *str);
120 120
121#define ERR_PUT_ERROR(l, r) ERR_PUT_error((l), 0xfff, (r), OPENSSL_FILE, OPENSSL_LINE)
122
123#define ASN1error(r) ERR_PUT_ERROR(ERR_LIB_ASN1, (r))
124#define BIOerror(r) ERR_PUT_ERROR(ERR_LIB_BIO, (r))
125#define BNerror(r) ERR_PUT_ERROR(ERR_LIB_BN, (r))
126#define BUFerror(r) ERR_PUT_ERROR(ERR_LIB_BUF, (r))
127#define CMSerror(r) ERR_PUT_ERROR(ERR_LIB_CMS, (r))
128#define CONFerror(r) ERR_PUT_ERROR(ERR_LIB_CONF, (r))
129#define CRYPTOerror(r) ERR_PUT_ERROR(ERR_LIB_CRYPTO, (r))
130#define CTerror(r) ERR_PUT_ERROR(ERR_LIB_CT, (r))
131#define DHerror(r) ERR_PUT_ERROR(ERR_LIB_DH, (r))
132#define DSAerror(r) ERR_PUT_ERROR(ERR_LIB_DSA, (r))
133#define ECerror(r) ERR_PUT_ERROR(ERR_LIB_EC, (r))
134#define EVPerror(r) ERR_PUT_ERROR(ERR_LIB_EVP, (r))
135#define KDFerror(r) ERR_PUT_ERROR(ERR_LIB_KDF, (r))
136#define OBJerror(r) ERR_PUT_ERROR(ERR_LIB_OBJ, (r))
137#define OCSPerror(r) ERR_PUT_ERROR(ERR_LIB_OCSP, (r))
138#define PEMerror(r) ERR_PUT_ERROR(ERR_LIB_PEM, (r))
139#define PKCS12error(r) ERR_PUT_ERROR(ERR_LIB_PKCS12, (r))
140#define PKCS7error(r) ERR_PUT_ERROR(ERR_LIB_PKCS7, (r))
141#define RANDerror(r) ERR_PUT_ERROR(ERR_LIB_RAND, (r))
142#define RSAerror(r) ERR_PUT_ERROR(ERR_LIB_RSA, (r))
143#define SYSerror(r) ERR_PUT_ERROR(ERR_LIB_SYS, (r))
144#define TSerror(r) ERR_PUT_ERROR(ERR_LIB_TS, (r))
145#define UIerror(r) ERR_PUT_ERROR(ERR_LIB_UI, (r))
146#define X509V3error(r) ERR_PUT_ERROR(ERR_LIB_X509V3, (r))
147#define X509error(r) ERR_PUT_ERROR(ERR_LIB_X509, (r))
148
121__END_HIDDEN_DECLS 149__END_HIDDEN_DECLS
122 150
123#endif /* HEADER_ERR_LOCAL_H */ 151#endif /* HEADER_ERR_LOCAL_H */
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index 5c52b6b258..e1ae1e9a5b 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_aes.c,v 1.61 2025/04/18 13:25:03 jsing Exp $ */ 1/* $OpenBSD: e_aes.c,v 1.83 2025/07/22 09:31:09 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -59,19 +59,15 @@
59 59
60#ifndef OPENSSL_NO_AES 60#ifndef OPENSSL_NO_AES
61#include <openssl/aes.h> 61#include <openssl/aes.h>
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64 63
64#include "aes_local.h"
65#include "err_local.h"
65#include "evp_local.h" 66#include "evp_local.h"
66#include "modes_local.h" 67#include "modes_local.h"
67 68
68typedef struct { 69typedef struct {
69 AES_KEY ks; 70 AES_KEY ks;
70 block128_f block;
71 union {
72 cbc128_f cbc;
73 ctr128_f ctr;
74 } stream;
75} EVP_AES_KEY; 71} EVP_AES_KEY;
76 72
77typedef struct { 73typedef struct {
@@ -84,15 +80,11 @@ typedef struct {
84 int taglen; 80 int taglen;
85 int iv_gen; /* It is OK to generate IVs */ 81 int iv_gen; /* It is OK to generate IVs */
86 int tls_aad_len; /* TLS AAD length */ 82 int tls_aad_len; /* TLS AAD length */
87 ctr128_f ctr;
88} EVP_AES_GCM_CTX; 83} EVP_AES_GCM_CTX;
89 84
90typedef struct { 85typedef struct {
91 AES_KEY ks1, ks2; /* AES key schedules to use */ 86 AES_KEY ks1, ks2; /* AES key schedules to use */
92 XTS128_CONTEXT xts; 87 XTS128_CONTEXT xts; /* XXX - replace with flags. */
93 void (*stream)(const unsigned char *in, unsigned char *out,
94 size_t length, const AES_KEY *key1, const AES_KEY *key2,
95 const unsigned char iv[16]);
96} EVP_AES_XTS_CTX; 88} EVP_AES_XTS_CTX;
97 89
98typedef struct { 90typedef struct {
@@ -103,99 +95,17 @@ typedef struct {
103 int len_set; /* Set if message length set */ 95 int len_set; /* Set if message length set */
104 int L, M; /* L and M parameters from RFC3610 */ 96 int L, M; /* L and M parameters from RFC3610 */
105 CCM128_CONTEXT ccm; 97 CCM128_CONTEXT ccm;
106 ccm128_f str;
107} EVP_AES_CCM_CTX; 98} EVP_AES_CCM_CTX;
108 99
109#define MAXBITCHUNK ((size_t)1<<(sizeof(size_t)*8-4)) 100#define MAXBITCHUNK ((size_t)1<<(sizeof(size_t)*8-4))
110 101
111#ifdef AES_CTR_ASM
112void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out,
113 size_t blocks, const AES_KEY *key,
114 const unsigned char ivec[AES_BLOCK_SIZE]);
115#endif
116#ifdef AES_XTS_ASM
117void AES_xts_encrypt(const char *inp, char *out, size_t len,
118 const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]);
119void AES_xts_decrypt(const char *inp, char *out, size_t len,
120 const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]);
121#endif
122
123#if defined(AES_ASM) && ( \
124 ((defined(__i386) || defined(__i386__) || \
125 defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2))|| \
126 defined(__x86_64) || defined(__x86_64__) || \
127 defined(_M_AMD64) || defined(_M_X64) || \
128 defined(__INTEL__) )
129
130#include "x86_arch.h"
131
132/*
133 * AES-NI section
134 */
135#define AESNI_CAPABLE (crypto_cpu_caps_ia32() & CPUCAP_MASK_AESNI)
136
137int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
138 AES_KEY *key);
139int aesni_set_decrypt_key(const unsigned char *userKey, int bits,
140 AES_KEY *key);
141
142void aesni_encrypt(const unsigned char *in, unsigned char *out,
143 const AES_KEY *key);
144void aesni_decrypt(const unsigned char *in, unsigned char *out,
145 const AES_KEY *key);
146
147void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out,
148 size_t length, const AES_KEY *key, int enc);
149void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out,
150 size_t length, const AES_KEY *key, unsigned char *ivec, int enc);
151
152void aesni_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
153 size_t blocks, const void *key, const unsigned char *ivec);
154
155void aesni_xts_encrypt(const unsigned char *in, unsigned char *out,
156 size_t length, const AES_KEY *key1, const AES_KEY *key2,
157 const unsigned char iv[16]);
158
159void aesni_xts_decrypt(const unsigned char *in, unsigned char *out,
160 size_t length, const AES_KEY *key1, const AES_KEY *key2,
161 const unsigned char iv[16]);
162
163void aesni_ccm64_encrypt_blocks (const unsigned char *in, unsigned char *out,
164 size_t blocks, const void *key, const unsigned char ivec[16],
165 unsigned char cmac[16]);
166
167void aesni_ccm64_decrypt_blocks (const unsigned char *in, unsigned char *out,
168 size_t blocks, const void *key, const unsigned char ivec[16],
169 unsigned char cmac[16]);
170
171static int 102static int
172aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 103aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
173 const unsigned char *iv, int enc) 104 const unsigned char *iv, int enc)
174{ 105{
175 int ret, mode; 106 EVP_AES_KEY *eak = ctx->cipher_data;
176 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
177
178 mode = ctx->cipher->flags & EVP_CIPH_MODE;
179 if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE) &&
180 !enc) {
181 ret = aesni_set_decrypt_key(key, ctx->key_len * 8,
182 ctx->cipher_data);
183 dat->block = (block128_f)aesni_decrypt;
184 dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ?
185 (cbc128_f)aesni_cbc_encrypt : NULL;
186 } else {
187 ret = aesni_set_encrypt_key(key, ctx->key_len * 8,
188 ctx->cipher_data);
189 dat->block = (block128_f)aesni_encrypt;
190 if (mode == EVP_CIPH_CBC_MODE)
191 dat->stream.cbc = (cbc128_f)aesni_cbc_encrypt;
192 else if (mode == EVP_CIPH_CTR_MODE)
193 dat->stream.ctr = (ctr128_f)aesni_ctr32_encrypt_blocks;
194 else
195 dat->stream.cbc = NULL;
196 }
197 107
198 if (ret < 0) { 108 if (AES_set_encrypt_key(key, ctx->key_len * 8, &eak->ks) < 0) {
199 EVPerror(EVP_R_AES_KEY_SETUP_FAILED); 109 EVPerror(EVP_R_AES_KEY_SETUP_FAILED);
200 return 0; 110 return 0;
201 } 111 }
@@ -204,192 +114,65 @@ aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
204} 114}
205 115
206static int 116static int
207aesni_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 117aes_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
208 const unsigned char *in, size_t len) 118 const unsigned char *iv, int encrypt)
209{
210 aesni_cbc_encrypt(in, out, len, ctx->cipher_data, ctx->iv,
211 ctx->encrypt);
212
213 return 1;
214}
215
216static int
217aesni_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
218 const unsigned char *in, size_t len)
219{
220 size_t bl = ctx->cipher->block_size;
221
222 if (len < bl)
223 return 1;
224
225 aesni_ecb_encrypt(in, out, len, ctx->cipher_data, ctx->encrypt);
226
227 return 1;
228}
229
230static int
231aesni_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
232 const unsigned char *iv, int enc)
233{ 119{
234 EVP_AES_GCM_CTX *gctx = ctx->cipher_data; 120 EVP_AES_KEY *eak = ctx->cipher_data;
235 121
236 if (!iv && !key) 122 if (encrypt) {
237 return 1; 123 if (AES_set_encrypt_key(key, ctx->key_len * 8, &eak->ks) < 0) {
238 if (key) { 124 EVPerror(EVP_R_AES_KEY_SETUP_FAILED);
239 aesni_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks); 125 return 0;
240 CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks,
241 (block128_f)aesni_encrypt);
242 gctx->ctr = (ctr128_f)aesni_ctr32_encrypt_blocks;
243 /* If we have an iv can set it directly, otherwise use
244 * saved IV.
245 */
246 if (iv == NULL && gctx->iv_set)
247 iv = gctx->iv;
248 if (iv) {
249 CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen);
250 gctx->iv_set = 1;
251 } 126 }
252 gctx->key_set = 1;
253 } else { 127 } else {
254 /* If key set use IV, otherwise copy */ 128 if (AES_set_decrypt_key(key, ctx->key_len * 8, &eak->ks) < 0) {
255 if (gctx->key_set) 129 EVPerror(EVP_R_AES_KEY_SETUP_FAILED);
256 CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen); 130 return 0;
257 else
258 memcpy(gctx->iv, iv, gctx->ivlen);
259 gctx->iv_set = 1;
260 gctx->iv_gen = 0;
261 }
262 return 1;
263}
264
265static int
266aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
267 const unsigned char *iv, int enc)
268{
269 EVP_AES_XTS_CTX *xctx = ctx->cipher_data;
270
271 if (!iv && !key)
272 return 1;
273
274 if (key) {
275 /* key_len is two AES keys */
276 if (enc) {
277 aesni_set_encrypt_key(key, ctx->key_len * 4,
278 &xctx->ks1);
279 xctx->xts.block1 = (block128_f)aesni_encrypt;
280 xctx->stream = aesni_xts_encrypt;
281 } else {
282 aesni_set_decrypt_key(key, ctx->key_len * 4,
283 &xctx->ks1);
284 xctx->xts.block1 = (block128_f)aesni_decrypt;
285 xctx->stream = aesni_xts_decrypt;
286 } 131 }
287
288 aesni_set_encrypt_key(key + ctx->key_len / 2,
289 ctx->key_len * 4, &xctx->ks2);
290 xctx->xts.block2 = (block128_f)aesni_encrypt;
291
292 xctx->xts.key1 = &xctx->ks1;
293 }
294
295 if (iv) {
296 xctx->xts.key2 = &xctx->ks2;
297 memcpy(ctx->iv, iv, 16);
298 } 132 }
299 133
300 return 1; 134 return 1;
301} 135}
302 136
303static int 137static int
304aesni_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 138aes_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
305 const unsigned char *iv, int enc) 139 const unsigned char *in, size_t len)
306{ 140{
307 EVP_AES_CCM_CTX *cctx = ctx->cipher_data; 141 EVP_AES_KEY *eak = ctx->cipher_data;
142
143 AES_cbc_encrypt(in, out, len, &eak->ks, ctx->iv, ctx->encrypt);
308 144
309 if (!iv && !key)
310 return 1;
311 if (key) {
312 aesni_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks);
313 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
314 &cctx->ks, (block128_f)aesni_encrypt);
315 cctx->str = enc ? (ccm128_f)aesni_ccm64_encrypt_blocks :
316 (ccm128_f)aesni_ccm64_decrypt_blocks;
317 cctx->key_set = 1;
318 }
319 if (iv) {
320 memcpy(ctx->iv, iv, 15 - cctx->L);
321 cctx->iv_set = 1;
322 }
323 return 1; 145 return 1;
324} 146}
325 147
326#endif
327
328static int 148static int
329aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 149aes_ecb_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
330 const unsigned char *iv, int enc) 150 const unsigned char *iv, int encrypt)
331{ 151{
332 int ret, mode; 152 EVP_AES_KEY *eak = ctx->cipher_data;
333 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
334
335 mode = ctx->cipher->flags & EVP_CIPH_MODE;
336 153
337 if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE) && !enc) { 154 if (encrypt) {
338 ret = AES_set_decrypt_key(key, ctx->key_len * 8, &dat->ks); 155 if (AES_set_encrypt_key(key, ctx->key_len * 8, &eak->ks) < 0) {
339 dat->block = (block128_f)AES_decrypt; 156 EVPerror(EVP_R_AES_KEY_SETUP_FAILED);
340 dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? 157 return 0;
341 (cbc128_f)AES_cbc_encrypt : NULL; 158 }
342 } else { 159 } else {
343 ret = AES_set_encrypt_key(key, ctx->key_len * 8, &dat->ks); 160 if (AES_set_decrypt_key(key, ctx->key_len * 8, &eak->ks) < 0) {
344 dat->block = (block128_f)AES_encrypt; 161 EVPerror(EVP_R_AES_KEY_SETUP_FAILED);
345 dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? 162 return 0;
346 (cbc128_f)AES_cbc_encrypt : NULL; 163 }
347#ifdef AES_CTR_ASM
348 if (mode == EVP_CIPH_CTR_MODE)
349 dat->stream.ctr = (ctr128_f)AES_ctr32_encrypt;
350#endif
351 }
352
353 if (ret < 0) {
354 EVPerror(EVP_R_AES_KEY_SETUP_FAILED);
355 return 0;
356 } 164 }
357 165
358 return 1; 166 return 1;
359} 167}
360 168
361static int 169static int
362aes_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
363 const unsigned char *in, size_t len)
364{
365 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
366
367 if (dat->stream.cbc)
368 (*dat->stream.cbc)(in, out, len, &dat->ks, ctx->iv,
369 ctx->encrypt);
370 else if (ctx->encrypt)
371 CRYPTO_cbc128_encrypt(in, out, len, &dat->ks, ctx->iv,
372 dat->block);
373 else
374 CRYPTO_cbc128_decrypt(in, out, len, &dat->ks, ctx->iv,
375 dat->block);
376
377 return 1;
378}
379
380static int
381aes_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 170aes_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
382 const unsigned char *in, size_t len) 171 const unsigned char *in, size_t len)
383{ 172{
384 size_t bl = ctx->cipher->block_size; 173 EVP_AES_KEY *eak = ctx->cipher_data;
385 size_t i;
386 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
387 174
388 if (len < bl) 175 aes_ecb_encrypt_internal(in, out, len, &eak->ks, ctx->encrypt);
389 return 1;
390
391 for (i = 0, len -= bl; i <= len; i += bl)
392 (*dat->block)(in + i, out + i, &dat->ks);
393 176
394 return 1; 177 return 1;
395} 178}
@@ -398,10 +181,10 @@ static int
398aes_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 181aes_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
399 const unsigned char *in, size_t len) 182 const unsigned char *in, size_t len)
400{ 183{
401 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; 184 EVP_AES_KEY *eak = ctx->cipher_data;
185
186 AES_ofb128_encrypt(in, out, len, &eak->ks, ctx->iv, &ctx->num);
402 187
403 CRYPTO_ofb128_encrypt(in, out, len, &dat->ks, ctx->iv, &ctx->num,
404 dat->block);
405 return 1; 188 return 1;
406} 189}
407 190
@@ -409,10 +192,11 @@ static int
409aes_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 192aes_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
410 const unsigned char *in, size_t len) 193 const unsigned char *in, size_t len)
411{ 194{
412 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; 195 EVP_AES_KEY *eak = ctx->cipher_data;
196
197 AES_cfb128_encrypt(in, out, len, &eak->ks, ctx->iv, &ctx->num,
198 ctx->encrypt);
413 199
414 CRYPTO_cfb128_encrypt(in, out, len, &dat->ks, ctx->iv, &ctx->num,
415 ctx->encrypt, dat->block);
416 return 1; 200 return 1;
417} 201}
418 202
@@ -420,10 +204,11 @@ static int
420aes_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 204aes_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
421 const unsigned char *in, size_t len) 205 const unsigned char *in, size_t len)
422{ 206{
423 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; 207 EVP_AES_KEY *eak = ctx->cipher_data;
208
209 AES_cfb8_encrypt(in, out, len, &eak->ks, ctx->iv, &ctx->num,
210 ctx->encrypt);
424 211
425 CRYPTO_cfb128_8_encrypt(in, out, len, &dat->ks, ctx->iv, &ctx->num,
426 ctx->encrypt, dat->block);
427 return 1; 212 return 1;
428} 213}
429 214
@@ -431,24 +216,25 @@ static int
431aes_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 216aes_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
432 const unsigned char *in, size_t len) 217 const unsigned char *in, size_t len)
433{ 218{
434 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; 219 EVP_AES_KEY *eak = ctx->cipher_data;
435 220
436 if (ctx->flags&EVP_CIPH_FLAG_LENGTH_BITS) { 221 if ((ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) != 0) {
437 CRYPTO_cfb128_1_encrypt(in, out, len, &dat->ks, ctx->iv, 222 AES_cfb1_encrypt(in, out, len, &eak->ks, ctx->iv, &ctx->num,
438 &ctx->num, ctx->encrypt, dat->block); 223 ctx->encrypt);
439 return 1; 224 return 1;
440 } 225 }
441 226
442 while (len >= MAXBITCHUNK) { 227 while (len >= MAXBITCHUNK) {
443 CRYPTO_cfb128_1_encrypt(in, out, MAXBITCHUNK*8, &dat->ks, 228 AES_cfb1_encrypt(in, out, MAXBITCHUNK * 8, &eak->ks, ctx->iv,
444 ctx->iv, &ctx->num, ctx->encrypt, dat->block); 229 &ctx->num, ctx->encrypt);
445 len -= MAXBITCHUNK; 230 len -= MAXBITCHUNK;
446 in += MAXBITCHUNK; 231 in += MAXBITCHUNK;
447 out += MAXBITCHUNK; 232 out += MAXBITCHUNK;
448 } 233 }
449 if (len) 234 if (len > 0) {
450 CRYPTO_cfb128_1_encrypt(in, out, len*8, &dat->ks, 235 AES_cfb1_encrypt(in, out, len * 8, &eak->ks, ctx->iv, &ctx->num,
451 ctx->iv, &ctx->num, ctx->encrypt, dat->block); 236 ctx->encrypt);
237 }
452 238
453 return 1; 239 return 1;
454} 240}
@@ -457,40 +243,23 @@ static int
457aes_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 243aes_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
458 const unsigned char *in, size_t len) 244 const unsigned char *in, size_t len)
459{ 245{
246 EVP_AES_KEY *eak = ctx->cipher_data;
460 unsigned int num = ctx->num; 247 unsigned int num = ctx->num;
461 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
462 248
463 if (dat->stream.ctr) 249 AES_ctr128_encrypt(in, out, len, &eak->ks, ctx->iv, ctx->buf, &num);
464 CRYPTO_ctr128_encrypt_ctr32(in, out, len, &dat->ks, 250
465 ctx->iv, ctx->buf, &num, dat->stream.ctr);
466 else
467 CRYPTO_ctr128_encrypt(in, out, len, &dat->ks,
468 ctx->iv, ctx->buf, &num, dat->block);
469 ctx->num = (size_t)num; 251 ctx->num = (size_t)num;
252
470 return 1; 253 return 1;
471} 254}
472 255
473
474#ifdef AESNI_CAPABLE
475static const EVP_CIPHER aesni_128_cbc = {
476 .nid = NID_aes_128_cbc,
477 .block_size = 16,
478 .key_len = 16,
479 .iv_len = 16,
480 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE,
481 .init = aesni_init_key,
482 .do_cipher = aesni_cbc_cipher,
483 .ctx_size = sizeof(EVP_AES_KEY),
484};
485#endif
486
487static const EVP_CIPHER aes_128_cbc = { 256static const EVP_CIPHER aes_128_cbc = {
488 .nid = NID_aes_128_cbc, 257 .nid = NID_aes_128_cbc,
489 .block_size = 16, 258 .block_size = 16,
490 .key_len = 16, 259 .key_len = 16,
491 .iv_len = 16, 260 .iv_len = 16,
492 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE, 261 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE,
493 .init = aes_init_key, 262 .init = aes_cbc_init_key,
494 .do_cipher = aes_cbc_cipher, 263 .do_cipher = aes_cbc_cipher,
495 .ctx_size = sizeof(EVP_AES_KEY), 264 .ctx_size = sizeof(EVP_AES_KEY),
496}; 265};
@@ -498,34 +267,17 @@ static const EVP_CIPHER aes_128_cbc = {
498const EVP_CIPHER * 267const EVP_CIPHER *
499EVP_aes_128_cbc(void) 268EVP_aes_128_cbc(void)
500{ 269{
501#ifdef AESNI_CAPABLE
502 return AESNI_CAPABLE ? &aesni_128_cbc : &aes_128_cbc;
503#else
504 return &aes_128_cbc; 270 return &aes_128_cbc;
505#endif
506} 271}
507LCRYPTO_ALIAS(EVP_aes_128_cbc); 272LCRYPTO_ALIAS(EVP_aes_128_cbc);
508 273
509#ifdef AESNI_CAPABLE
510static const EVP_CIPHER aesni_128_ecb = {
511 .nid = NID_aes_128_ecb,
512 .block_size = 16,
513 .key_len = 16,
514 .iv_len = 0,
515 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE,
516 .init = aesni_init_key,
517 .do_cipher = aesni_ecb_cipher,
518 .ctx_size = sizeof(EVP_AES_KEY),
519};
520#endif
521
522static const EVP_CIPHER aes_128_ecb = { 274static const EVP_CIPHER aes_128_ecb = {
523 .nid = NID_aes_128_ecb, 275 .nid = NID_aes_128_ecb,
524 .block_size = 16, 276 .block_size = 16,
525 .key_len = 16, 277 .key_len = 16,
526 .iv_len = 0, 278 .iv_len = 0,
527 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE, 279 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE,
528 .init = aes_init_key, 280 .init = aes_ecb_init_key,
529 .do_cipher = aes_ecb_cipher, 281 .do_cipher = aes_ecb_cipher,
530 .ctx_size = sizeof(EVP_AES_KEY), 282 .ctx_size = sizeof(EVP_AES_KEY),
531}; 283};
@@ -533,27 +285,10 @@ static const EVP_CIPHER aes_128_ecb = {
533const EVP_CIPHER * 285const EVP_CIPHER *
534EVP_aes_128_ecb(void) 286EVP_aes_128_ecb(void)
535{ 287{
536#ifdef AESNI_CAPABLE
537 return AESNI_CAPABLE ? &aesni_128_ecb : &aes_128_ecb;
538#else
539 return &aes_128_ecb; 288 return &aes_128_ecb;
540#endif
541} 289}
542LCRYPTO_ALIAS(EVP_aes_128_ecb); 290LCRYPTO_ALIAS(EVP_aes_128_ecb);
543 291
544#ifdef AESNI_CAPABLE
545static const EVP_CIPHER aesni_128_ofb = {
546 .nid = NID_aes_128_ofb128,
547 .block_size = 1,
548 .key_len = 16,
549 .iv_len = 16,
550 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE,
551 .init = aesni_init_key,
552 .do_cipher = aes_ofb_cipher,
553 .ctx_size = sizeof(EVP_AES_KEY),
554};
555#endif
556
557static const EVP_CIPHER aes_128_ofb = { 292static const EVP_CIPHER aes_128_ofb = {
558 .nid = NID_aes_128_ofb128, 293 .nid = NID_aes_128_ofb128,
559 .block_size = 1, 294 .block_size = 1,
@@ -568,27 +303,10 @@ static const EVP_CIPHER aes_128_ofb = {
568const EVP_CIPHER * 303const EVP_CIPHER *
569EVP_aes_128_ofb(void) 304EVP_aes_128_ofb(void)
570{ 305{
571#ifdef AESNI_CAPABLE
572 return AESNI_CAPABLE ? &aesni_128_ofb : &aes_128_ofb;
573#else
574 return &aes_128_ofb; 306 return &aes_128_ofb;
575#endif
576} 307}
577LCRYPTO_ALIAS(EVP_aes_128_ofb); 308LCRYPTO_ALIAS(EVP_aes_128_ofb);
578 309
579#ifdef AESNI_CAPABLE
580static const EVP_CIPHER aesni_128_cfb = {
581 .nid = NID_aes_128_cfb128,
582 .block_size = 1,
583 .key_len = 16,
584 .iv_len = 16,
585 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE,
586 .init = aesni_init_key,
587 .do_cipher = aes_cfb_cipher,
588 .ctx_size = sizeof(EVP_AES_KEY),
589};
590#endif
591
592static const EVP_CIPHER aes_128_cfb = { 310static const EVP_CIPHER aes_128_cfb = {
593 .nid = NID_aes_128_cfb128, 311 .nid = NID_aes_128_cfb128,
594 .block_size = 1, 312 .block_size = 1,
@@ -603,27 +321,10 @@ static const EVP_CIPHER aes_128_cfb = {
603const EVP_CIPHER * 321const EVP_CIPHER *
604EVP_aes_128_cfb128(void) 322EVP_aes_128_cfb128(void)
605{ 323{
606#ifdef AESNI_CAPABLE
607 return AESNI_CAPABLE ? &aesni_128_cfb : &aes_128_cfb;
608#else
609 return &aes_128_cfb; 324 return &aes_128_cfb;
610#endif
611} 325}
612LCRYPTO_ALIAS(EVP_aes_128_cfb128); 326LCRYPTO_ALIAS(EVP_aes_128_cfb128);
613 327
614#ifdef AESNI_CAPABLE
615static const EVP_CIPHER aesni_128_cfb1 = {
616 .nid = NID_aes_128_cfb1,
617 .block_size = 1,
618 .key_len = 16,
619 .iv_len = 16,
620 .flags = EVP_CIPH_CFB_MODE,
621 .init = aesni_init_key,
622 .do_cipher = aes_cfb1_cipher,
623 .ctx_size = sizeof(EVP_AES_KEY),
624};
625#endif
626
627static const EVP_CIPHER aes_128_cfb1 = { 328static const EVP_CIPHER aes_128_cfb1 = {
628 .nid = NID_aes_128_cfb1, 329 .nid = NID_aes_128_cfb1,
629 .block_size = 1, 330 .block_size = 1,
@@ -638,27 +339,10 @@ static const EVP_CIPHER aes_128_cfb1 = {
638const EVP_CIPHER * 339const EVP_CIPHER *
639EVP_aes_128_cfb1(void) 340EVP_aes_128_cfb1(void)
640{ 341{
641#ifdef AESNI_CAPABLE
642 return AESNI_CAPABLE ? &aesni_128_cfb1 : &aes_128_cfb1;
643#else
644 return &aes_128_cfb1; 342 return &aes_128_cfb1;
645#endif
646} 343}
647LCRYPTO_ALIAS(EVP_aes_128_cfb1); 344LCRYPTO_ALIAS(EVP_aes_128_cfb1);
648 345
649#ifdef AESNI_CAPABLE
650static const EVP_CIPHER aesni_128_cfb8 = {
651 .nid = NID_aes_128_cfb8,
652 .block_size = 1,
653 .key_len = 16,
654 .iv_len = 16,
655 .flags = EVP_CIPH_CFB_MODE,
656 .init = aesni_init_key,
657 .do_cipher = aes_cfb8_cipher,
658 .ctx_size = sizeof(EVP_AES_KEY),
659};
660#endif
661
662static const EVP_CIPHER aes_128_cfb8 = { 346static const EVP_CIPHER aes_128_cfb8 = {
663 .nid = NID_aes_128_cfb8, 347 .nid = NID_aes_128_cfb8,
664 .block_size = 1, 348 .block_size = 1,
@@ -673,27 +357,10 @@ static const EVP_CIPHER aes_128_cfb8 = {
673const EVP_CIPHER * 357const EVP_CIPHER *
674EVP_aes_128_cfb8(void) 358EVP_aes_128_cfb8(void)
675{ 359{
676#ifdef AESNI_CAPABLE
677 return AESNI_CAPABLE ? &aesni_128_cfb8 : &aes_128_cfb8;
678#else
679 return &aes_128_cfb8; 360 return &aes_128_cfb8;
680#endif
681} 361}
682LCRYPTO_ALIAS(EVP_aes_128_cfb8); 362LCRYPTO_ALIAS(EVP_aes_128_cfb8);
683 363
684#ifdef AESNI_CAPABLE
685static const EVP_CIPHER aesni_128_ctr = {
686 .nid = NID_aes_128_ctr,
687 .block_size = 1,
688 .key_len = 16,
689 .iv_len = 16,
690 .flags = EVP_CIPH_CTR_MODE,
691 .init = aesni_init_key,
692 .do_cipher = aes_ctr_cipher,
693 .ctx_size = sizeof(EVP_AES_KEY),
694};
695#endif
696
697static const EVP_CIPHER aes_128_ctr = { 364static const EVP_CIPHER aes_128_ctr = {
698 .nid = NID_aes_128_ctr, 365 .nid = NID_aes_128_ctr,
699 .block_size = 1, 366 .block_size = 1,
@@ -708,35 +375,17 @@ static const EVP_CIPHER aes_128_ctr = {
708const EVP_CIPHER * 375const EVP_CIPHER *
709EVP_aes_128_ctr(void) 376EVP_aes_128_ctr(void)
710{ 377{
711#ifdef AESNI_CAPABLE
712 return AESNI_CAPABLE ? &aesni_128_ctr : &aes_128_ctr;
713#else
714 return &aes_128_ctr; 378 return &aes_128_ctr;
715#endif
716} 379}
717LCRYPTO_ALIAS(EVP_aes_128_ctr); 380LCRYPTO_ALIAS(EVP_aes_128_ctr);
718 381
719
720#ifdef AESNI_CAPABLE
721static const EVP_CIPHER aesni_192_cbc = {
722 .nid = NID_aes_192_cbc,
723 .block_size = 16,
724 .key_len = 24,
725 .iv_len = 16,
726 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE,
727 .init = aesni_init_key,
728 .do_cipher = aesni_cbc_cipher,
729 .ctx_size = sizeof(EVP_AES_KEY),
730};
731#endif
732
733static const EVP_CIPHER aes_192_cbc = { 382static const EVP_CIPHER aes_192_cbc = {
734 .nid = NID_aes_192_cbc, 383 .nid = NID_aes_192_cbc,
735 .block_size = 16, 384 .block_size = 16,
736 .key_len = 24, 385 .key_len = 24,
737 .iv_len = 16, 386 .iv_len = 16,
738 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE, 387 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE,
739 .init = aes_init_key, 388 .init = aes_cbc_init_key,
740 .do_cipher = aes_cbc_cipher, 389 .do_cipher = aes_cbc_cipher,
741 .ctx_size = sizeof(EVP_AES_KEY), 390 .ctx_size = sizeof(EVP_AES_KEY),
742}; 391};
@@ -744,34 +393,17 @@ static const EVP_CIPHER aes_192_cbc = {
744const EVP_CIPHER * 393const EVP_CIPHER *
745EVP_aes_192_cbc(void) 394EVP_aes_192_cbc(void)
746{ 395{
747#ifdef AESNI_CAPABLE
748 return AESNI_CAPABLE ? &aesni_192_cbc : &aes_192_cbc;
749#else
750 return &aes_192_cbc; 396 return &aes_192_cbc;
751#endif
752} 397}
753LCRYPTO_ALIAS(EVP_aes_192_cbc); 398LCRYPTO_ALIAS(EVP_aes_192_cbc);
754 399
755#ifdef AESNI_CAPABLE
756static const EVP_CIPHER aesni_192_ecb = {
757 .nid = NID_aes_192_ecb,
758 .block_size = 16,
759 .key_len = 24,
760 .iv_len = 0,
761 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE,
762 .init = aesni_init_key,
763 .do_cipher = aesni_ecb_cipher,
764 .ctx_size = sizeof(EVP_AES_KEY),
765};
766#endif
767
768static const EVP_CIPHER aes_192_ecb = { 400static const EVP_CIPHER aes_192_ecb = {
769 .nid = NID_aes_192_ecb, 401 .nid = NID_aes_192_ecb,
770 .block_size = 16, 402 .block_size = 16,
771 .key_len = 24, 403 .key_len = 24,
772 .iv_len = 0, 404 .iv_len = 0,
773 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE, 405 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE,
774 .init = aes_init_key, 406 .init = aes_ecb_init_key,
775 .do_cipher = aes_ecb_cipher, 407 .do_cipher = aes_ecb_cipher,
776 .ctx_size = sizeof(EVP_AES_KEY), 408 .ctx_size = sizeof(EVP_AES_KEY),
777}; 409};
@@ -779,27 +411,10 @@ static const EVP_CIPHER aes_192_ecb = {
779const EVP_CIPHER * 411const EVP_CIPHER *
780EVP_aes_192_ecb(void) 412EVP_aes_192_ecb(void)
781{ 413{
782#ifdef AESNI_CAPABLE
783 return AESNI_CAPABLE ? &aesni_192_ecb : &aes_192_ecb;
784#else
785 return &aes_192_ecb; 414 return &aes_192_ecb;
786#endif
787} 415}
788LCRYPTO_ALIAS(EVP_aes_192_ecb); 416LCRYPTO_ALIAS(EVP_aes_192_ecb);
789 417
790#ifdef AESNI_CAPABLE
791static const EVP_CIPHER aesni_192_ofb = {
792 .nid = NID_aes_192_ofb128,
793 .block_size = 1,
794 .key_len = 24,
795 .iv_len = 16,
796 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE,
797 .init = aesni_init_key,
798 .do_cipher = aes_ofb_cipher,
799 .ctx_size = sizeof(EVP_AES_KEY),
800};
801#endif
802
803static const EVP_CIPHER aes_192_ofb = { 418static const EVP_CIPHER aes_192_ofb = {
804 .nid = NID_aes_192_ofb128, 419 .nid = NID_aes_192_ofb128,
805 .block_size = 1, 420 .block_size = 1,
@@ -814,27 +429,10 @@ static const EVP_CIPHER aes_192_ofb = {
814const EVP_CIPHER * 429const EVP_CIPHER *
815EVP_aes_192_ofb(void) 430EVP_aes_192_ofb(void)
816{ 431{
817#ifdef AESNI_CAPABLE
818 return AESNI_CAPABLE ? &aesni_192_ofb : &aes_192_ofb;
819#else
820 return &aes_192_ofb; 432 return &aes_192_ofb;
821#endif
822} 433}
823LCRYPTO_ALIAS(EVP_aes_192_ofb); 434LCRYPTO_ALIAS(EVP_aes_192_ofb);
824 435
825#ifdef AESNI_CAPABLE
826static const EVP_CIPHER aesni_192_cfb = {
827 .nid = NID_aes_192_cfb128,
828 .block_size = 1,
829 .key_len = 24,
830 .iv_len = 16,
831 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE,
832 .init = aesni_init_key,
833 .do_cipher = aes_cfb_cipher,
834 .ctx_size = sizeof(EVP_AES_KEY),
835};
836#endif
837
838static const EVP_CIPHER aes_192_cfb = { 436static const EVP_CIPHER aes_192_cfb = {
839 .nid = NID_aes_192_cfb128, 437 .nid = NID_aes_192_cfb128,
840 .block_size = 1, 438 .block_size = 1,
@@ -849,27 +447,10 @@ static const EVP_CIPHER aes_192_cfb = {
849const EVP_CIPHER * 447const EVP_CIPHER *
850EVP_aes_192_cfb128(void) 448EVP_aes_192_cfb128(void)
851{ 449{
852#ifdef AESNI_CAPABLE
853 return AESNI_CAPABLE ? &aesni_192_cfb : &aes_192_cfb;
854#else
855 return &aes_192_cfb; 450 return &aes_192_cfb;
856#endif
857} 451}
858LCRYPTO_ALIAS(EVP_aes_192_cfb128); 452LCRYPTO_ALIAS(EVP_aes_192_cfb128);
859 453
860#ifdef AESNI_CAPABLE
861static const EVP_CIPHER aesni_192_cfb1 = {
862 .nid = NID_aes_192_cfb1,
863 .block_size = 1,
864 .key_len = 24,
865 .iv_len = 16,
866 .flags = EVP_CIPH_CFB_MODE,
867 .init = aesni_init_key,
868 .do_cipher = aes_cfb1_cipher,
869 .ctx_size = sizeof(EVP_AES_KEY),
870};
871#endif
872
873static const EVP_CIPHER aes_192_cfb1 = { 454static const EVP_CIPHER aes_192_cfb1 = {
874 .nid = NID_aes_192_cfb1, 455 .nid = NID_aes_192_cfb1,
875 .block_size = 1, 456 .block_size = 1,
@@ -884,27 +465,10 @@ static const EVP_CIPHER aes_192_cfb1 = {
884const EVP_CIPHER * 465const EVP_CIPHER *
885EVP_aes_192_cfb1(void) 466EVP_aes_192_cfb1(void)
886{ 467{
887#ifdef AESNI_CAPABLE
888 return AESNI_CAPABLE ? &aesni_192_cfb1 : &aes_192_cfb1;
889#else
890 return &aes_192_cfb1; 468 return &aes_192_cfb1;
891#endif
892} 469}
893LCRYPTO_ALIAS(EVP_aes_192_cfb1); 470LCRYPTO_ALIAS(EVP_aes_192_cfb1);
894 471
895#ifdef AESNI_CAPABLE
896static const EVP_CIPHER aesni_192_cfb8 = {
897 .nid = NID_aes_192_cfb8,
898 .block_size = 1,
899 .key_len = 24,
900 .iv_len = 16,
901 .flags = EVP_CIPH_CFB_MODE,
902 .init = aesni_init_key,
903 .do_cipher = aes_cfb8_cipher,
904 .ctx_size = sizeof(EVP_AES_KEY),
905};
906#endif
907
908static const EVP_CIPHER aes_192_cfb8 = { 472static const EVP_CIPHER aes_192_cfb8 = {
909 .nid = NID_aes_192_cfb8, 473 .nid = NID_aes_192_cfb8,
910 .block_size = 1, 474 .block_size = 1,
@@ -919,27 +483,10 @@ static const EVP_CIPHER aes_192_cfb8 = {
919const EVP_CIPHER * 483const EVP_CIPHER *
920EVP_aes_192_cfb8(void) 484EVP_aes_192_cfb8(void)
921{ 485{
922#ifdef AESNI_CAPABLE
923 return AESNI_CAPABLE ? &aesni_192_cfb8 : &aes_192_cfb8;
924#else
925 return &aes_192_cfb8; 486 return &aes_192_cfb8;
926#endif
927} 487}
928LCRYPTO_ALIAS(EVP_aes_192_cfb8); 488LCRYPTO_ALIAS(EVP_aes_192_cfb8);
929 489
930#ifdef AESNI_CAPABLE
931static const EVP_CIPHER aesni_192_ctr = {
932 .nid = NID_aes_192_ctr,
933 .block_size = 1,
934 .key_len = 24,
935 .iv_len = 16,
936 .flags = EVP_CIPH_CTR_MODE,
937 .init = aesni_init_key,
938 .do_cipher = aes_ctr_cipher,
939 .ctx_size = sizeof(EVP_AES_KEY),
940};
941#endif
942
943static const EVP_CIPHER aes_192_ctr = { 490static const EVP_CIPHER aes_192_ctr = {
944 .nid = NID_aes_192_ctr, 491 .nid = NID_aes_192_ctr,
945 .block_size = 1, 492 .block_size = 1,
@@ -954,35 +501,17 @@ static const EVP_CIPHER aes_192_ctr = {
954const EVP_CIPHER * 501const EVP_CIPHER *
955EVP_aes_192_ctr(void) 502EVP_aes_192_ctr(void)
956{ 503{
957#ifdef AESNI_CAPABLE
958 return AESNI_CAPABLE ? &aesni_192_ctr : &aes_192_ctr;
959#else
960 return &aes_192_ctr; 504 return &aes_192_ctr;
961#endif
962} 505}
963LCRYPTO_ALIAS(EVP_aes_192_ctr); 506LCRYPTO_ALIAS(EVP_aes_192_ctr);
964 507
965
966#ifdef AESNI_CAPABLE
967static const EVP_CIPHER aesni_256_cbc = {
968 .nid = NID_aes_256_cbc,
969 .block_size = 16,
970 .key_len = 32,
971 .iv_len = 16,
972 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE,
973 .init = aesni_init_key,
974 .do_cipher = aesni_cbc_cipher,
975 .ctx_size = sizeof(EVP_AES_KEY),
976};
977#endif
978
979static const EVP_CIPHER aes_256_cbc = { 508static const EVP_CIPHER aes_256_cbc = {
980 .nid = NID_aes_256_cbc, 509 .nid = NID_aes_256_cbc,
981 .block_size = 16, 510 .block_size = 16,
982 .key_len = 32, 511 .key_len = 32,
983 .iv_len = 16, 512 .iv_len = 16,
984 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE, 513 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CBC_MODE,
985 .init = aes_init_key, 514 .init = aes_cbc_init_key,
986 .do_cipher = aes_cbc_cipher, 515 .do_cipher = aes_cbc_cipher,
987 .ctx_size = sizeof(EVP_AES_KEY), 516 .ctx_size = sizeof(EVP_AES_KEY),
988}; 517};
@@ -990,34 +519,17 @@ static const EVP_CIPHER aes_256_cbc = {
990const EVP_CIPHER * 519const EVP_CIPHER *
991EVP_aes_256_cbc(void) 520EVP_aes_256_cbc(void)
992{ 521{
993#ifdef AESNI_CAPABLE
994 return AESNI_CAPABLE ? &aesni_256_cbc : &aes_256_cbc;
995#else
996 return &aes_256_cbc; 522 return &aes_256_cbc;
997#endif
998} 523}
999LCRYPTO_ALIAS(EVP_aes_256_cbc); 524LCRYPTO_ALIAS(EVP_aes_256_cbc);
1000 525
1001#ifdef AESNI_CAPABLE
1002static const EVP_CIPHER aesni_256_ecb = {
1003 .nid = NID_aes_256_ecb,
1004 .block_size = 16,
1005 .key_len = 32,
1006 .iv_len = 0,
1007 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE,
1008 .init = aesni_init_key,
1009 .do_cipher = aesni_ecb_cipher,
1010 .ctx_size = sizeof(EVP_AES_KEY),
1011};
1012#endif
1013
1014static const EVP_CIPHER aes_256_ecb = { 526static const EVP_CIPHER aes_256_ecb = {
1015 .nid = NID_aes_256_ecb, 527 .nid = NID_aes_256_ecb,
1016 .block_size = 16, 528 .block_size = 16,
1017 .key_len = 32, 529 .key_len = 32,
1018 .iv_len = 0, 530 .iv_len = 0,
1019 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE, 531 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_ECB_MODE,
1020 .init = aes_init_key, 532 .init = aes_ecb_init_key,
1021 .do_cipher = aes_ecb_cipher, 533 .do_cipher = aes_ecb_cipher,
1022 .ctx_size = sizeof(EVP_AES_KEY), 534 .ctx_size = sizeof(EVP_AES_KEY),
1023}; 535};
@@ -1025,27 +537,10 @@ static const EVP_CIPHER aes_256_ecb = {
1025const EVP_CIPHER * 537const EVP_CIPHER *
1026EVP_aes_256_ecb(void) 538EVP_aes_256_ecb(void)
1027{ 539{
1028#ifdef AESNI_CAPABLE
1029 return AESNI_CAPABLE ? &aesni_256_ecb : &aes_256_ecb;
1030#else
1031 return &aes_256_ecb; 540 return &aes_256_ecb;
1032#endif
1033} 541}
1034LCRYPTO_ALIAS(EVP_aes_256_ecb); 542LCRYPTO_ALIAS(EVP_aes_256_ecb);
1035 543
1036#ifdef AESNI_CAPABLE
1037static const EVP_CIPHER aesni_256_ofb = {
1038 .nid = NID_aes_256_ofb128,
1039 .block_size = 1,
1040 .key_len = 32,
1041 .iv_len = 16,
1042 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE,
1043 .init = aesni_init_key,
1044 .do_cipher = aes_ofb_cipher,
1045 .ctx_size = sizeof(EVP_AES_KEY),
1046};
1047#endif
1048
1049static const EVP_CIPHER aes_256_ofb = { 544static const EVP_CIPHER aes_256_ofb = {
1050 .nid = NID_aes_256_ofb128, 545 .nid = NID_aes_256_ofb128,
1051 .block_size = 1, 546 .block_size = 1,
@@ -1060,27 +555,10 @@ static const EVP_CIPHER aes_256_ofb = {
1060const EVP_CIPHER * 555const EVP_CIPHER *
1061EVP_aes_256_ofb(void) 556EVP_aes_256_ofb(void)
1062{ 557{
1063#ifdef AESNI_CAPABLE
1064 return AESNI_CAPABLE ? &aesni_256_ofb : &aes_256_ofb;
1065#else
1066 return &aes_256_ofb; 558 return &aes_256_ofb;
1067#endif
1068} 559}
1069LCRYPTO_ALIAS(EVP_aes_256_ofb); 560LCRYPTO_ALIAS(EVP_aes_256_ofb);
1070 561
1071#ifdef AESNI_CAPABLE
1072static const EVP_CIPHER aesni_256_cfb = {
1073 .nid = NID_aes_256_cfb128,
1074 .block_size = 1,
1075 .key_len = 32,
1076 .iv_len = 16,
1077 .flags = EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE,
1078 .init = aesni_init_key,
1079 .do_cipher = aes_cfb_cipher,
1080 .ctx_size = sizeof(EVP_AES_KEY),
1081};
1082#endif
1083
1084static const EVP_CIPHER aes_256_cfb = { 562static const EVP_CIPHER aes_256_cfb = {
1085 .nid = NID_aes_256_cfb128, 563 .nid = NID_aes_256_cfb128,
1086 .block_size = 1, 564 .block_size = 1,
@@ -1095,27 +573,10 @@ static const EVP_CIPHER aes_256_cfb = {
1095const EVP_CIPHER * 573const EVP_CIPHER *
1096EVP_aes_256_cfb128(void) 574EVP_aes_256_cfb128(void)
1097{ 575{
1098#ifdef AESNI_CAPABLE
1099 return AESNI_CAPABLE ? &aesni_256_cfb : &aes_256_cfb;
1100#else
1101 return &aes_256_cfb; 576 return &aes_256_cfb;
1102#endif
1103} 577}
1104LCRYPTO_ALIAS(EVP_aes_256_cfb128); 578LCRYPTO_ALIAS(EVP_aes_256_cfb128);
1105 579
1106#ifdef AESNI_CAPABLE
1107static const EVP_CIPHER aesni_256_cfb1 = {
1108 .nid = NID_aes_256_cfb1,
1109 .block_size = 1,
1110 .key_len = 32,
1111 .iv_len = 16,
1112 .flags = EVP_CIPH_CFB_MODE,
1113 .init = aesni_init_key,
1114 .do_cipher = aes_cfb1_cipher,
1115 .ctx_size = sizeof(EVP_AES_KEY),
1116};
1117#endif
1118
1119static const EVP_CIPHER aes_256_cfb1 = { 580static const EVP_CIPHER aes_256_cfb1 = {
1120 .nid = NID_aes_256_cfb1, 581 .nid = NID_aes_256_cfb1,
1121 .block_size = 1, 582 .block_size = 1,
@@ -1130,27 +591,10 @@ static const EVP_CIPHER aes_256_cfb1 = {
1130const EVP_CIPHER * 591const EVP_CIPHER *
1131EVP_aes_256_cfb1(void) 592EVP_aes_256_cfb1(void)
1132{ 593{
1133#ifdef AESNI_CAPABLE
1134 return AESNI_CAPABLE ? &aesni_256_cfb1 : &aes_256_cfb1;
1135#else
1136 return &aes_256_cfb1; 594 return &aes_256_cfb1;
1137#endif
1138} 595}
1139LCRYPTO_ALIAS(EVP_aes_256_cfb1); 596LCRYPTO_ALIAS(EVP_aes_256_cfb1);
1140 597
1141#ifdef AESNI_CAPABLE
1142static const EVP_CIPHER aesni_256_cfb8 = {
1143 .nid = NID_aes_256_cfb8,
1144 .block_size = 1,
1145 .key_len = 32,
1146 .iv_len = 16,
1147 .flags = EVP_CIPH_CFB_MODE,
1148 .init = aesni_init_key,
1149 .do_cipher = aes_cfb8_cipher,
1150 .ctx_size = sizeof(EVP_AES_KEY),
1151};
1152#endif
1153
1154static const EVP_CIPHER aes_256_cfb8 = { 598static const EVP_CIPHER aes_256_cfb8 = {
1155 .nid = NID_aes_256_cfb8, 599 .nid = NID_aes_256_cfb8,
1156 .block_size = 1, 600 .block_size = 1,
@@ -1165,27 +609,10 @@ static const EVP_CIPHER aes_256_cfb8 = {
1165const EVP_CIPHER * 609const EVP_CIPHER *
1166EVP_aes_256_cfb8(void) 610EVP_aes_256_cfb8(void)
1167{ 611{
1168#ifdef AESNI_CAPABLE
1169 return AESNI_CAPABLE ? &aesni_256_cfb8 : &aes_256_cfb8;
1170#else
1171 return &aes_256_cfb8; 612 return &aes_256_cfb8;
1172#endif
1173} 613}
1174LCRYPTO_ALIAS(EVP_aes_256_cfb8); 614LCRYPTO_ALIAS(EVP_aes_256_cfb8);
1175 615
1176#ifdef AESNI_CAPABLE
1177static const EVP_CIPHER aesni_256_ctr = {
1178 .nid = NID_aes_256_ctr,
1179 .block_size = 1,
1180 .key_len = 32,
1181 .iv_len = 16,
1182 .flags = EVP_CIPH_CTR_MODE,
1183 .init = aesni_init_key,
1184 .do_cipher = aes_ctr_cipher,
1185 .ctx_size = sizeof(EVP_AES_KEY),
1186};
1187#endif
1188
1189static const EVP_CIPHER aes_256_ctr = { 616static const EVP_CIPHER aes_256_ctr = {
1190 .nid = NID_aes_256_ctr, 617 .nid = NID_aes_256_ctr,
1191 .block_size = 1, 618 .block_size = 1,
@@ -1200,11 +627,7 @@ static const EVP_CIPHER aes_256_ctr = {
1200const EVP_CIPHER * 627const EVP_CIPHER *
1201EVP_aes_256_ctr(void) 628EVP_aes_256_ctr(void)
1202{ 629{
1203#ifdef AESNI_CAPABLE
1204 return AESNI_CAPABLE ? &aesni_256_ctr : &aes_256_ctr;
1205#else
1206 return &aes_256_ctr; 630 return &aes_256_ctr;
1207#endif
1208} 631}
1209LCRYPTO_ALIAS(EVP_aes_256_ctr); 632LCRYPTO_ALIAS(EVP_aes_256_ctr);
1210 633
@@ -1385,19 +808,6 @@ aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
1385 } 808 }
1386} 809}
1387 810
1388static ctr128_f
1389aes_gcm_set_key(AES_KEY *aes_key, GCM128_CONTEXT *gcm_ctx,
1390 const unsigned char *key, size_t key_len)
1391{
1392 AES_set_encrypt_key(key, key_len * 8, aes_key);
1393 CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)AES_encrypt);
1394#ifdef AES_CTR_ASM
1395 return (ctr128_f)AES_ctr32_encrypt;
1396#else
1397 return NULL;
1398#endif
1399}
1400
1401static int 811static int
1402aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 812aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
1403 const unsigned char *iv, int enc) 813 const unsigned char *iv, int enc)
@@ -1407,8 +817,8 @@ aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
1407 if (!iv && !key) 817 if (!iv && !key)
1408 return 1; 818 return 1;
1409 if (key) { 819 if (key) {
1410 gctx->ctr = aes_gcm_set_key(&gctx->ks, &gctx->gcm, 820 AES_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks);
1411 key, ctx->key_len); 821 CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, aes_encrypt_block128);
1412 822
1413 /* If we have an iv can set it directly, otherwise use 823 /* If we have an iv can set it directly, otherwise use
1414 * saved IV. 824 * saved IV.
@@ -1468,14 +878,9 @@ aes_gcm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1468 len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN; 878 len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN;
1469 if (ctx->encrypt) { 879 if (ctx->encrypt) {
1470 /* Encrypt payload */ 880 /* Encrypt payload */
1471 if (gctx->ctr) { 881 if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm, in, out, len,
1472 if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm, in, out, 882 aes_ctr32_encrypt_ctr128f))
1473 len, gctx->ctr)) 883 goto err;
1474 goto err;
1475 } else {
1476 if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, len))
1477 goto err;
1478 }
1479 out += len; 884 out += len;
1480 885
1481 /* Finally write tag */ 886 /* Finally write tag */
@@ -1483,19 +888,15 @@ aes_gcm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1483 rv = len + EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN; 888 rv = len + EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN;
1484 } else { 889 } else {
1485 /* Decrypt */ 890 /* Decrypt */
1486 if (gctx->ctr) { 891 if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm, in, out, len,
1487 if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm, in, out, 892 aes_ctr32_encrypt_ctr128f))
1488 len, gctx->ctr)) 893 goto err;
1489 goto err; 894
1490 } else {
1491 if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, len))
1492 goto err;
1493 }
1494 /* Retrieve tag */ 895 /* Retrieve tag */
1495 CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, EVP_GCM_TLS_TAG_LEN); 896 CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, EVP_GCM_TLS_TAG_LEN);
1496 897
1497 /* If tag mismatch wipe buffer */ 898 /* If tag mismatch wipe buffer */
1498 if (memcmp(ctx->buf, in + len, EVP_GCM_TLS_TAG_LEN)) { 899 if (timingsafe_memcmp(ctx->buf, in + len, EVP_GCM_TLS_TAG_LEN) != 0) {
1499 explicit_bzero(out, len); 900 explicit_bzero(out, len);
1500 goto err; 901 goto err;
1501 } 902 }
@@ -1529,25 +930,13 @@ aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1529 if (CRYPTO_gcm128_aad(&gctx->gcm, in, len)) 930 if (CRYPTO_gcm128_aad(&gctx->gcm, in, len))
1530 return -1; 931 return -1;
1531 } else if (ctx->encrypt) { 932 } else if (ctx->encrypt) {
1532 if (gctx->ctr) { 933 if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm,
1533 if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm, 934 in, out, len, aes_ctr32_encrypt_ctr128f))
1534 in, out, len, gctx->ctr)) 935 return -1;
1535 return -1;
1536 } else {
1537 if (CRYPTO_gcm128_encrypt(&gctx->gcm,
1538 in, out, len))
1539 return -1;
1540 }
1541 } else { 936 } else {
1542 if (gctx->ctr) { 937 if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm,
1543 if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm, 938 in, out, len, aes_ctr32_encrypt_ctr128f))
1544 in, out, len, gctx->ctr)) 939 return -1;
1545 return -1;
1546 } else {
1547 if (CRYPTO_gcm128_decrypt(&gctx->gcm,
1548 in, out, len))
1549 return -1;
1550 }
1551 } 940 }
1552 return len; 941 return len;
1553 } else { 942 } else {
@@ -1576,22 +965,6 @@ aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1576 EVP_CIPH_FLAG_CUSTOM_CIPHER | EVP_CIPH_ALWAYS_CALL_INIT | \ 965 EVP_CIPH_FLAG_CUSTOM_CIPHER | EVP_CIPH_ALWAYS_CALL_INIT | \
1577 EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY ) 966 EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY )
1578 967
1579
1580#ifdef AESNI_CAPABLE
1581static const EVP_CIPHER aesni_128_gcm = {
1582 .nid = NID_aes_128_gcm,
1583 .block_size = 1,
1584 .key_len = 16,
1585 .iv_len = 12,
1586 .flags = EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE,
1587 .init = aesni_gcm_init_key,
1588 .do_cipher = aes_gcm_cipher,
1589 .cleanup = aes_gcm_cleanup,
1590 .ctx_size = sizeof(EVP_AES_GCM_CTX),
1591 .ctrl = aes_gcm_ctrl,
1592};
1593#endif
1594
1595static const EVP_CIPHER aes_128_gcm = { 968static const EVP_CIPHER aes_128_gcm = {
1596 .nid = NID_aes_128_gcm, 969 .nid = NID_aes_128_gcm,
1597 .block_size = 1, 970 .block_size = 1,
@@ -1608,29 +981,10 @@ static const EVP_CIPHER aes_128_gcm = {
1608const EVP_CIPHER * 981const EVP_CIPHER *
1609EVP_aes_128_gcm(void) 982EVP_aes_128_gcm(void)
1610{ 983{
1611#ifdef AESNI_CAPABLE
1612 return AESNI_CAPABLE ? &aesni_128_gcm : &aes_128_gcm;
1613#else
1614 return &aes_128_gcm; 984 return &aes_128_gcm;
1615#endif
1616} 985}
1617LCRYPTO_ALIAS(EVP_aes_128_gcm); 986LCRYPTO_ALIAS(EVP_aes_128_gcm);
1618 987
1619#ifdef AESNI_CAPABLE
1620static const EVP_CIPHER aesni_192_gcm = {
1621 .nid = NID_aes_192_gcm,
1622 .block_size = 1,
1623 .key_len = 24,
1624 .iv_len = 12,
1625 .flags = EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE,
1626 .init = aesni_gcm_init_key,
1627 .do_cipher = aes_gcm_cipher,
1628 .cleanup = aes_gcm_cleanup,
1629 .ctx_size = sizeof(EVP_AES_GCM_CTX),
1630 .ctrl = aes_gcm_ctrl,
1631};
1632#endif
1633
1634static const EVP_CIPHER aes_192_gcm = { 988static const EVP_CIPHER aes_192_gcm = {
1635 .nid = NID_aes_192_gcm, 989 .nid = NID_aes_192_gcm,
1636 .block_size = 1, 990 .block_size = 1,
@@ -1647,29 +1001,10 @@ static const EVP_CIPHER aes_192_gcm = {
1647const EVP_CIPHER * 1001const EVP_CIPHER *
1648EVP_aes_192_gcm(void) 1002EVP_aes_192_gcm(void)
1649{ 1003{
1650#ifdef AESNI_CAPABLE
1651 return AESNI_CAPABLE ? &aesni_192_gcm : &aes_192_gcm;
1652#else
1653 return &aes_192_gcm; 1004 return &aes_192_gcm;
1654#endif
1655} 1005}
1656LCRYPTO_ALIAS(EVP_aes_192_gcm); 1006LCRYPTO_ALIAS(EVP_aes_192_gcm);
1657 1007
1658#ifdef AESNI_CAPABLE
1659static const EVP_CIPHER aesni_256_gcm = {
1660 .nid = NID_aes_256_gcm,
1661 .block_size = 1,
1662 .key_len = 32,
1663 .iv_len = 12,
1664 .flags = EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE,
1665 .init = aesni_gcm_init_key,
1666 .do_cipher = aes_gcm_cipher,
1667 .cleanup = aes_gcm_cleanup,
1668 .ctx_size = sizeof(EVP_AES_GCM_CTX),
1669 .ctrl = aes_gcm_ctrl,
1670};
1671#endif
1672
1673static const EVP_CIPHER aes_256_gcm = { 1008static const EVP_CIPHER aes_256_gcm = {
1674 .nid = NID_aes_256_gcm, 1009 .nid = NID_aes_256_gcm,
1675 .block_size = 1, 1010 .block_size = 1,
@@ -1686,11 +1021,7 @@ static const EVP_CIPHER aes_256_gcm = {
1686const EVP_CIPHER * 1021const EVP_CIPHER *
1687EVP_aes_256_gcm(void) 1022EVP_aes_256_gcm(void)
1688{ 1023{
1689#ifdef AESNI_CAPABLE
1690 return AESNI_CAPABLE ? &aesni_256_gcm : &aes_256_gcm;
1691#else
1692 return &aes_256_gcm; 1024 return &aes_256_gcm;
1693#endif
1694} 1025}
1695LCRYPTO_ALIAS(EVP_aes_256_gcm); 1026LCRYPTO_ALIAS(EVP_aes_256_gcm);
1696 1027
@@ -1732,36 +1063,24 @@ aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
1732 1063
1733static int 1064static int
1734aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 1065aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
1735 const unsigned char *iv, int enc) 1066 const unsigned char *iv, int encrypt)
1736{ 1067{
1737 EVP_AES_XTS_CTX *xctx = ctx->cipher_data; 1068 EVP_AES_XTS_CTX *xctx = ctx->cipher_data;
1738 1069
1739 if (!iv && !key) 1070 if (key != NULL) {
1740 return 1;
1741
1742 if (key) {
1743#ifdef AES_XTS_ASM
1744 xctx->stream = enc ? AES_xts_encrypt : AES_xts_decrypt;
1745#else
1746 xctx->stream = NULL;
1747#endif
1748 /* key_len is two AES keys */ 1071 /* key_len is two AES keys */
1749 if (enc) { 1072 if (encrypt)
1750 AES_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1); 1073 AES_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1);
1751 xctx->xts.block1 = (block128_f)AES_encrypt; 1074 else
1752 } else {
1753 AES_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1); 1075 AES_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1);
1754 xctx->xts.block1 = (block128_f)AES_decrypt;
1755 }
1756 1076
1757 AES_set_encrypt_key(key + ctx->key_len / 2, 1077 AES_set_encrypt_key(key + ctx->key_len / 2, ctx->key_len * 4,
1758 ctx->key_len * 4, &xctx->ks2); 1078 &xctx->ks2);
1759 xctx->xts.block2 = (block128_f)AES_encrypt;
1760 1079
1761 xctx->xts.key1 = &xctx->ks1; 1080 xctx->xts.key1 = &xctx->ks1;
1762 } 1081 }
1763 1082
1764 if (iv) { 1083 if (iv != NULL) {
1765 xctx->xts.key2 = &xctx->ks2; 1084 xctx->xts.key2 = &xctx->ks2;
1766 memcpy(ctx->iv, iv, 16); 1085 memcpy(ctx->iv, iv, 16);
1767 } 1086 }
@@ -1775,17 +1094,15 @@ aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1775{ 1094{
1776 EVP_AES_XTS_CTX *xctx = ctx->cipher_data; 1095 EVP_AES_XTS_CTX *xctx = ctx->cipher_data;
1777 1096
1778 if (!xctx->xts.key1 || !xctx->xts.key2) 1097 if (xctx->xts.key1 == NULL || xctx->xts.key2 == NULL)
1779 return 0;
1780 if (!out || !in || len < AES_BLOCK_SIZE)
1781 return 0; 1098 return 0;
1782 1099
1783 if (xctx->stream) 1100 if (out == NULL || in == NULL || len < AES_BLOCK_SIZE)
1784 (*xctx->stream)(in, out, len, xctx->xts.key1, xctx->xts.key2,
1785 ctx->iv);
1786 else if (CRYPTO_xts128_encrypt(&xctx->xts, ctx->iv, in, out, len,
1787 ctx->encrypt))
1788 return 0; 1101 return 0;
1102
1103 aes_xts_encrypt_internal(in, out, len, xctx->xts.key1, xctx->xts.key2,
1104 ctx->iv, ctx->encrypt);
1105
1789 return 1; 1106 return 1;
1790} 1107}
1791 1108
@@ -1793,22 +1110,6 @@ aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1793 ( EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV | \ 1110 ( EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV | \
1794 EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY ) 1111 EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY )
1795 1112
1796
1797#ifdef AESNI_CAPABLE
1798static const EVP_CIPHER aesni_128_xts = {
1799 .nid = NID_aes_128_xts,
1800 .block_size = 1,
1801 .key_len = 2 * 16,
1802 .iv_len = 16,
1803 .flags = XTS_FLAGS | EVP_CIPH_XTS_MODE,
1804 .init = aesni_xts_init_key,
1805 .do_cipher = aes_xts_cipher,
1806 .cleanup = NULL,
1807 .ctx_size = sizeof(EVP_AES_XTS_CTX),
1808 .ctrl = aes_xts_ctrl,
1809};
1810#endif
1811
1812static const EVP_CIPHER aes_128_xts = { 1113static const EVP_CIPHER aes_128_xts = {
1813 .nid = NID_aes_128_xts, 1114 .nid = NID_aes_128_xts,
1814 .block_size = 1, 1115 .block_size = 1,
@@ -1825,29 +1126,10 @@ static const EVP_CIPHER aes_128_xts = {
1825const EVP_CIPHER * 1126const EVP_CIPHER *
1826EVP_aes_128_xts(void) 1127EVP_aes_128_xts(void)
1827{ 1128{
1828#ifdef AESNI_CAPABLE
1829 return AESNI_CAPABLE ? &aesni_128_xts : &aes_128_xts;
1830#else
1831 return &aes_128_xts; 1129 return &aes_128_xts;
1832#endif
1833} 1130}
1834LCRYPTO_ALIAS(EVP_aes_128_xts); 1131LCRYPTO_ALIAS(EVP_aes_128_xts);
1835 1132
1836#ifdef AESNI_CAPABLE
1837static const EVP_CIPHER aesni_256_xts = {
1838 .nid = NID_aes_256_xts,
1839 .block_size = 1,
1840 .key_len = 2 * 32,
1841 .iv_len = 16,
1842 .flags = XTS_FLAGS | EVP_CIPH_XTS_MODE,
1843 .init = aesni_xts_init_key,
1844 .do_cipher = aes_xts_cipher,
1845 .cleanup = NULL,
1846 .ctx_size = sizeof(EVP_AES_XTS_CTX),
1847 .ctrl = aes_xts_ctrl,
1848};
1849#endif
1850
1851static const EVP_CIPHER aes_256_xts = { 1133static const EVP_CIPHER aes_256_xts = {
1852 .nid = NID_aes_256_xts, 1134 .nid = NID_aes_256_xts,
1853 .block_size = 1, 1135 .block_size = 1,
@@ -1864,11 +1146,7 @@ static const EVP_CIPHER aes_256_xts = {
1864const EVP_CIPHER * 1146const EVP_CIPHER *
1865EVP_aes_256_xts(void) 1147EVP_aes_256_xts(void)
1866{ 1148{
1867#ifdef AESNI_CAPABLE
1868 return AESNI_CAPABLE ? &aesni_256_xts : &aes_256_xts;
1869#else
1870 return &aes_256_xts; 1149 return &aes_256_xts;
1871#endif
1872} 1150}
1873LCRYPTO_ALIAS(EVP_aes_256_xts); 1151LCRYPTO_ALIAS(EVP_aes_256_xts);
1874 1152
@@ -1951,8 +1229,7 @@ aes_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
1951 if (key) { 1229 if (key) {
1952 AES_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks); 1230 AES_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks);
1953 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, 1231 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
1954 &cctx->ks, (block128_f)AES_encrypt); 1232 &cctx->ks, aes_encrypt_block128);
1955 cctx->str = NULL;
1956 cctx->key_set = 1; 1233 cctx->key_set = 1;
1957 } 1234 }
1958 if (iv) { 1235 if (iv) {
@@ -1970,7 +1247,14 @@ aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1970 CCM128_CONTEXT *ccm = &cctx->ccm; 1247 CCM128_CONTEXT *ccm = &cctx->ccm;
1971 1248
1972 /* If not set up, return error */ 1249 /* If not set up, return error */
1973 if (!cctx->iv_set && !cctx->key_set) 1250 if (!cctx->key_set)
1251 return -1;
1252
1253 /* EVP_*Final() doesn't return any data */
1254 if (in == NULL && out != NULL)
1255 return 0;
1256
1257 if (!cctx->iv_set)
1974 return -1; 1258 return -1;
1975 if (!ctx->encrypt && !cctx->tag_set) 1259 if (!ctx->encrypt && !cctx->tag_set)
1976 return -1; 1260 return -1;
@@ -1989,9 +1273,7 @@ aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1989 CRYPTO_ccm128_aad(ccm, in, len); 1273 CRYPTO_ccm128_aad(ccm, in, len);
1990 return len; 1274 return len;
1991 } 1275 }
1992 /* EVP_*Final() doesn't return any data */ 1276
1993 if (!in)
1994 return 0;
1995 /* If not set length yet do it */ 1277 /* If not set length yet do it */
1996 if (!cctx->len_set) { 1278 if (!cctx->len_set) {
1997 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, len)) 1279 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, len))
@@ -1999,18 +1281,18 @@ aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1999 cctx->len_set = 1; 1281 cctx->len_set = 1;
2000 } 1282 }
2001 if (ctx->encrypt) { 1283 if (ctx->encrypt) {
2002 if (cctx->str ? CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len, 1284 if (CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len,
2003 cctx->str) : CRYPTO_ccm128_encrypt(ccm, in, out, len)) 1285 aes_ccm64_encrypt_ccm128f) != 0)
2004 return -1; 1286 return -1;
2005 cctx->tag_set = 1; 1287 cctx->tag_set = 1;
2006 return len; 1288 return len;
2007 } else { 1289 } else {
2008 int rv = -1; 1290 int rv = -1;
2009 if (cctx->str ? !CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len, 1291 if (CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len,
2010 cctx->str) : !CRYPTO_ccm128_decrypt(ccm, in, out, len)) { 1292 aes_ccm64_decrypt_ccm128f) == 0) {
2011 unsigned char tag[16]; 1293 unsigned char tag[16];
2012 if (CRYPTO_ccm128_tag(ccm, tag, cctx->M)) { 1294 if (CRYPTO_ccm128_tag(ccm, tag, cctx->M)) {
2013 if (!memcmp(tag, ctx->buf, cctx->M)) 1295 if (timingsafe_memcmp(tag, ctx->buf, cctx->M) == 0)
2014 rv = len; 1296 rv = len;
2015 } 1297 }
2016 } 1298 }
@@ -2021,24 +1303,8 @@ aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
2021 cctx->len_set = 0; 1303 cctx->len_set = 0;
2022 return rv; 1304 return rv;
2023 } 1305 }
2024
2025} 1306}
2026 1307
2027#ifdef AESNI_CAPABLE
2028static const EVP_CIPHER aesni_128_ccm = {
2029 .nid = NID_aes_128_ccm,
2030 .block_size = 1,
2031 .key_len = 16,
2032 .iv_len = 12,
2033 .flags = CUSTOM_FLAGS | EVP_CIPH_CCM_MODE,
2034 .init = aesni_ccm_init_key,
2035 .do_cipher = aes_ccm_cipher,
2036 .cleanup = NULL,
2037 .ctx_size = sizeof(EVP_AES_CCM_CTX),
2038 .ctrl = aes_ccm_ctrl,
2039};
2040#endif
2041
2042static const EVP_CIPHER aes_128_ccm = { 1308static const EVP_CIPHER aes_128_ccm = {
2043 .nid = NID_aes_128_ccm, 1309 .nid = NID_aes_128_ccm,
2044 .block_size = 1, 1310 .block_size = 1,
@@ -2055,29 +1321,10 @@ static const EVP_CIPHER aes_128_ccm = {
2055const EVP_CIPHER * 1321const EVP_CIPHER *
2056EVP_aes_128_ccm(void) 1322EVP_aes_128_ccm(void)
2057{ 1323{
2058#ifdef AESNI_CAPABLE
2059 return AESNI_CAPABLE ? &aesni_128_ccm : &aes_128_ccm;
2060#else
2061 return &aes_128_ccm; 1324 return &aes_128_ccm;
2062#endif
2063} 1325}
2064LCRYPTO_ALIAS(EVP_aes_128_ccm); 1326LCRYPTO_ALIAS(EVP_aes_128_ccm);
2065 1327
2066#ifdef AESNI_CAPABLE
2067static const EVP_CIPHER aesni_192_ccm = {
2068 .nid = NID_aes_192_ccm,
2069 .block_size = 1,
2070 .key_len = 24,
2071 .iv_len = 12,
2072 .flags = CUSTOM_FLAGS | EVP_CIPH_CCM_MODE,
2073 .init = aesni_ccm_init_key,
2074 .do_cipher = aes_ccm_cipher,
2075 .cleanup = NULL,
2076 .ctx_size = sizeof(EVP_AES_CCM_CTX),
2077 .ctrl = aes_ccm_ctrl,
2078};
2079#endif
2080
2081static const EVP_CIPHER aes_192_ccm = { 1328static const EVP_CIPHER aes_192_ccm = {
2082 .nid = NID_aes_192_ccm, 1329 .nid = NID_aes_192_ccm,
2083 .block_size = 1, 1330 .block_size = 1,
@@ -2094,29 +1341,10 @@ static const EVP_CIPHER aes_192_ccm = {
2094const EVP_CIPHER * 1341const EVP_CIPHER *
2095EVP_aes_192_ccm(void) 1342EVP_aes_192_ccm(void)
2096{ 1343{
2097#ifdef AESNI_CAPABLE
2098 return AESNI_CAPABLE ? &aesni_192_ccm : &aes_192_ccm;
2099#else
2100 return &aes_192_ccm; 1344 return &aes_192_ccm;
2101#endif
2102} 1345}
2103LCRYPTO_ALIAS(EVP_aes_192_ccm); 1346LCRYPTO_ALIAS(EVP_aes_192_ccm);
2104 1347
2105#ifdef AESNI_CAPABLE
2106static const EVP_CIPHER aesni_256_ccm = {
2107 .nid = NID_aes_256_ccm,
2108 .block_size = 1,
2109 .key_len = 32,
2110 .iv_len = 12,
2111 .flags = CUSTOM_FLAGS | EVP_CIPH_CCM_MODE,
2112 .init = aesni_ccm_init_key,
2113 .do_cipher = aes_ccm_cipher,
2114 .cleanup = NULL,
2115 .ctx_size = sizeof(EVP_AES_CCM_CTX),
2116 .ctrl = aes_ccm_ctrl,
2117};
2118#endif
2119
2120static const EVP_CIPHER aes_256_ccm = { 1348static const EVP_CIPHER aes_256_ccm = {
2121 .nid = NID_aes_256_ccm, 1349 .nid = NID_aes_256_ccm,
2122 .block_size = 1, 1350 .block_size = 1,
@@ -2133,11 +1361,7 @@ static const EVP_CIPHER aes_256_ccm = {
2133const EVP_CIPHER * 1361const EVP_CIPHER *
2134EVP_aes_256_ccm(void) 1362EVP_aes_256_ccm(void)
2135{ 1363{
2136#ifdef AESNI_CAPABLE
2137 return AESNI_CAPABLE ? &aesni_256_ccm : &aes_256_ccm;
2138#else
2139 return &aes_256_ccm; 1364 return &aes_256_ccm;
2140#endif
2141} 1365}
2142LCRYPTO_ALIAS(EVP_aes_256_ccm); 1366LCRYPTO_ALIAS(EVP_aes_256_ccm);
2143 1367
@@ -2149,7 +1373,6 @@ struct aead_aes_gcm_ctx {
2149 AES_KEY ks; 1373 AES_KEY ks;
2150 } ks; 1374 } ks;
2151 GCM128_CONTEXT gcm; 1375 GCM128_CONTEXT gcm;
2152 ctr128_f ctr;
2153 unsigned char tag_len; 1376 unsigned char tag_len;
2154}; 1377};
2155 1378
@@ -2177,18 +1400,8 @@ aead_aes_gcm_init(EVP_AEAD_CTX *ctx, const unsigned char *key, size_t key_len,
2177 if ((gcm_ctx = calloc(1, sizeof(struct aead_aes_gcm_ctx))) == NULL) 1400 if ((gcm_ctx = calloc(1, sizeof(struct aead_aes_gcm_ctx))) == NULL)
2178 return 0; 1401 return 0;
2179 1402
2180#ifdef AESNI_CAPABLE 1403 AES_set_encrypt_key(key, key_bits, &gcm_ctx->ks.ks);
2181 if (AESNI_CAPABLE) { 1404 CRYPTO_gcm128_init(&gcm_ctx->gcm, &gcm_ctx->ks.ks, aes_encrypt_block128);
2182 aesni_set_encrypt_key(key, key_bits, &gcm_ctx->ks.ks);
2183 CRYPTO_gcm128_init(&gcm_ctx->gcm, &gcm_ctx->ks.ks,
2184 (block128_f)aesni_encrypt);
2185 gcm_ctx->ctr = (ctr128_f) aesni_ctr32_encrypt_blocks;
2186 } else
2187#endif
2188 {
2189 gcm_ctx->ctr = aes_gcm_set_key(&gcm_ctx->ks.ks, &gcm_ctx->gcm,
2190 key, key_len);
2191 }
2192 gcm_ctx->tag_len = tag_len; 1405 gcm_ctx->tag_len = tag_len;
2193 ctx->aead_state = gcm_ctx; 1406 ctx->aead_state = gcm_ctx;
2194 1407
@@ -2229,15 +1442,9 @@ aead_aes_gcm_seal(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len,
2229 if (ad_len > 0 && CRYPTO_gcm128_aad(&gcm, ad, ad_len)) 1442 if (ad_len > 0 && CRYPTO_gcm128_aad(&gcm, ad, ad_len))
2230 return 0; 1443 return 0;
2231 1444
2232 if (gcm_ctx->ctr) { 1445 if (CRYPTO_gcm128_encrypt_ctr32(&gcm, in + bulk, out + bulk,
2233 if (CRYPTO_gcm128_encrypt_ctr32(&gcm, in + bulk, out + bulk, 1446 in_len - bulk, aes_ctr32_encrypt_ctr128f))
2234 in_len - bulk, gcm_ctx->ctr)) 1447 return 0;
2235 return 0;
2236 } else {
2237 if (CRYPTO_gcm128_encrypt(&gcm, in + bulk, out + bulk,
2238 in_len - bulk))
2239 return 0;
2240 }
2241 1448
2242 CRYPTO_gcm128_tag(&gcm, out + in_len, gcm_ctx->tag_len); 1449 CRYPTO_gcm128_tag(&gcm, out + in_len, gcm_ctx->tag_len);
2243 *out_len = in_len + gcm_ctx->tag_len; 1450 *out_len = in_len + gcm_ctx->tag_len;
@@ -2280,15 +1487,9 @@ aead_aes_gcm_open(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len,
2280 if (CRYPTO_gcm128_aad(&gcm, ad, ad_len)) 1487 if (CRYPTO_gcm128_aad(&gcm, ad, ad_len))
2281 return 0; 1488 return 0;
2282 1489
2283 if (gcm_ctx->ctr) { 1490 if (CRYPTO_gcm128_decrypt_ctr32(&gcm, in + bulk, out + bulk,
2284 if (CRYPTO_gcm128_decrypt_ctr32(&gcm, in + bulk, out + bulk, 1491 in_len - bulk - gcm_ctx->tag_len, aes_ctr32_encrypt_ctr128f))
2285 in_len - bulk - gcm_ctx->tag_len, gcm_ctx->ctr)) 1492 return 0;
2286 return 0;
2287 } else {
2288 if (CRYPTO_gcm128_decrypt(&gcm, in + bulk, out + bulk,
2289 in_len - bulk - gcm_ctx->tag_len))
2290 return 0;
2291 }
2292 1493
2293 CRYPTO_gcm128_tag(&gcm, tag, gcm_ctx->tag_len); 1494 CRYPTO_gcm128_tag(&gcm, tag, gcm_ctx->tag_len);
2294 if (timingsafe_memcmp(tag, in + plaintext_len, gcm_ctx->tag_len) != 0) { 1495 if (timingsafe_memcmp(tag, in + plaintext_len, gcm_ctx->tag_len) != 0) {
diff --git a/src/lib/libcrypto/evp/e_bf.c b/src/lib/libcrypto/evp/e_bf.c
index 4f3799975b..8c32a5658e 100644
--- a/src/lib/libcrypto/evp/e_bf.c
+++ b/src/lib/libcrypto/evp/e_bf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_bf.c,v 1.19 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_bf.c,v 1.20 2025/05/27 03:58:12 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -162,13 +162,14 @@ static const EVP_CIPHER bf_cbc = {
162 .block_size = 8, 162 .block_size = 8,
163 .key_len = 16, 163 .key_len = 16,
164 .iv_len = 8, 164 .iv_len = 8,
165 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CBC_MODE, 165 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CBC_MODE |
166 EVP_CIPH_FLAG_DEFAULT_ASN1,
166 .init = bf_init_key, 167 .init = bf_init_key,
167 .do_cipher = bf_cbc_cipher, 168 .do_cipher = bf_cbc_cipher,
168 .cleanup = NULL, 169 .cleanup = NULL,
169 .ctx_size = sizeof(EVP_BF_KEY), 170 .ctx_size = sizeof(EVP_BF_KEY),
170 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 171 .set_asn1_parameters = NULL,
171 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 172 .get_asn1_parameters = NULL,
172 .ctrl = NULL, 173 .ctrl = NULL,
173}; 174};
174 175
@@ -184,13 +185,14 @@ static const EVP_CIPHER bf_cfb64 = {
184 .block_size = 1, 185 .block_size = 1,
185 .key_len = 16, 186 .key_len = 16,
186 .iv_len = 8, 187 .iv_len = 8,
187 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CFB_MODE, 188 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CFB_MODE |
189 EVP_CIPH_FLAG_DEFAULT_ASN1,
188 .init = bf_init_key, 190 .init = bf_init_key,
189 .do_cipher = bf_cfb64_cipher, 191 .do_cipher = bf_cfb64_cipher,
190 .cleanup = NULL, 192 .cleanup = NULL,
191 .ctx_size = sizeof(EVP_BF_KEY), 193 .ctx_size = sizeof(EVP_BF_KEY),
192 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 194 .set_asn1_parameters = NULL,
193 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 195 .get_asn1_parameters = NULL,
194 .ctrl = NULL, 196 .ctrl = NULL,
195}; 197};
196 198
@@ -206,13 +208,14 @@ static const EVP_CIPHER bf_ofb = {
206 .block_size = 1, 208 .block_size = 1,
207 .key_len = 16, 209 .key_len = 16,
208 .iv_len = 8, 210 .iv_len = 8,
209 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_OFB_MODE, 211 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_OFB_MODE |
212 EVP_CIPH_FLAG_DEFAULT_ASN1,
210 .init = bf_init_key, 213 .init = bf_init_key,
211 .do_cipher = bf_ofb_cipher, 214 .do_cipher = bf_ofb_cipher,
212 .cleanup = NULL, 215 .cleanup = NULL,
213 .ctx_size = sizeof(EVP_BF_KEY), 216 .ctx_size = sizeof(EVP_BF_KEY),
214 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 217 .set_asn1_parameters = NULL,
215 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 218 .get_asn1_parameters = NULL,
216 .ctrl = NULL, 219 .ctrl = NULL,
217}; 220};
218 221
@@ -228,13 +231,14 @@ static const EVP_CIPHER bf_ecb = {
228 .block_size = 8, 231 .block_size = 8,
229 .key_len = 16, 232 .key_len = 16,
230 .iv_len = 0, 233 .iv_len = 0,
231 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ECB_MODE, 234 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ECB_MODE |
235 EVP_CIPH_FLAG_DEFAULT_ASN1,
232 .init = bf_init_key, 236 .init = bf_init_key,
233 .do_cipher = bf_ecb_cipher, 237 .do_cipher = bf_ecb_cipher,
234 .cleanup = NULL, 238 .cleanup = NULL,
235 .ctx_size = sizeof(EVP_BF_KEY), 239 .ctx_size = sizeof(EVP_BF_KEY),
236 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 240 .set_asn1_parameters = NULL,
237 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 241 .get_asn1_parameters = NULL,
238 .ctrl = NULL, 242 .ctrl = NULL,
239}; 243};
240 244
diff --git a/src/lib/libcrypto/evp/e_camellia.c b/src/lib/libcrypto/evp/e_camellia.c
index 55dcc79922..8da46275a3 100644
--- a/src/lib/libcrypto/evp/e_camellia.c
+++ b/src/lib/libcrypto/evp/e_camellia.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_camellia.c,v 1.20 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_camellia.c,v 1.22 2025/05/27 03:58:12 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -59,9 +59,9 @@
59 59
60#ifndef OPENSSL_NO_CAMELLIA 60#ifndef OPENSSL_NO_CAMELLIA
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/err.h>
63#include <openssl/camellia.h> 62#include <openssl/camellia.h>
64 63
64#include "err_local.h"
65#include "evp_local.h" 65#include "evp_local.h"
66 66
67/* Camellia subkey Structure */ 67/* Camellia subkey Structure */
@@ -163,13 +163,13 @@ static const EVP_CIPHER camellia_128_cbc = {
163 .block_size = 16, 163 .block_size = 16,
164 .key_len = 16, 164 .key_len = 16,
165 .iv_len = 16, 165 .iv_len = 16,
166 .flags = 0 | EVP_CIPH_CBC_MODE, 166 .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
167 .init = camellia_init_key, 167 .init = camellia_init_key,
168 .do_cipher = camellia_128_cbc_cipher, 168 .do_cipher = camellia_128_cbc_cipher,
169 .cleanup = NULL, 169 .cleanup = NULL,
170 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 170 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
171 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 171 .set_asn1_parameters = NULL,
172 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 172 .get_asn1_parameters = NULL,
173 .ctrl = NULL, 173 .ctrl = NULL,
174}; 174};
175 175
@@ -185,13 +185,13 @@ static const EVP_CIPHER camellia_128_cfb128 = {
185 .block_size = 1, 185 .block_size = 1,
186 .key_len = 16, 186 .key_len = 16,
187 .iv_len = 16, 187 .iv_len = 16,
188 .flags = 0 | EVP_CIPH_CFB_MODE, 188 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
189 .init = camellia_init_key, 189 .init = camellia_init_key,
190 .do_cipher = camellia_128_cfb128_cipher, 190 .do_cipher = camellia_128_cfb128_cipher,
191 .cleanup = NULL, 191 .cleanup = NULL,
192 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 192 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
193 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 193 .set_asn1_parameters = NULL,
194 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 194 .get_asn1_parameters = NULL,
195 .ctrl = NULL, 195 .ctrl = NULL,
196}; 196};
197 197
@@ -207,13 +207,13 @@ static const EVP_CIPHER camellia_128_ofb = {
207 .block_size = 1, 207 .block_size = 1,
208 .key_len = 16, 208 .key_len = 16,
209 .iv_len = 16, 209 .iv_len = 16,
210 .flags = 0 | EVP_CIPH_OFB_MODE, 210 .flags = EVP_CIPH_OFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
211 .init = camellia_init_key, 211 .init = camellia_init_key,
212 .do_cipher = camellia_128_ofb_cipher, 212 .do_cipher = camellia_128_ofb_cipher,
213 .cleanup = NULL, 213 .cleanup = NULL,
214 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 214 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
215 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 215 .set_asn1_parameters = NULL,
216 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 216 .get_asn1_parameters = NULL,
217 .ctrl = NULL, 217 .ctrl = NULL,
218}; 218};
219 219
@@ -229,13 +229,13 @@ static const EVP_CIPHER camellia_128_ecb = {
229 .block_size = 16, 229 .block_size = 16,
230 .key_len = 16, 230 .key_len = 16,
231 .iv_len = 0, 231 .iv_len = 0,
232 .flags = 0 | EVP_CIPH_ECB_MODE, 232 .flags = EVP_CIPH_ECB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
233 .init = camellia_init_key, 233 .init = camellia_init_key,
234 .do_cipher = camellia_128_ecb_cipher, 234 .do_cipher = camellia_128_ecb_cipher,
235 .cleanup = NULL, 235 .cleanup = NULL,
236 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 236 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
237 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 237 .set_asn1_parameters = NULL,
238 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 238 .get_asn1_parameters = NULL,
239 .ctrl = NULL, 239 .ctrl = NULL,
240}; 240};
241 241
@@ -321,13 +321,13 @@ static const EVP_CIPHER camellia_192_cbc = {
321 .block_size = 16, 321 .block_size = 16,
322 .key_len = 24, 322 .key_len = 24,
323 .iv_len = 16, 323 .iv_len = 16,
324 .flags = 0 | EVP_CIPH_CBC_MODE, 324 .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
325 .init = camellia_init_key, 325 .init = camellia_init_key,
326 .do_cipher = camellia_192_cbc_cipher, 326 .do_cipher = camellia_192_cbc_cipher,
327 .cleanup = NULL, 327 .cleanup = NULL,
328 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 328 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
329 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 329 .set_asn1_parameters = NULL,
330 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 330 .get_asn1_parameters = NULL,
331 .ctrl = NULL, 331 .ctrl = NULL,
332}; 332};
333 333
@@ -343,13 +343,13 @@ static const EVP_CIPHER camellia_192_cfb128 = {
343 .block_size = 1, 343 .block_size = 1,
344 .key_len = 24, 344 .key_len = 24,
345 .iv_len = 16, 345 .iv_len = 16,
346 .flags = 0 | EVP_CIPH_CFB_MODE, 346 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
347 .init = camellia_init_key, 347 .init = camellia_init_key,
348 .do_cipher = camellia_192_cfb128_cipher, 348 .do_cipher = camellia_192_cfb128_cipher,
349 .cleanup = NULL, 349 .cleanup = NULL,
350 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 350 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
351 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 351 .set_asn1_parameters = NULL,
352 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 352 .get_asn1_parameters = NULL,
353 .ctrl = NULL, 353 .ctrl = NULL,
354}; 354};
355 355
@@ -365,13 +365,13 @@ static const EVP_CIPHER camellia_192_ofb = {
365 .block_size = 1, 365 .block_size = 1,
366 .key_len = 24, 366 .key_len = 24,
367 .iv_len = 16, 367 .iv_len = 16,
368 .flags = 0 | EVP_CIPH_OFB_MODE, 368 .flags = EVP_CIPH_OFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
369 .init = camellia_init_key, 369 .init = camellia_init_key,
370 .do_cipher = camellia_192_ofb_cipher, 370 .do_cipher = camellia_192_ofb_cipher,
371 .cleanup = NULL, 371 .cleanup = NULL,
372 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 372 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
373 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 373 .set_asn1_parameters = NULL,
374 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 374 .get_asn1_parameters = NULL,
375 .ctrl = NULL, 375 .ctrl = NULL,
376}; 376};
377 377
@@ -387,13 +387,13 @@ static const EVP_CIPHER camellia_192_ecb = {
387 .block_size = 16, 387 .block_size = 16,
388 .key_len = 24, 388 .key_len = 24,
389 .iv_len = 0, 389 .iv_len = 0,
390 .flags = 0 | EVP_CIPH_ECB_MODE, 390 .flags = EVP_CIPH_ECB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
391 .init = camellia_init_key, 391 .init = camellia_init_key,
392 .do_cipher = camellia_192_ecb_cipher, 392 .do_cipher = camellia_192_ecb_cipher,
393 .cleanup = NULL, 393 .cleanup = NULL,
394 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 394 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
395 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 395 .set_asn1_parameters = NULL,
396 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 396 .get_asn1_parameters = NULL,
397 .ctrl = NULL, 397 .ctrl = NULL,
398}; 398};
399 399
@@ -479,13 +479,13 @@ static const EVP_CIPHER camellia_256_cbc = {
479 .block_size = 16, 479 .block_size = 16,
480 .key_len = 32, 480 .key_len = 32,
481 .iv_len = 16, 481 .iv_len = 16,
482 .flags = 0 | EVP_CIPH_CBC_MODE, 482 .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
483 .init = camellia_init_key, 483 .init = camellia_init_key,
484 .do_cipher = camellia_256_cbc_cipher, 484 .do_cipher = camellia_256_cbc_cipher,
485 .cleanup = NULL, 485 .cleanup = NULL,
486 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 486 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
487 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 487 .set_asn1_parameters = NULL,
488 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 488 .get_asn1_parameters = NULL,
489 .ctrl = NULL, 489 .ctrl = NULL,
490}; 490};
491 491
@@ -501,13 +501,13 @@ static const EVP_CIPHER camellia_256_cfb128 = {
501 .block_size = 1, 501 .block_size = 1,
502 .key_len = 32, 502 .key_len = 32,
503 .iv_len = 16, 503 .iv_len = 16,
504 .flags = 0 | EVP_CIPH_CFB_MODE, 504 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
505 .init = camellia_init_key, 505 .init = camellia_init_key,
506 .do_cipher = camellia_256_cfb128_cipher, 506 .do_cipher = camellia_256_cfb128_cipher,
507 .cleanup = NULL, 507 .cleanup = NULL,
508 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 508 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
509 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 509 .set_asn1_parameters = NULL,
510 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 510 .get_asn1_parameters = NULL,
511 .ctrl = NULL, 511 .ctrl = NULL,
512}; 512};
513 513
@@ -523,13 +523,13 @@ static const EVP_CIPHER camellia_256_ofb = {
523 .block_size = 1, 523 .block_size = 1,
524 .key_len = 32, 524 .key_len = 32,
525 .iv_len = 16, 525 .iv_len = 16,
526 .flags = 0 | EVP_CIPH_OFB_MODE, 526 .flags = EVP_CIPH_OFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
527 .init = camellia_init_key, 527 .init = camellia_init_key,
528 .do_cipher = camellia_256_ofb_cipher, 528 .do_cipher = camellia_256_ofb_cipher,
529 .cleanup = NULL, 529 .cleanup = NULL,
530 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 530 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
531 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 531 .set_asn1_parameters = NULL,
532 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 532 .get_asn1_parameters = NULL,
533 .ctrl = NULL, 533 .ctrl = NULL,
534}; 534};
535 535
@@ -545,13 +545,13 @@ static const EVP_CIPHER camellia_256_ecb = {
545 .block_size = 16, 545 .block_size = 16,
546 .key_len = 32, 546 .key_len = 32,
547 .iv_len = 0, 547 .iv_len = 0,
548 .flags = 0 | EVP_CIPH_ECB_MODE, 548 .flags = EVP_CIPH_ECB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
549 .init = camellia_init_key, 549 .init = camellia_init_key,
550 .do_cipher = camellia_256_ecb_cipher, 550 .do_cipher = camellia_256_ecb_cipher,
551 .cleanup = NULL, 551 .cleanup = NULL,
552 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 552 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
553 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 553 .set_asn1_parameters = NULL,
554 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 554 .get_asn1_parameters = NULL,
555 .ctrl = NULL, 555 .ctrl = NULL,
556}; 556};
557 557
@@ -589,13 +589,13 @@ static const EVP_CIPHER camellia_128_cfb1 = {
589 .block_size = 1, 589 .block_size = 1,
590 .key_len = 128/8, 590 .key_len = 128/8,
591 .iv_len = 16, 591 .iv_len = 16,
592 .flags = 0 | EVP_CIPH_CFB_MODE, 592 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
593 .init = camellia_init_key, 593 .init = camellia_init_key,
594 .do_cipher = camellia_128_cfb1_cipher, 594 .do_cipher = camellia_128_cfb1_cipher,
595 .cleanup = NULL, 595 .cleanup = NULL,
596 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 596 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
597 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 597 .set_asn1_parameters = NULL,
598 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 598 .get_asn1_parameters = NULL,
599 .ctrl = NULL, 599 .ctrl = NULL,
600}; 600};
601 601
@@ -633,13 +633,13 @@ static const EVP_CIPHER camellia_192_cfb1 = {
633 .block_size = 1, 633 .block_size = 1,
634 .key_len = 192/8, 634 .key_len = 192/8,
635 .iv_len = 16, 635 .iv_len = 16,
636 .flags = 0 | EVP_CIPH_CFB_MODE, 636 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
637 .init = camellia_init_key, 637 .init = camellia_init_key,
638 .do_cipher = camellia_192_cfb1_cipher, 638 .do_cipher = camellia_192_cfb1_cipher,
639 .cleanup = NULL, 639 .cleanup = NULL,
640 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 640 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
641 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 641 .set_asn1_parameters = NULL,
642 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 642 .get_asn1_parameters = NULL,
643 .ctrl = NULL, 643 .ctrl = NULL,
644}; 644};
645 645
@@ -677,13 +677,13 @@ static const EVP_CIPHER camellia_256_cfb1 = {
677 .block_size = 1, 677 .block_size = 1,
678 .key_len = 256/8, 678 .key_len = 256/8,
679 .iv_len = 16, 679 .iv_len = 16,
680 .flags = 0 | EVP_CIPH_CFB_MODE, 680 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
681 .init = camellia_init_key, 681 .init = camellia_init_key,
682 .do_cipher = camellia_256_cfb1_cipher, 682 .do_cipher = camellia_256_cfb1_cipher,
683 .cleanup = NULL, 683 .cleanup = NULL,
684 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 684 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
685 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 685 .set_asn1_parameters = NULL,
686 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 686 .get_asn1_parameters = NULL,
687 .ctrl = NULL, 687 .ctrl = NULL,
688}; 688};
689 689
@@ -720,13 +720,13 @@ static const EVP_CIPHER camellia_128_cfb8 = {
720 .block_size = 1, 720 .block_size = 1,
721 .key_len = 128/8, 721 .key_len = 128/8,
722 .iv_len = 16, 722 .iv_len = 16,
723 .flags = 0 | EVP_CIPH_CFB_MODE, 723 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
724 .init = camellia_init_key, 724 .init = camellia_init_key,
725 .do_cipher = camellia_128_cfb8_cipher, 725 .do_cipher = camellia_128_cfb8_cipher,
726 .cleanup = NULL, 726 .cleanup = NULL,
727 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 727 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
728 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 728 .set_asn1_parameters = NULL,
729 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 729 .get_asn1_parameters = NULL,
730 .ctrl = NULL, 730 .ctrl = NULL,
731}; 731};
732 732
@@ -762,13 +762,13 @@ static const EVP_CIPHER camellia_192_cfb8 = {
762 .block_size = 1, 762 .block_size = 1,
763 .key_len = 192/8, 763 .key_len = 192/8,
764 .iv_len = 16, 764 .iv_len = 16,
765 .flags = 0 | EVP_CIPH_CFB_MODE, 765 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
766 .init = camellia_init_key, 766 .init = camellia_init_key,
767 .do_cipher = camellia_192_cfb8_cipher, 767 .do_cipher = camellia_192_cfb8_cipher,
768 .cleanup = NULL, 768 .cleanup = NULL,
769 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 769 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
770 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 770 .set_asn1_parameters = NULL,
771 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 771 .get_asn1_parameters = NULL,
772 .ctrl = NULL, 772 .ctrl = NULL,
773}; 773};
774 774
@@ -804,13 +804,13 @@ static const EVP_CIPHER camellia_256_cfb8 = {
804 .block_size = 1, 804 .block_size = 1,
805 .key_len = 256/8, 805 .key_len = 256/8,
806 .iv_len = 16, 806 .iv_len = 16,
807 .flags = 0 | EVP_CIPH_CFB_MODE, 807 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
808 .init = camellia_init_key, 808 .init = camellia_init_key,
809 .do_cipher = camellia_256_cfb8_cipher, 809 .do_cipher = camellia_256_cfb8_cipher,
810 .cleanup = NULL, 810 .cleanup = NULL,
811 .ctx_size = sizeof(EVP_CAMELLIA_KEY), 811 .ctx_size = sizeof(EVP_CAMELLIA_KEY),
812 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 812 .set_asn1_parameters = NULL,
813 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 813 .get_asn1_parameters = NULL,
814 .ctrl = NULL, 814 .ctrl = NULL,
815}; 815};
816 816
diff --git a/src/lib/libcrypto/evp/e_cast.c b/src/lib/libcrypto/evp/e_cast.c
index 1575a7a5bb..283cb8cf63 100644
--- a/src/lib/libcrypto/evp/e_cast.c
+++ b/src/lib/libcrypto/evp/e_cast.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_cast.c,v 1.18 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_cast.c,v 1.19 2025/05/27 03:58:12 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -162,13 +162,14 @@ static const EVP_CIPHER cast5_cbc = {
162 .block_size = 8, 162 .block_size = 8,
163 .key_len = CAST_KEY_LENGTH, 163 .key_len = CAST_KEY_LENGTH,
164 .iv_len = 8, 164 .iv_len = 8,
165 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CBC_MODE, 165 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CBC_MODE |
166 EVP_CIPH_FLAG_DEFAULT_ASN1,
166 .init = cast_init_key, 167 .init = cast_init_key,
167 .do_cipher = cast5_cbc_cipher, 168 .do_cipher = cast5_cbc_cipher,
168 .cleanup = NULL, 169 .cleanup = NULL,
169 .ctx_size = sizeof(EVP_CAST_KEY), 170 .ctx_size = sizeof(EVP_CAST_KEY),
170 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 171 .set_asn1_parameters = NULL,
171 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 172 .get_asn1_parameters = NULL,
172 .ctrl = NULL, 173 .ctrl = NULL,
173}; 174};
174 175
@@ -184,13 +185,14 @@ static const EVP_CIPHER cast5_cfb64 = {
184 .block_size = 1, 185 .block_size = 1,
185 .key_len = CAST_KEY_LENGTH, 186 .key_len = CAST_KEY_LENGTH,
186 .iv_len = 8, 187 .iv_len = 8,
187 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CFB_MODE, 188 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CFB_MODE |
189 EVP_CIPH_FLAG_DEFAULT_ASN1,
188 .init = cast_init_key, 190 .init = cast_init_key,
189 .do_cipher = cast5_cfb64_cipher, 191 .do_cipher = cast5_cfb64_cipher,
190 .cleanup = NULL, 192 .cleanup = NULL,
191 .ctx_size = sizeof(EVP_CAST_KEY), 193 .ctx_size = sizeof(EVP_CAST_KEY),
192 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 194 .set_asn1_parameters = NULL,
193 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 195 .get_asn1_parameters = NULL,
194 .ctrl = NULL, 196 .ctrl = NULL,
195}; 197};
196 198
@@ -206,13 +208,14 @@ static const EVP_CIPHER cast5_ofb = {
206 .block_size = 1, 208 .block_size = 1,
207 .key_len = CAST_KEY_LENGTH, 209 .key_len = CAST_KEY_LENGTH,
208 .iv_len = 8, 210 .iv_len = 8,
209 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_OFB_MODE, 211 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_OFB_MODE |
212 EVP_CIPH_FLAG_DEFAULT_ASN1,
210 .init = cast_init_key, 213 .init = cast_init_key,
211 .do_cipher = cast5_ofb_cipher, 214 .do_cipher = cast5_ofb_cipher,
212 .cleanup = NULL, 215 .cleanup = NULL,
213 .ctx_size = sizeof(EVP_CAST_KEY), 216 .ctx_size = sizeof(EVP_CAST_KEY),
214 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 217 .set_asn1_parameters = NULL,
215 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 218 .get_asn1_parameters = NULL,
216 .ctrl = NULL, 219 .ctrl = NULL,
217}; 220};
218 221
@@ -228,13 +231,14 @@ static const EVP_CIPHER cast5_ecb = {
228 .block_size = 8, 231 .block_size = 8,
229 .key_len = CAST_KEY_LENGTH, 232 .key_len = CAST_KEY_LENGTH,
230 .iv_len = 0, 233 .iv_len = 0,
231 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ECB_MODE, 234 .flags = EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_ECB_MODE |
235 EVP_CIPH_FLAG_DEFAULT_ASN1,
232 .init = cast_init_key, 236 .init = cast_init_key,
233 .do_cipher = cast5_ecb_cipher, 237 .do_cipher = cast5_ecb_cipher,
234 .cleanup = NULL, 238 .cleanup = NULL,
235 .ctx_size = sizeof(EVP_CAST_KEY), 239 .ctx_size = sizeof(EVP_CAST_KEY),
236 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 240 .set_asn1_parameters = NULL,
237 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 241 .get_asn1_parameters = NULL,
238 .ctrl = NULL, 242 .ctrl = NULL,
239}; 243};
240 244
diff --git a/src/lib/libcrypto/evp/e_chacha20poly1305.c b/src/lib/libcrypto/evp/e_chacha20poly1305.c
index d176569f90..d3a1e44875 100644
--- a/src/lib/libcrypto/evp/e_chacha20poly1305.c
+++ b/src/lib/libcrypto/evp/e_chacha20poly1305.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_chacha20poly1305.c,v 1.37 2024/12/20 20:05:29 schwarze Exp $ */ 1/* $OpenBSD: e_chacha20poly1305.c,v 1.38 2025/05/10 05:54:38 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
@@ -26,12 +26,12 @@
26 26
27#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) 27#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
28 28
29#include <openssl/err.h>
30#include <openssl/evp.h> 29#include <openssl/evp.h>
31#include <openssl/chacha.h> 30#include <openssl/chacha.h>
32#include <openssl/poly1305.h> 31#include <openssl/poly1305.h>
33 32
34#include "bytestring.h" 33#include "bytestring.h"
34#include "err_local.h"
35#include "evp_local.h" 35#include "evp_local.h"
36 36
37#define POLY1305_TAG_LEN 16 37#define POLY1305_TAG_LEN 16
diff --git a/src/lib/libcrypto/evp/e_des.c b/src/lib/libcrypto/evp/e_des.c
index fb335e95b1..680f77a723 100644
--- a/src/lib/libcrypto/evp/e_des.c
+++ b/src/lib/libcrypto/evp/e_des.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_des.c,v 1.24 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_des.c,v 1.25 2025/05/27 03:58:12 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -226,13 +226,14 @@ static const EVP_CIPHER des_cbc = {
226 .block_size = 8, 226 .block_size = 8,
227 .key_len = 8, 227 .key_len = 8,
228 .iv_len = 8, 228 .iv_len = 8,
229 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CBC_MODE, 229 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CBC_MODE |
230 EVP_CIPH_FLAG_DEFAULT_ASN1,
230 .init = des_init_key, 231 .init = des_init_key,
231 .do_cipher = des_cbc_cipher, 232 .do_cipher = des_cbc_cipher,
232 .cleanup = NULL, 233 .cleanup = NULL,
233 .ctx_size = sizeof(DES_key_schedule), 234 .ctx_size = sizeof(DES_key_schedule),
234 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 235 .set_asn1_parameters = NULL,
235 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 236 .get_asn1_parameters = NULL,
236 .ctrl = des_ctrl, 237 .ctrl = des_ctrl,
237}; 238};
238 239
@@ -248,13 +249,14 @@ static const EVP_CIPHER des_cfb64 = {
248 .block_size = 1, 249 .block_size = 1,
249 .key_len = 8, 250 .key_len = 8,
250 .iv_len = 8, 251 .iv_len = 8,
251 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE, 252 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE |
253 EVP_CIPH_FLAG_DEFAULT_ASN1,
252 .init = des_init_key, 254 .init = des_init_key,
253 .do_cipher = des_cfb64_cipher, 255 .do_cipher = des_cfb64_cipher,
254 .cleanup = NULL, 256 .cleanup = NULL,
255 .ctx_size = sizeof(DES_key_schedule), 257 .ctx_size = sizeof(DES_key_schedule),
256 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 258 .set_asn1_parameters = NULL,
257 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 259 .get_asn1_parameters = NULL,
258 .ctrl = des_ctrl, 260 .ctrl = des_ctrl,
259}; 261};
260 262
@@ -270,13 +272,14 @@ static const EVP_CIPHER des_ofb = {
270 .block_size = 1, 272 .block_size = 1,
271 .key_len = 8, 273 .key_len = 8,
272 .iv_len = 8, 274 .iv_len = 8,
273 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_OFB_MODE, 275 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_OFB_MODE |
276 EVP_CIPH_FLAG_DEFAULT_ASN1,
274 .init = des_init_key, 277 .init = des_init_key,
275 .do_cipher = des_ofb_cipher, 278 .do_cipher = des_ofb_cipher,
276 .cleanup = NULL, 279 .cleanup = NULL,
277 .ctx_size = sizeof(DES_key_schedule), 280 .ctx_size = sizeof(DES_key_schedule),
278 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 281 .set_asn1_parameters = NULL,
279 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 282 .get_asn1_parameters = NULL,
280 .ctrl = des_ctrl, 283 .ctrl = des_ctrl,
281}; 284};
282 285
@@ -292,13 +295,14 @@ static const EVP_CIPHER des_ecb = {
292 .block_size = 8, 295 .block_size = 8,
293 .key_len = 8, 296 .key_len = 8,
294 .iv_len = 0, 297 .iv_len = 0,
295 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_ECB_MODE, 298 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_ECB_MODE |
299 EVP_CIPH_FLAG_DEFAULT_ASN1,
296 .init = des_init_key, 300 .init = des_init_key,
297 .do_cipher = des_ecb_cipher, 301 .do_cipher = des_ecb_cipher,
298 .cleanup = NULL, 302 .cleanup = NULL,
299 .ctx_size = sizeof(DES_key_schedule), 303 .ctx_size = sizeof(DES_key_schedule),
300 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 304 .set_asn1_parameters = NULL,
301 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 305 .get_asn1_parameters = NULL,
302 .ctrl = des_ctrl, 306 .ctrl = des_ctrl,
303}; 307};
304 308
@@ -314,13 +318,14 @@ static const EVP_CIPHER des_cfb1 = {
314 .block_size = 1, 318 .block_size = 1,
315 .key_len = 8, 319 .key_len = 8,
316 .iv_len = 8, 320 .iv_len = 8,
317 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE, 321 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE |
322 EVP_CIPH_FLAG_DEFAULT_ASN1,
318 .init = des_init_key, 323 .init = des_init_key,
319 .do_cipher = des_cfb1_cipher, 324 .do_cipher = des_cfb1_cipher,
320 .cleanup = NULL, 325 .cleanup = NULL,
321 .ctx_size = sizeof(DES_key_schedule), 326 .ctx_size = sizeof(DES_key_schedule),
322 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 327 .set_asn1_parameters = NULL,
323 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 328 .get_asn1_parameters = NULL,
324 .ctrl = des_ctrl, 329 .ctrl = des_ctrl,
325}; 330};
326 331
@@ -336,13 +341,14 @@ static const EVP_CIPHER des_cfb8 = {
336 .block_size = 1, 341 .block_size = 1,
337 .key_len = 8, 342 .key_len = 8,
338 .iv_len = 8, 343 .iv_len = 8,
339 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE, 344 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE |
345 EVP_CIPH_FLAG_DEFAULT_ASN1,
340 .init = des_init_key, 346 .init = des_init_key,
341 .do_cipher = des_cfb8_cipher, 347 .do_cipher = des_cfb8_cipher,
342 .cleanup = NULL, 348 .cleanup = NULL,
343 .ctx_size = sizeof(DES_key_schedule), 349 .ctx_size = sizeof(DES_key_schedule),
344 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 350 .set_asn1_parameters = NULL,
345 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 351 .get_asn1_parameters = NULL,
346 .ctrl = des_ctrl, 352 .ctrl = des_ctrl,
347}; 353};
348 354
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c
index 48fbcdb366..f3eb4cce1b 100644
--- a/src/lib/libcrypto/evp/e_des3.c
+++ b/src/lib/libcrypto/evp/e_des3.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_des3.c,v 1.30 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_des3.c,v 1.31 2025/05/27 03:58:12 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -258,13 +258,14 @@ static const EVP_CIPHER des_ede_cbc = {
258 .block_size = 8, 258 .block_size = 8,
259 .key_len = 16, 259 .key_len = 16,
260 .iv_len = 8, 260 .iv_len = 8,
261 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CBC_MODE, 261 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CBC_MODE |
262 EVP_CIPH_FLAG_DEFAULT_ASN1,
262 .init = des_ede_init_key, 263 .init = des_ede_init_key,
263 .do_cipher = des_ede_cbc_cipher, 264 .do_cipher = des_ede_cbc_cipher,
264 .cleanup = NULL, 265 .cleanup = NULL,
265 .ctx_size = sizeof(DES_EDE_KEY), 266 .ctx_size = sizeof(DES_EDE_KEY),
266 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 267 .set_asn1_parameters = NULL,
267 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 268 .get_asn1_parameters = NULL,
268 .ctrl = des3_ctrl, 269 .ctrl = des3_ctrl,
269}; 270};
270 271
@@ -280,13 +281,14 @@ static const EVP_CIPHER des_ede_cfb64 = {
280 .block_size = 1, 281 .block_size = 1,
281 .key_len = 16, 282 .key_len = 16,
282 .iv_len = 8, 283 .iv_len = 8,
283 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE, 284 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE |
285 EVP_CIPH_FLAG_DEFAULT_ASN1,
284 .init = des_ede_init_key, 286 .init = des_ede_init_key,
285 .do_cipher = des_ede_cfb64_cipher, 287 .do_cipher = des_ede_cfb64_cipher,
286 .cleanup = NULL, 288 .cleanup = NULL,
287 .ctx_size = sizeof(DES_EDE_KEY), 289 .ctx_size = sizeof(DES_EDE_KEY),
288 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 290 .set_asn1_parameters = NULL,
289 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 291 .get_asn1_parameters = NULL,
290 .ctrl = des3_ctrl, 292 .ctrl = des3_ctrl,
291}; 293};
292 294
@@ -307,8 +309,8 @@ static const EVP_CIPHER des_ede_ofb = {
307 .do_cipher = des_ede_ofb_cipher, 309 .do_cipher = des_ede_ofb_cipher,
308 .cleanup = NULL, 310 .cleanup = NULL,
309 .ctx_size = sizeof(DES_EDE_KEY), 311 .ctx_size = sizeof(DES_EDE_KEY),
310 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 312 .set_asn1_parameters = NULL,
311 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 313 .get_asn1_parameters = NULL,
312 .ctrl = des3_ctrl, 314 .ctrl = des3_ctrl,
313}; 315};
314 316
@@ -324,13 +326,14 @@ static const EVP_CIPHER des_ede_ecb = {
324 .block_size = 8, 326 .block_size = 8,
325 .key_len = 16, 327 .key_len = 16,
326 .iv_len = 0, 328 .iv_len = 0,
327 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_ECB_MODE, 329 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_ECB_MODE |
330 EVP_CIPH_FLAG_DEFAULT_ASN1,
328 .init = des_ede_init_key, 331 .init = des_ede_init_key,
329 .do_cipher = des_ede_ecb_cipher, 332 .do_cipher = des_ede_ecb_cipher,
330 .cleanup = NULL, 333 .cleanup = NULL,
331 .ctx_size = sizeof(DES_EDE_KEY), 334 .ctx_size = sizeof(DES_EDE_KEY),
332 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 335 .set_asn1_parameters = NULL,
333 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 336 .get_asn1_parameters = NULL,
334 .ctrl = des3_ctrl, 337 .ctrl = des3_ctrl,
335}; 338};
336 339
@@ -352,13 +355,14 @@ static const EVP_CIPHER des_ede3_cbc = {
352 .block_size = 8, 355 .block_size = 8,
353 .key_len = 24, 356 .key_len = 24,
354 .iv_len = 8, 357 .iv_len = 8,
355 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CBC_MODE, 358 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CBC_MODE |
359 EVP_CIPH_FLAG_DEFAULT_ASN1,
356 .init = des_ede3_init_key, 360 .init = des_ede3_init_key,
357 .do_cipher = des_ede3_cbc_cipher, 361 .do_cipher = des_ede3_cbc_cipher,
358 .cleanup = NULL, 362 .cleanup = NULL,
359 .ctx_size = sizeof(DES_EDE_KEY), 363 .ctx_size = sizeof(DES_EDE_KEY),
360 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 364 .set_asn1_parameters = NULL,
361 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 365 .get_asn1_parameters = NULL,
362 .ctrl = des3_ctrl, 366 .ctrl = des3_ctrl,
363}; 367};
364 368
@@ -374,13 +378,14 @@ static const EVP_CIPHER des_ede3_cfb64 = {
374 .block_size = 1, 378 .block_size = 1,
375 .key_len = 24, 379 .key_len = 24,
376 .iv_len = 8, 380 .iv_len = 8,
377 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE, 381 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE |
382 EVP_CIPH_FLAG_DEFAULT_ASN1,
378 .init = des_ede3_init_key, 383 .init = des_ede3_init_key,
379 .do_cipher = des_ede3_cfb64_cipher, 384 .do_cipher = des_ede3_cfb64_cipher,
380 .cleanup = NULL, 385 .cleanup = NULL,
381 .ctx_size = sizeof(DES_EDE_KEY), 386 .ctx_size = sizeof(DES_EDE_KEY),
382 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 387 .set_asn1_parameters = NULL,
383 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 388 .get_asn1_parameters = NULL,
384 .ctrl = des3_ctrl, 389 .ctrl = des3_ctrl,
385}; 390};
386 391
@@ -396,13 +401,14 @@ static const EVP_CIPHER des_ede3_ofb = {
396 .block_size = 1, 401 .block_size = 1,
397 .key_len = 24, 402 .key_len = 24,
398 .iv_len = 8, 403 .iv_len = 8,
399 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_OFB_MODE, 404 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_OFB_MODE |
405 EVP_CIPH_FLAG_DEFAULT_ASN1,
400 .init = des_ede3_init_key, 406 .init = des_ede3_init_key,
401 .do_cipher = des_ede3_ofb_cipher, 407 .do_cipher = des_ede3_ofb_cipher,
402 .cleanup = NULL, 408 .cleanup = NULL,
403 .ctx_size = sizeof(DES_EDE_KEY), 409 .ctx_size = sizeof(DES_EDE_KEY),
404 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 410 .set_asn1_parameters = NULL,
405 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 411 .get_asn1_parameters = NULL,
406 .ctrl = des3_ctrl, 412 .ctrl = des3_ctrl,
407}; 413};
408 414
@@ -418,13 +424,14 @@ static const EVP_CIPHER des_ede3_ecb = {
418 .block_size = 8, 424 .block_size = 8,
419 .key_len = 24, 425 .key_len = 24,
420 .iv_len = 0, 426 .iv_len = 0,
421 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_ECB_MODE, 427 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_ECB_MODE |
428 EVP_CIPH_FLAG_DEFAULT_ASN1,
422 .init = des_ede3_init_key, 429 .init = des_ede3_init_key,
423 .do_cipher = des_ede3_ecb_cipher, 430 .do_cipher = des_ede3_ecb_cipher,
424 .cleanup = NULL, 431 .cleanup = NULL,
425 .ctx_size = sizeof(DES_EDE_KEY), 432 .ctx_size = sizeof(DES_EDE_KEY),
426 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 433 .set_asn1_parameters = NULL,
427 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 434 .get_asn1_parameters = NULL,
428 .ctrl = des3_ctrl, 435 .ctrl = des3_ctrl,
429}; 436};
430 437
@@ -441,13 +448,14 @@ static const EVP_CIPHER des_ede3_cfb1 = {
441 .block_size = 1, 448 .block_size = 1,
442 .key_len = 24, 449 .key_len = 24,
443 .iv_len = 8, 450 .iv_len = 8,
444 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE, 451 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE |
452 EVP_CIPH_FLAG_DEFAULT_ASN1,
445 .init = des_ede3_init_key, 453 .init = des_ede3_init_key,
446 .do_cipher = des_ede3_cfb1_cipher, 454 .do_cipher = des_ede3_cfb1_cipher,
447 .cleanup = NULL, 455 .cleanup = NULL,
448 .ctx_size = sizeof(DES_EDE_KEY), 456 .ctx_size = sizeof(DES_EDE_KEY),
449 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 457 .set_asn1_parameters = NULL,
450 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 458 .get_asn1_parameters = NULL,
451 .ctrl = des3_ctrl, 459 .ctrl = des3_ctrl,
452}; 460};
453 461
@@ -464,13 +472,14 @@ static const EVP_CIPHER des_ede3_cfb8 = {
464 .block_size = 1, 472 .block_size = 1,
465 .key_len = 24, 473 .key_len = 24,
466 .iv_len = 8, 474 .iv_len = 8,
467 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE, 475 .flags = EVP_CIPH_RAND_KEY | EVP_CIPH_CFB_MODE |
476 EVP_CIPH_FLAG_DEFAULT_ASN1,
468 .init = des_ede3_init_key, 477 .init = des_ede3_init_key,
469 .do_cipher = des_ede3_cfb8_cipher, 478 .do_cipher = des_ede3_cfb8_cipher,
470 .cleanup = NULL, 479 .cleanup = NULL,
471 .ctx_size = sizeof(DES_EDE_KEY), 480 .ctx_size = sizeof(DES_EDE_KEY),
472 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 481 .set_asn1_parameters = NULL,
473 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 482 .get_asn1_parameters = NULL,
474 .ctrl = des3_ctrl, 483 .ctrl = des3_ctrl,
475}; 484};
476 485
diff --git a/src/lib/libcrypto/evp/e_idea.c b/src/lib/libcrypto/evp/e_idea.c
index 86cf77602a..5d33a110fd 100644
--- a/src/lib/libcrypto/evp/e_idea.c
+++ b/src/lib/libcrypto/evp/e_idea.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_idea.c,v 1.22 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_idea.c,v 1.23 2025/05/27 03:58:12 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -181,13 +181,13 @@ static const EVP_CIPHER idea_cbc = {
181 .block_size = 8, 181 .block_size = 8,
182 .key_len = 16, 182 .key_len = 16,
183 .iv_len = 8, 183 .iv_len = 8,
184 .flags = 0 | EVP_CIPH_CBC_MODE, 184 .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
185 .init = idea_init_key, 185 .init = idea_init_key,
186 .do_cipher = idea_cbc_cipher, 186 .do_cipher = idea_cbc_cipher,
187 .cleanup = NULL, 187 .cleanup = NULL,
188 .ctx_size = sizeof(IDEA_KEY_SCHEDULE), 188 .ctx_size = sizeof(IDEA_KEY_SCHEDULE),
189 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 189 .set_asn1_parameters = NULL,
190 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 190 .get_asn1_parameters = NULL,
191 .ctrl = NULL, 191 .ctrl = NULL,
192}; 192};
193 193
@@ -203,13 +203,13 @@ static const EVP_CIPHER idea_cfb64 = {
203 .block_size = 1, 203 .block_size = 1,
204 .key_len = 16, 204 .key_len = 16,
205 .iv_len = 8, 205 .iv_len = 8,
206 .flags = 0 | EVP_CIPH_CFB_MODE, 206 .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
207 .init = idea_init_key, 207 .init = idea_init_key,
208 .do_cipher = idea_cfb64_cipher, 208 .do_cipher = idea_cfb64_cipher,
209 .cleanup = NULL, 209 .cleanup = NULL,
210 .ctx_size = sizeof(IDEA_KEY_SCHEDULE), 210 .ctx_size = sizeof(IDEA_KEY_SCHEDULE),
211 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 211 .set_asn1_parameters = NULL,
212 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 212 .get_asn1_parameters = NULL,
213 .ctrl = NULL, 213 .ctrl = NULL,
214}; 214};
215 215
@@ -225,13 +225,13 @@ static const EVP_CIPHER idea_ofb = {
225 .block_size = 1, 225 .block_size = 1,
226 .key_len = 16, 226 .key_len = 16,
227 .iv_len = 8, 227 .iv_len = 8,
228 .flags = 0 | EVP_CIPH_OFB_MODE, 228 .flags = EVP_CIPH_OFB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
229 .init = idea_init_key, 229 .init = idea_init_key,
230 .do_cipher = idea_ofb_cipher, 230 .do_cipher = idea_ofb_cipher,
231 .cleanup = NULL, 231 .cleanup = NULL,
232 .ctx_size = sizeof(IDEA_KEY_SCHEDULE), 232 .ctx_size = sizeof(IDEA_KEY_SCHEDULE),
233 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 233 .set_asn1_parameters = NULL,
234 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 234 .get_asn1_parameters = NULL,
235 .ctrl = NULL, 235 .ctrl = NULL,
236}; 236};
237 237
@@ -247,13 +247,13 @@ static const EVP_CIPHER idea_ecb = {
247 .block_size = 8, 247 .block_size = 8,
248 .key_len = 16, 248 .key_len = 16,
249 .iv_len = 0, 249 .iv_len = 0,
250 .flags = 0 | EVP_CIPH_ECB_MODE, 250 .flags = EVP_CIPH_ECB_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
251 .init = idea_init_key, 251 .init = idea_init_key,
252 .do_cipher = idea_ecb_cipher, 252 .do_cipher = idea_ecb_cipher,
253 .cleanup = NULL, 253 .cleanup = NULL,
254 .ctx_size = sizeof(IDEA_KEY_SCHEDULE), 254 .ctx_size = sizeof(IDEA_KEY_SCHEDULE),
255 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 255 .set_asn1_parameters = NULL,
256 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 256 .get_asn1_parameters = NULL,
257 .ctrl = NULL, 257 .ctrl = NULL,
258}; 258};
259 259
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c
index dc404cff20..b7ba60297a 100644
--- a/src/lib/libcrypto/evp/e_rc2.c
+++ b/src/lib/libcrypto/evp/e_rc2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_rc2.c,v 1.29 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_rc2.c,v 1.30 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,11 +63,11 @@
63 63
64#ifndef OPENSSL_NO_RC2 64#ifndef OPENSSL_NO_RC2
65 65
66#include <openssl/err.h>
67#include <openssl/evp.h> 66#include <openssl/evp.h>
68#include <openssl/objects.h> 67#include <openssl/objects.h>
69#include <openssl/rc2.h> 68#include <openssl/rc2.h>
70 69
70#include "err_local.h"
71#include "evp_local.h" 71#include "evp_local.h"
72 72
73static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 73static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c
index 1e3bee0791..1c5e6c32b2 100644
--- a/src/lib/libcrypto/evp/e_xcbc_d.c
+++ b/src/lib/libcrypto/evp/e_xcbc_d.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_xcbc_d.c,v 1.18 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: e_xcbc_d.c,v 1.19 2025/05/27 03:58:12 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -88,13 +88,13 @@ static const EVP_CIPHER d_xcbc_cipher = {
88 .block_size = 8, 88 .block_size = 8,
89 .key_len = 24, 89 .key_len = 24,
90 .iv_len = 8, 90 .iv_len = 8,
91 .flags = EVP_CIPH_CBC_MODE, 91 .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1,
92 .init = desx_cbc_init_key, 92 .init = desx_cbc_init_key,
93 .do_cipher = desx_cbc_cipher, 93 .do_cipher = desx_cbc_cipher,
94 .cleanup = NULL, 94 .cleanup = NULL,
95 .ctx_size = sizeof(DESX_CBC_KEY), 95 .ctx_size = sizeof(DESX_CBC_KEY),
96 .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, 96 .set_asn1_parameters = NULL,
97 .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, 97 .get_asn1_parameters = NULL,
98 .ctrl = NULL, 98 .ctrl = NULL,
99}; 99};
100 100
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index c2b81d0576..94295e1262 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp.h,v 1.137 2024/08/31 10:38:49 tb Exp $ */ 1/* $OpenBSD: evp.h,v 1.138 2025/07/02 06:36:52 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -778,28 +778,24 @@ void *EVP_PKEY_get0(const EVP_PKEY *pkey);
778const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len); 778const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
779 779
780#ifndef OPENSSL_NO_RSA 780#ifndef OPENSSL_NO_RSA
781struct rsa_st; 781RSA *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey);
782struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey); 782RSA *EVP_PKEY_get1_RSA(const EVP_PKEY *pkey);
783struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); 783int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key);
784int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);
785#endif 784#endif
786#ifndef OPENSSL_NO_DSA 785#ifndef OPENSSL_NO_DSA
787struct dsa_st; 786DSA *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey);
788struct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey); 787DSA *EVP_PKEY_get1_DSA(const EVP_PKEY *pkey);
789struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); 788int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key);
790int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);
791#endif 789#endif
792#ifndef OPENSSL_NO_DH 790#ifndef OPENSSL_NO_DH
793struct dh_st; 791DH *EVP_PKEY_get0_DH(const EVP_PKEY *pkey);
794struct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey); 792DH *EVP_PKEY_get1_DH(const EVP_PKEY *pkey);
795struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); 793int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key);
796int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
797#endif 794#endif
798#ifndef OPENSSL_NO_EC 795#ifndef OPENSSL_NO_EC
799struct ec_key_st; 796EC_KEY *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey);
800struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey); 797EC_KEY *EVP_PKEY_get1_EC_KEY(const EVP_PKEY *pkey);
801struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); 798int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
802int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
803#endif 799#endif
804 800
805EVP_PKEY *EVP_PKEY_new(void); 801EVP_PKEY *EVP_PKEY_new(void);
diff --git a/src/lib/libcrypto/evp/evp_aead.c b/src/lib/libcrypto/evp/evp_aead.c
index b35f5157ed..fdac082217 100644
--- a/src/lib/libcrypto/evp/evp_aead.c
+++ b/src/lib/libcrypto/evp/evp_aead.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_aead.c,v 1.11 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: evp_aead.c,v 1.12 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -19,8 +19,8 @@
19#include <string.h> 19#include <string.h>
20 20
21#include <openssl/evp.h> 21#include <openssl/evp.h>
22#include <openssl/err.h>
23 22
23#include "err_local.h"
24#include "evp_local.h" 24#include "evp_local.h"
25 25
26size_t 26size_t
diff --git a/src/lib/libcrypto/evp/evp_cipher.c b/src/lib/libcrypto/evp/evp_cipher.c
index e9c266d1b9..04e0e1c0b0 100644
--- a/src/lib/libcrypto/evp/evp_cipher.c
+++ b/src/lib/libcrypto/evp/evp_cipher.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_cipher.c,v 1.23 2024/04/10 15:00:38 beck Exp $ */ 1/* $OpenBSD: evp_cipher.c,v 1.28 2025/07/02 06:19:46 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -115,10 +115,10 @@
115#include <string.h> 115#include <string.h>
116 116
117#include <openssl/asn1.h> 117#include <openssl/asn1.h>
118#include <openssl/err.h>
119#include <openssl/evp.h> 118#include <openssl/evp.h>
120 119
121#include "asn1_local.h" 120#include "asn1_local.h"
121#include "err_local.h"
122#include "evp_local.h" 122#include "evp_local.h"
123 123
124int 124int
@@ -167,7 +167,7 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine,
167 } 167 }
168 168
169 if ((ctx->cipher->flags & EVP_CIPH_CTRL_INIT) != 0) { 169 if ((ctx->cipher->flags & EVP_CIPH_CTRL_INIT) != 0) {
170 if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { 170 if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL) <= 0) {
171 EVPerror(EVP_R_INITIALIZATION_ERROR); 171 EVPerror(EVP_R_INITIALIZATION_ERROR);
172 return 0; 172 return 0;
173 } 173 }
@@ -944,14 +944,20 @@ EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
944LCRYPTO_ALIAS(EVP_CIPHER_CTX_flags); 944LCRYPTO_ALIAS(EVP_CIPHER_CTX_flags);
945 945
946/* 946/*
947 * Used by CMS and its predecessors. Only GOST and RC2 have a custom method. 947 * Used by CMS and its predecessors. Only RC2 has a custom method.
948 */ 948 */
949 949
950int 950int
951EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) 951EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
952{ 952{
953 int iv_len; 953 int iv_len;
954 954
955 if (ctx->cipher->get_asn1_parameters != NULL)
956 return ctx->cipher->get_asn1_parameters(ctx, type);
957
958 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) == 0)
959 return -1;
960
955 if (type == NULL) 961 if (type == NULL)
956 return 0; 962 return 0;
957 963
@@ -970,21 +976,15 @@ EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
970} 976}
971 977
972int 978int
973EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) 979EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
974{ 980{
975 if (ctx->cipher->get_asn1_parameters != NULL) 981 int iv_len;
976 return ctx->cipher->get_asn1_parameters(ctx, type);
977
978 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
979 return EVP_CIPHER_get_asn1_iv(ctx, type);
980 982
981 return -1; 983 if (ctx->cipher->set_asn1_parameters != NULL)
982} 984 return ctx->cipher->set_asn1_parameters(ctx, type);
983 985
984int 986 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) == 0)
985EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type) 987 return -1;
986{
987 int iv_len;
988 988
989 if (type == NULL) 989 if (type == NULL)
990 return 0; 990 return 0;
@@ -998,18 +998,6 @@ EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
998 return ASN1_TYPE_set_octetstring(type, ctx->oiv, iv_len); 998 return ASN1_TYPE_set_octetstring(type, ctx->oiv, iv_len);
999} 999}
1000 1000
1001int
1002EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
1003{
1004 if (ctx->cipher->set_asn1_parameters != NULL)
1005 return ctx->cipher->set_asn1_parameters(ctx, type);
1006
1007 if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
1008 return EVP_CIPHER_set_asn1_iv(ctx, type);
1009
1010 return -1;
1011}
1012
1013/* Convert the various cipher NIDs and dummies to a proper OID NID */ 1001/* Convert the various cipher NIDs and dummies to a proper OID NID */
1014int 1002int
1015EVP_CIPHER_type(const EVP_CIPHER *cipher) 1003EVP_CIPHER_type(const EVP_CIPHER *cipher)
diff --git a/src/lib/libcrypto/evp/evp_digest.c b/src/lib/libcrypto/evp/evp_digest.c
index 0a97d25c7d..8bd6691fbf 100644
--- a/src/lib/libcrypto/evp/evp_digest.c
+++ b/src/lib/libcrypto/evp/evp_digest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_digest.c,v 1.14 2024/04/10 15:00:38 beck Exp $ */ 1/* $OpenBSD: evp_digest.c,v 1.15 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -114,10 +114,10 @@
114 114
115#include <openssl/opensslconf.h> 115#include <openssl/opensslconf.h>
116 116
117#include <openssl/err.h>
118#include <openssl/evp.h> 117#include <openssl/evp.h>
119#include <openssl/objects.h> 118#include <openssl/objects.h>
120 119
120#include "err_local.h"
121#include "evp_local.h" 121#include "evp_local.h"
122 122
123int 123int
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index e7c7ec3294..128bec0ac3 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_key.c,v 1.36 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: evp_key.c,v 1.37 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,12 +59,12 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/ui.h> 64#include <openssl/ui.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67 66
67#include "err_local.h"
68#include "evp_local.h" 68#include "evp_local.h"
69 69
70/* should be init to zeros. */ 70/* should be init to zeros. */
diff --git a/src/lib/libcrypto/evp/evp_local.h b/src/lib/libcrypto/evp/evp_local.h
index 54cd65d0af..76465643c6 100644
--- a/src/lib/libcrypto/evp/evp_local.h
+++ b/src/lib/libcrypto/evp/evp_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_local.h,v 1.25 2024/08/29 16:58:19 tb Exp $ */ 1/* $OpenBSD: evp_local.h,v 1.26 2025/05/27 03:58:12 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -353,9 +353,7 @@ struct evp_aead_ctx_st {
353}; 353};
354 354
355/* Legacy EVP_CIPHER methods used by CMS and its predecessors. */ 355/* Legacy EVP_CIPHER methods used by CMS and its predecessors. */
356int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
357int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type); 356int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
358int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
359int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type); 357int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
360 358
361int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, 359int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
diff --git a/src/lib/libcrypto/evp/evp_names.c b/src/lib/libcrypto/evp/evp_names.c
index 817d33602c..8757d191dd 100644
--- a/src/lib/libcrypto/evp/evp_names.c
+++ b/src/lib/libcrypto/evp/evp_names.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_names.c,v 1.18 2024/08/31 10:38:49 tb Exp $ */ 1/* $OpenBSD: evp_names.c,v 1.19 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -15,7 +15,6 @@
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */ 16 */
17 17
18#include <openssl/err.h>
19#include <openssl/evp.h> 18#include <openssl/evp.h>
20#include <openssl/objects.h> 19#include <openssl/objects.h>
21 20
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index 88ceb14033..cb2ace1fd0 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_pbe.c,v 1.50 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: evp_pbe.c,v 1.51 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,13 +60,13 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/err.h>
64#include <openssl/evp.h> 63#include <openssl/evp.h>
65#include <openssl/hmac.h> 64#include <openssl/hmac.h>
66#include <openssl/objects.h> 65#include <openssl/objects.h>
67#include <openssl/pkcs12.h> 66#include <openssl/pkcs12.h>
68#include <openssl/x509.h> 67#include <openssl/x509.h>
69 68
69#include "err_local.h"
70#include "evp_local.h" 70#include "evp_local.h"
71#include "hmac_local.h" 71#include "hmac_local.h"
72#include "pkcs12_local.h" 72#include "pkcs12_local.h"
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c
index a1e127352a..1c0b8b41e9 100644
--- a/src/lib/libcrypto/evp/evp_pkey.c
+++ b/src/lib/libcrypto/evp/evp_pkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_pkey.c,v 1.33 2025/02/04 04:51:34 tb Exp $ */ 1/* $OpenBSD: evp_pkey.c,v 1.34 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,10 +60,10 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/err.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
65 64
66#include "asn1_local.h" 65#include "asn1_local.h"
66#include "err_local.h"
67#include "evp_local.h" 67#include "evp_local.h"
68 68
69/* Extract a private key from a PKCS8 structure */ 69/* Extract a private key from a PKCS8 structure */
diff --git a/src/lib/libcrypto/evp/m_sigver.c b/src/lib/libcrypto/evp/m_sigver.c
index a3353854f1..66e4752242 100644
--- a/src/lib/libcrypto/evp/m_sigver.c
+++ b/src/lib/libcrypto/evp/m_sigver.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: m_sigver.c,v 1.27 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: m_sigver.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -58,11 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
65 64
65#include "err_local.h"
66#include "evp_local.h" 66#include "evp_local.h"
67 67
68static int 68static int
diff --git a/src/lib/libcrypto/evp/p_legacy.c b/src/lib/libcrypto/evp/p_legacy.c
index 01cfdbcd6a..7c958a16e3 100644
--- a/src/lib/libcrypto/evp/p_legacy.c
+++ b/src/lib/libcrypto/evp/p_legacy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_legacy.c,v 1.6 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: p_legacy.c,v 1.7 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,10 +59,10 @@
59#include <stdlib.h> 59#include <stdlib.h>
60 60
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/err.h>
63 62
64#include <openssl/rsa.h> 63#include <openssl/rsa.h>
65 64
65#include "err_local.h"
66#include "evp_local.h" 66#include "evp_local.h"
67 67
68int 68int
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c
index 95c7721303..3f88185737 100644
--- a/src/lib/libcrypto/evp/p_lib.c
+++ b/src/lib/libcrypto/evp/p_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_lib.c,v 1.61 2024/08/22 12:24:24 tb Exp $ */ 1/* $OpenBSD: p_lib.c,v 1.63 2025/07/02 06:36:52 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -111,7 +111,6 @@
111#include <openssl/bio.h> 111#include <openssl/bio.h>
112#include <openssl/cmac.h> 112#include <openssl/cmac.h>
113#include <openssl/crypto.h> 113#include <openssl/crypto.h>
114#include <openssl/err.h>
115#include <openssl/evp.h> 114#include <openssl/evp.h>
116#include <openssl/objects.h> 115#include <openssl/objects.h>
117#include <openssl/x509.h> 116#include <openssl/x509.h>
@@ -129,6 +128,7 @@
129#include <openssl/rsa.h> 128#include <openssl/rsa.h>
130#endif 129#endif
131 130
131#include "err_local.h"
132#include "evp_local.h" 132#include "evp_local.h"
133 133
134extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; 134extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;
@@ -628,7 +628,7 @@ LCRYPTO_ALIAS(EVP_PKEY_get0_hmac);
628 628
629#ifndef OPENSSL_NO_RSA 629#ifndef OPENSSL_NO_RSA
630RSA * 630RSA *
631EVP_PKEY_get0_RSA(EVP_PKEY *pkey) 631EVP_PKEY_get0_RSA(const EVP_PKEY *pkey)
632{ 632{
633 if (pkey->type == EVP_PKEY_RSA || pkey->type == EVP_PKEY_RSA_PSS) 633 if (pkey->type == EVP_PKEY_RSA || pkey->type == EVP_PKEY_RSA_PSS)
634 return pkey->pkey.rsa; 634 return pkey->pkey.rsa;
@@ -639,7 +639,7 @@ EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
639LCRYPTO_ALIAS(EVP_PKEY_get0_RSA); 639LCRYPTO_ALIAS(EVP_PKEY_get0_RSA);
640 640
641RSA * 641RSA *
642EVP_PKEY_get1_RSA(EVP_PKEY *pkey) 642EVP_PKEY_get1_RSA(const EVP_PKEY *pkey)
643{ 643{
644 RSA *rsa; 644 RSA *rsa;
645 645
@@ -665,7 +665,7 @@ LCRYPTO_ALIAS(EVP_PKEY_set1_RSA);
665 665
666#ifndef OPENSSL_NO_DSA 666#ifndef OPENSSL_NO_DSA
667DSA * 667DSA *
668EVP_PKEY_get0_DSA(EVP_PKEY *pkey) 668EVP_PKEY_get0_DSA(const EVP_PKEY *pkey)
669{ 669{
670 if (pkey->type != EVP_PKEY_DSA) { 670 if (pkey->type != EVP_PKEY_DSA) {
671 EVPerror(EVP_R_EXPECTING_A_DSA_KEY); 671 EVPerror(EVP_R_EXPECTING_A_DSA_KEY);
@@ -676,7 +676,7 @@ EVP_PKEY_get0_DSA(EVP_PKEY *pkey)
676LCRYPTO_ALIAS(EVP_PKEY_get0_DSA); 676LCRYPTO_ALIAS(EVP_PKEY_get0_DSA);
677 677
678DSA * 678DSA *
679EVP_PKEY_get1_DSA(EVP_PKEY *pkey) 679EVP_PKEY_get1_DSA(const EVP_PKEY *pkey)
680{ 680{
681 DSA *dsa; 681 DSA *dsa;
682 682
@@ -702,7 +702,7 @@ LCRYPTO_ALIAS(EVP_PKEY_set1_DSA);
702 702
703#ifndef OPENSSL_NO_EC 703#ifndef OPENSSL_NO_EC
704EC_KEY * 704EC_KEY *
705EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) 705EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey)
706{ 706{
707 if (pkey->type != EVP_PKEY_EC) { 707 if (pkey->type != EVP_PKEY_EC) {
708 EVPerror(EVP_R_EXPECTING_A_EC_KEY); 708 EVPerror(EVP_R_EXPECTING_A_EC_KEY);
@@ -713,7 +713,7 @@ EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
713LCRYPTO_ALIAS(EVP_PKEY_get0_EC_KEY); 713LCRYPTO_ALIAS(EVP_PKEY_get0_EC_KEY);
714 714
715EC_KEY * 715EC_KEY *
716EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey) 716EVP_PKEY_get1_EC_KEY(const EVP_PKEY *pkey)
717{ 717{
718 EC_KEY *key; 718 EC_KEY *key;
719 719
@@ -740,7 +740,7 @@ LCRYPTO_ALIAS(EVP_PKEY_set1_EC_KEY);
740 740
741#ifndef OPENSSL_NO_DH 741#ifndef OPENSSL_NO_DH
742DH * 742DH *
743EVP_PKEY_get0_DH(EVP_PKEY *pkey) 743EVP_PKEY_get0_DH(const EVP_PKEY *pkey)
744{ 744{
745 if (pkey->type != EVP_PKEY_DH) { 745 if (pkey->type != EVP_PKEY_DH) {
746 EVPerror(EVP_R_EXPECTING_A_DH_KEY); 746 EVPerror(EVP_R_EXPECTING_A_DH_KEY);
@@ -751,7 +751,7 @@ EVP_PKEY_get0_DH(EVP_PKEY *pkey)
751LCRYPTO_ALIAS(EVP_PKEY_get0_DH); 751LCRYPTO_ALIAS(EVP_PKEY_get0_DH);
752 752
753DH * 753DH *
754EVP_PKEY_get1_DH(EVP_PKEY *pkey) 754EVP_PKEY_get1_DH(const EVP_PKEY *pkey)
755{ 755{
756 DH *dh; 756 DH *dh;
757 757
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c
index 7f472ea716..775cf78d62 100644
--- a/src/lib/libcrypto/evp/p_sign.c
+++ b/src/lib/libcrypto/evp/p_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_sign.c,v 1.22 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: p_sign.c,v 1.23 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -58,7 +58,6 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c
index 02132e2c38..cd7482df55 100644
--- a/src/lib/libcrypto/evp/p_verify.c
+++ b/src/lib/libcrypto/evp/p_verify.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_verify.c,v 1.21 2024/04/09 13:52:41 beck Exp $ */ 1/* $OpenBSD: p_verify.c,v 1.22 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -58,7 +58,6 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
diff --git a/src/lib/libcrypto/evp/pmeth_fn.c b/src/lib/libcrypto/evp/pmeth_fn.c
index 308c434f0d..ad6c04dabb 100644
--- a/src/lib/libcrypto/evp/pmeth_fn.c
+++ b/src/lib/libcrypto/evp/pmeth_fn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pmeth_fn.c,v 1.11 2024/04/12 09:41:39 tb Exp $ */ 1/* $OpenBSD: pmeth_fn.c,v 1.12 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -59,10 +59,10 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61 61
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65 64
65#include "err_local.h"
66#include "evp_local.h" 66#include "evp_local.h"
67 67
68#define M_check_autoarg(ctx, arg, arglen, err) \ 68#define M_check_autoarg(ctx, arg, arglen, err) \
diff --git a/src/lib/libcrypto/evp/pmeth_gn.c b/src/lib/libcrypto/evp/pmeth_gn.c
index bc1c5bd7d2..fa5b446124 100644
--- a/src/lib/libcrypto/evp/pmeth_gn.c
+++ b/src/lib/libcrypto/evp/pmeth_gn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pmeth_gn.c,v 1.21 2024/08/31 09:14:21 tb Exp $ */ 1/* $OpenBSD: pmeth_gn.c,v 1.22 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -60,12 +60,12 @@
60#include <stdlib.h> 60#include <stdlib.h>
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/err.h>
64#include <openssl/evp.h> 63#include <openssl/evp.h>
65#include <openssl/objects.h> 64#include <openssl/objects.h>
66 65
67#include "asn1_local.h" 66#include "asn1_local.h"
68#include "bn_local.h" 67#include "bn_local.h"
68#include "err_local.h"
69#include "evp_local.h" 69#include "evp_local.h"
70 70
71int 71int
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c
index fbf4057c38..ce6beecad6 100644
--- a/src/lib/libcrypto/evp/pmeth_lib.c
+++ b/src/lib/libcrypto/evp/pmeth_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pmeth_lib.c,v 1.42 2025/01/20 12:57:28 tb Exp $ */ 1/* $OpenBSD: pmeth_lib.c,v 1.43 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -63,12 +63,12 @@
63 63
64#include <openssl/opensslconf.h> 64#include <openssl/opensslconf.h>
65 65
66#include <openssl/err.h>
67#include <openssl/evp.h> 66#include <openssl/evp.h>
68#include <openssl/objects.h> 67#include <openssl/objects.h>
69#include <openssl/x509v3.h> 68#include <openssl/x509v3.h>
70 69
71#include "asn1_local.h" 70#include "asn1_local.h"
71#include "err_local.h"
72#include "evp_local.h" 72#include "evp_local.h"
73 73
74extern const EVP_PKEY_METHOD cmac_pkey_meth; 74extern const EVP_PKEY_METHOD cmac_pkey_meth;
diff --git a/src/lib/libcrypto/format-pem.pl b/src/lib/libcrypto/format-pem.pl
index 5a96fe5b1d..fba3470344 100644
--- a/src/lib/libcrypto/format-pem.pl
+++ b/src/lib/libcrypto/format-pem.pl
@@ -1,5 +1,5 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2# $OpenBSD: format-pem.pl,v 1.7 2024/11/01 11:19:13 sthen Exp $ 2# $OpenBSD: format-pem.pl,v 1.8 2025/06/16 10:24:55 sthen Exp $
3# 3#
4# Copyright (c) 2016 Stuart Henderson <sthen@openbsd.org> 4# Copyright (c) 2016 Stuart Henderson <sthen@openbsd.org>
5# 5#
@@ -99,6 +99,7 @@ while(<>) {
99 99
100 my $verify = qx/openssl verify -CAfile $t $t 2>&1/; 100 my $verify = qx/openssl verify -CAfile $t $t 2>&1/;
101 if (not $verify =~ /^$t: OK$/) { 101 if (not $verify =~ /^$t: OK$/) {
102 $verify =~ s,$t: ,,;
102 print STDERR "ERROR: '$subj' cannot be verified with libressl\n---\n$verify---\n"; 103 print STDERR "ERROR: '$subj' cannot be verified with libressl\n---\n$verify---\n";
103 $ca{$o}{$subj}{'valid'} = 0; 104 $ca{$o}{$subj}{'valid'} = 0;
104 } 105 }
diff --git a/src/lib/libcrypto/hidden/crypto_namespace.h b/src/lib/libcrypto/hidden/crypto_namespace.h
index 741ad08549..43c8718ed0 100644
--- a/src/lib/libcrypto/hidden/crypto_namespace.h
+++ b/src/lib/libcrypto/hidden/crypto_namespace.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_namespace.h,v 1.4 2024/07/11 21:31:52 miod Exp $ */ 1/* $OpenBSD: crypto_namespace.h,v 1.5 2025/08/18 16:00:05 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> 3 * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org>
4 * 4 *
@@ -45,7 +45,11 @@
45# define LCRYPTO_UNUSED(x) 45# define LCRYPTO_UNUSED(x)
46# define LCRYPTO_USED(x) 46# define LCRYPTO_USED(x)
47# define LCRYPTO_ALIAS1(pre,x) 47# define LCRYPTO_ALIAS1(pre,x)
48#ifdef _MSC_VER
49# define LCRYPTO_ALIAS(x)
50#else
48# define LCRYPTO_ALIAS(x) asm("") 51# define LCRYPTO_ALIAS(x) asm("")
52#endif /* _MSC_VER */
49#endif 53#endif
50 54
51#endif /* _LIBCRYPTO_CRYPTO_NAMESPACE_H_ */ 55#endif /* _LIBCRYPTO_CRYPTO_NAMESPACE_H_ */
diff --git a/src/lib/libcrypto/hidden/openssl/bio.h b/src/lib/libcrypto/hidden/openssl/bio.h
index 03da75a795..69651cf3cb 100644
--- a/src/lib/libcrypto/hidden/openssl/bio.h
+++ b/src/lib/libcrypto/hidden/openssl/bio.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio.h,v 1.8 2024/07/09 06:14:59 beck Exp $ */ 1/* $OpenBSD: bio.h,v 1.9 2025/07/16 15:59:26 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -103,7 +103,6 @@ LCRYPTO_USED(BIO_s_socket);
103LCRYPTO_USED(BIO_s_connect); 103LCRYPTO_USED(BIO_s_connect);
104LCRYPTO_USED(BIO_s_accept); 104LCRYPTO_USED(BIO_s_accept);
105LCRYPTO_USED(BIO_s_fd); 105LCRYPTO_USED(BIO_s_fd);
106LCRYPTO_USED(BIO_s_log);
107LCRYPTO_USED(BIO_s_bio); 106LCRYPTO_USED(BIO_s_bio);
108LCRYPTO_USED(BIO_s_null); 107LCRYPTO_USED(BIO_s_null);
109LCRYPTO_USED(BIO_f_null); 108LCRYPTO_USED(BIO_f_null);
diff --git a/src/lib/libcrypto/hidden/openssl/mlkem.h b/src/lib/libcrypto/hidden/openssl/mlkem.h
index 8cd80eb3af..3807b3fa1e 100644
--- a/src/lib/libcrypto/hidden/openssl/mlkem.h
+++ b/src/lib/libcrypto/hidden/openssl/mlkem.h
@@ -1,6 +1,6 @@
1/* $OpenBSD: mlkem.h,v 1.4 2024/12/20 15:10:31 tb Exp $ */ 1/* $OpenBSD: mlkem.h,v 1.5 2025/08/14 15:48:48 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Bob Beck <beck@obtuse.com> 3 * Copyright (c) 2025 Bob Beck <beck@openbsd.org>
4 * 4 *
5 * Permission to use, copy, modify, and distribute this software for any 5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above 6 * purpose with or without fee is hereby granted, provided that the above
@@ -18,9 +18,6 @@
18#ifndef _LIBCRYPTO_MLKEM_H 18#ifndef _LIBCRYPTO_MLKEM_H
19#define _LIBCRYPTO_MLKEM_H 19#define _LIBCRYPTO_MLKEM_H
20 20
21/* Undo when making public */
22#ifdef LIBRESSL_HAS_MLKEM
23
24#ifndef _MSC_VER 21#ifndef _MSC_VER
25#include_next <openssl/mlkem.h> 22#include_next <openssl/mlkem.h>
26#else 23#else
@@ -28,22 +25,21 @@
28#endif 25#endif
29#include "crypto_namespace.h" 26#include "crypto_namespace.h"
30 27
31LCRYPTO_USED(MLKEM768_generate_key); 28LCRYPTO_USED(MLKEM_private_key_new);
32LCRYPTO_USED(MLKEM768_public_from_private); 29LCRYPTO_USED(MLKEM_private_key_free);
33LCRYPTO_USED(MLKEM768_encap); 30LCRYPTO_USED(MLKEM_private_key_ciphertext_length);
34LCRYPTO_USED(MLKEM768_decap); 31LCRYPTO_USED(MLKEM_private_key_encoded_length);
35LCRYPTO_USED(MLKEM768_marshal_public_key); 32LCRYPTO_USED(MLKEM_public_key_new);
36LCRYPTO_USED(MLKEM768_parse_public_key); 33LCRYPTO_USED(MLKEM_public_key_free);
37LCRYPTO_USED(MLKEM768_private_key_from_seed); 34LCRYPTO_USED(MLKEM_public_key_ciphertext_length);
38LCRYPTO_USED(MLKEM768_parse_private_key); 35LCRYPTO_USED(MLKEM_public_key_encoded_length);
39LCRYPTO_USED(MLKEM1024_generate_key); 36LCRYPTO_USED(MLKEM_generate_key);
40LCRYPTO_USED(MLKEM1024_public_from_private); 37LCRYPTO_USED(MLKEM_private_key_from_seed);
41LCRYPTO_USED(MLKEM1024_encap); 38LCRYPTO_USED(MLKEM_public_from_private);
42LCRYPTO_USED(MLKEM1024_decap); 39LCRYPTO_USED(MLKEM_encap);
43LCRYPTO_USED(MLKEM1024_marshal_public_key); 40LCRYPTO_USED(MLKEM_decap);
44LCRYPTO_USED(MLKEM1024_parse_public_key); 41LCRYPTO_USED(MLKEM_marshal_public_key);
45LCRYPTO_USED(MLKEM1024_private_key_from_seed); 42LCRYPTO_USED(MLKEM_parse_public_key);
46LCRYPTO_USED(MLKEM1024_parse_private_key); 43LCRYPTO_USED(MLKEM_parse_private_key);
47#endif /* LIBRESSL_HAS_MLKEM */
48 44
49#endif /* _LIBCRYPTO_MLKEM_H */ 45#endif /* _LIBCRYPTO_MLKEM_H */
diff --git a/src/lib/libcrypto/hidden/openssl/pem.h b/src/lib/libcrypto/hidden/openssl/pem.h
index 5838f07f4d..233fd8859b 100644
--- a/src/lib/libcrypto/hidden/openssl/pem.h
+++ b/src/lib/libcrypto/hidden/openssl/pem.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem.h,v 1.2 2023/07/07 19:37:54 beck Exp $ */ 1/* $OpenBSD: pem.h,v 1.3 2025/07/16 15:59:26 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -33,12 +33,10 @@ LCRYPTO_USED(PEM_bytes_read_bio);
33LCRYPTO_USED(PEM_ASN1_read_bio); 33LCRYPTO_USED(PEM_ASN1_read_bio);
34LCRYPTO_USED(PEM_ASN1_write_bio); 34LCRYPTO_USED(PEM_ASN1_write_bio);
35LCRYPTO_USED(PEM_X509_INFO_read_bio); 35LCRYPTO_USED(PEM_X509_INFO_read_bio);
36LCRYPTO_USED(PEM_X509_INFO_write_bio);
37LCRYPTO_USED(PEM_read); 36LCRYPTO_USED(PEM_read);
38LCRYPTO_USED(PEM_write); 37LCRYPTO_USED(PEM_write);
39LCRYPTO_USED(PEM_ASN1_read); 38LCRYPTO_USED(PEM_ASN1_read);
40LCRYPTO_USED(PEM_ASN1_write); 39LCRYPTO_USED(PEM_ASN1_write);
41LCRYPTO_USED(PEM_X509_INFO_read);
42LCRYPTO_USED(PEM_SignInit); 40LCRYPTO_USED(PEM_SignInit);
43LCRYPTO_USED(PEM_SignUpdate); 41LCRYPTO_USED(PEM_SignUpdate);
44LCRYPTO_USED(PEM_SignFinal); 42LCRYPTO_USED(PEM_SignFinal);
diff --git a/src/lib/libcrypto/hidden/openssl/x509.h b/src/lib/libcrypto/hidden/openssl/x509.h
index e6104cd451..5e78f7af97 100644
--- a/src/lib/libcrypto/hidden/openssl/x509.h
+++ b/src/lib/libcrypto/hidden/openssl/x509.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509.h,v 1.15 2025/03/09 15:17:22 tb Exp $ */ 1/* $OpenBSD: x509.h,v 1.16 2025/07/16 15:59:26 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2022 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -401,8 +401,6 @@ LCRYPTO_USED(i2d_X509_CRL);
401LCRYPTO_USED(X509_CRL_add0_revoked); 401LCRYPTO_USED(X509_CRL_add0_revoked);
402LCRYPTO_USED(X509_CRL_get0_by_serial); 402LCRYPTO_USED(X509_CRL_get0_by_serial);
403LCRYPTO_USED(X509_CRL_get0_by_cert); 403LCRYPTO_USED(X509_CRL_get0_by_cert);
404LCRYPTO_USED(X509_PKEY_new);
405LCRYPTO_USED(X509_PKEY_free);
406LCRYPTO_USED(NETSCAPE_SPKI_new); 404LCRYPTO_USED(NETSCAPE_SPKI_new);
407LCRYPTO_USED(NETSCAPE_SPKI_free); 405LCRYPTO_USED(NETSCAPE_SPKI_free);
408LCRYPTO_USED(d2i_NETSCAPE_SPKI); 406LCRYPTO_USED(d2i_NETSCAPE_SPKI);
diff --git a/src/lib/libcrypto/hkdf/hkdf.c b/src/lib/libcrypto/hkdf/hkdf.c
index 6104ef0cc7..f68df4bea4 100644
--- a/src/lib/libcrypto/hkdf/hkdf.c
+++ b/src/lib/libcrypto/hkdf/hkdf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hkdf.c,v 1.11 2024/03/25 13:09:13 jsing Exp $ */ 1/* $OpenBSD: hkdf.c,v 1.12 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -19,10 +19,10 @@
19 19
20#include <string.h> 20#include <string.h>
21 21
22#include <openssl/err.h>
23#include <openssl/hmac.h> 22#include <openssl/hmac.h>
24 23
25#include "bytestring.h" 24#include "bytestring.h"
25#include "err_local.h"
26#include "evp_local.h" 26#include "evp_local.h"
27#include "hmac_local.h" 27#include "hmac_local.h"
28 28
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index dc1614d3ce..e3d5664143 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hmac.c,v 1.36 2024/08/31 10:42:21 tb Exp $ */ 1/* $OpenBSD: hmac.c,v 1.37 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,9 +60,9 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/err.h>
64#include <openssl/hmac.h> 63#include <openssl/hmac.h>
65 64
65#include "err_local.h"
66#include "evp_local.h" 66#include "evp_local.h"
67#include "hmac_local.h" 67#include "hmac_local.h"
68 68
diff --git a/src/lib/libcrypto/idea/idea.h b/src/lib/libcrypto/idea/idea.h
index 2bdd3647fd..fccef8fc73 100644
--- a/src/lib/libcrypto/idea/idea.h
+++ b/src/lib/libcrypto/idea/idea.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: idea.h,v 1.13 2025/01/25 17:59:44 tb Exp $ */ 1/* $OpenBSD: idea.h,v 1.14 2025/06/09 14:37:49 tb Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,7 +59,12 @@
59#ifndef HEADER_IDEA_H 59#ifndef HEADER_IDEA_H
60#define HEADER_IDEA_H 60#define HEADER_IDEA_H
61 61
62#include <openssl/opensslconf.h> /* IDEA_INT, OPENSSL_NO_IDEA */ 62#include <openssl/opensslconf.h> /* OPENSSL_NO_IDEA */
63
64#ifndef IDEA_INT
65/* XXX - typedef */
66#define IDEA_INT unsigned int
67#endif
63 68
64#define IDEA_ENCRYPT 1 69#define IDEA_ENCRYPT 1
65#define IDEA_DECRYPT 0 70#define IDEA_DECRYPT 0
diff --git a/src/lib/libcrypto/kdf/hkdf_evp.c b/src/lib/libcrypto/kdf/hkdf_evp.c
index b33e2e0a26..dee6e35d82 100644
--- a/src/lib/libcrypto/kdf/hkdf_evp.c
+++ b/src/lib/libcrypto/kdf/hkdf_evp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hkdf_evp.c,v 1.20 2023/06/26 08:57:17 tb Exp $ */ 1/* $OpenBSD: hkdf_evp.c,v 1.22 2025/05/21 03:53:20 kenjiro Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2016-2018 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2016-2018 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -50,12 +50,11 @@
50#include <stdlib.h> 50#include <stdlib.h>
51#include <string.h> 51#include <string.h>
52 52
53#include <openssl/err.h>
54#include <openssl/evp.h>
55#include <openssl/hmac.h> 53#include <openssl/hmac.h>
56#include <openssl/hkdf.h> 54#include <openssl/hkdf.h>
57#include <openssl/kdf.h> 55#include <openssl/kdf.h>
58 56
57#include "err_local.h"
59#include "evp_local.h" 58#include "evp_local.h"
60 59
61#define HKDF_MAXBUF 1024 60#define HKDF_MAXBUF 1024
@@ -91,6 +90,9 @@ pkey_hkdf_cleanup(EVP_PKEY_CTX *ctx)
91{ 90{
92 HKDF_PKEY_CTX *kctx = ctx->data; 91 HKDF_PKEY_CTX *kctx = ctx->data;
93 92
93 if (kctx == NULL)
94 return;
95
94 freezero(kctx->salt, kctx->salt_len); 96 freezero(kctx->salt, kctx->salt_len);
95 freezero(kctx->key, kctx->key_len); 97 freezero(kctx->key, kctx->key_len);
96 freezero(kctx, sizeof(*kctx)); 98 freezero(kctx, sizeof(*kctx));
diff --git a/src/lib/libcrypto/kdf/tls1_prf.c b/src/lib/libcrypto/kdf/tls1_prf.c
index 7d6231e3c7..2b86ff744f 100644
--- a/src/lib/libcrypto/kdf/tls1_prf.c
+++ b/src/lib/libcrypto/kdf/tls1_prf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls1_prf.c,v 1.40 2024/07/10 06:53:27 tb Exp $ */ 1/* $OpenBSD: tls1_prf.c,v 1.42 2025/05/21 03:53:20 kenjiro Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4 * 2016. 4 * 2016.
@@ -61,10 +61,10 @@
61#include <stdio.h> 61#include <stdio.h>
62#include <string.h> 62#include <string.h>
63 63
64#include <openssl/err.h>
65#include <openssl/evp.h> 64#include <openssl/evp.h>
66#include <openssl/kdf.h> 65#include <openssl/kdf.h>
67 66
67#include "err_local.h"
68#include "evp_local.h" 68#include "evp_local.h"
69 69
70#define TLS1_PRF_MAXBUF 1024 70#define TLS1_PRF_MAXBUF 1024
@@ -96,6 +96,9 @@ pkey_tls1_prf_cleanup(EVP_PKEY_CTX *ctx)
96{ 96{
97 struct tls1_prf_ctx *kctx = ctx->data; 97 struct tls1_prf_ctx *kctx = ctx->data;
98 98
99 if (kctx == NULL)
100 return;
101
99 freezero(kctx->secret, kctx->secret_len); 102 freezero(kctx->secret, kctx->secret_len);
100 freezero(kctx, sizeof(*kctx)); 103 freezero(kctx, sizeof(*kctx));
101} 104}
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c
index aa532267de..ad6ece543b 100644
--- a/src/lib/libcrypto/lhash/lhash.c
+++ b/src/lib/libcrypto/lhash/lhash.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: lhash.c,v 1.28 2024/07/14 14:32:45 jsing Exp $ */ 1/* $OpenBSD: lhash.c,v 1.29 2025/05/01 00:35:23 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -115,11 +115,11 @@ expand(_LHASH *lh)
115#endif 115#endif
116 if ((hash % nni) != p) { /* move it */ 116 if ((hash % nni) != p) { /* move it */
117 *n1 = (*n1)->next; 117 *n1 = (*n1)->next;
118 np->next= *n2; 118 np->next = *n2;
119 *n2 = np; 119 *n2 = np;
120 } else 120 } else
121 n1 = &((*n1)->next); 121 n1 = &((*n1)->next);
122 np= *n1; 122 np = *n1;
123 } 123 }
124 124
125 if ((lh->p) >= lh->pmax) { 125 if ((lh->p) >= lh->pmax) {
@@ -305,7 +305,7 @@ lh_delete(_LHASH *lh, const void *data)
305 if (*rn == NULL) { 305 if (*rn == NULL) {
306 return (NULL); 306 return (NULL);
307 } else { 307 } else {
308 nn= *rn; 308 nn = *rn;
309 *rn = nn->next; 309 *rn = nn->next;
310 ret = nn->data; 310 ret = nn->data;
311 free(nn); 311 free(nn);
diff --git a/src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3 b/src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3
index 15156ffca3..bfa915c8af 100644
--- a/src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3
+++ b/src/lib/libcrypto/man/ACCESS_DESCRIPTION_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ACCESS_DESCRIPTION_new.3,v 1.6 2022/03/31 17:27:16 naddy Exp $ 1.\" $OpenBSD: ACCESS_DESCRIPTION_new.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 31 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ACCESS_DESCRIPTION_NEW 3 18.Dt ACCESS_DESCRIPTION_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm AUTHORITY_INFO_ACCESS_free 24.Nm AUTHORITY_INFO_ACCESS_free
25.Nd X.509 information access extensions 25.Nd X.509 information access extensions
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509v3.h 28.In openssl/x509v3.h
28.Ft ACCESS_DESCRIPTION * 29.Ft ACCESS_DESCRIPTION *
29.Fn ACCESS_DESCRIPTION_new void 30.Fn ACCESS_DESCRIPTION_new void
diff --git a/src/lib/libcrypto/man/AES_encrypt.3 b/src/lib/libcrypto/man/AES_encrypt.3
index f022848a61..4ceece648e 100644
--- a/src/lib/libcrypto/man/AES_encrypt.3
+++ b/src/lib/libcrypto/man/AES_encrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: AES_encrypt.3,v 1.1 2019/08/28 10:37:42 schwarze Exp $ 1.\" $OpenBSD: AES_encrypt.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 28 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt AES_ENCRYPT 3 18.Dt AES_ENCRYPT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.Nm AES_cbc_encrypt 25.Nm AES_cbc_encrypt
26.Nd low-level interface to the AES symmetric cipher 26.Nd low-level interface to the AES symmetric cipher
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/aes.h 29.In openssl/aes.h
29.Ft int 30.Ft int
30.Fo AES_set_encrypt_key 31.Fo AES_set_encrypt_key
diff --git a/src/lib/libcrypto/man/ASIdentifiers_new.3 b/src/lib/libcrypto/man/ASIdentifiers_new.3
index d8473b81a0..f5f4a1215e 100644
--- a/src/lib/libcrypto/man/ASIdentifiers_new.3
+++ b/src/lib/libcrypto/man/ASIdentifiers_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASIdentifiers_new.3,v 1.11 2023/09/30 18:16:44 tb Exp $ 1.\" $OpenBSD: ASIdentifiers_new.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 30 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASIDENTIFIERS_NEW 3 18.Dt ASIDENTIFIERS_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm i2d_ASIdentifiers 24.Nm i2d_ASIdentifiers
25.Nd RFC 3779 autonomous system identifier delegation extensions 25.Nd RFC 3779 autonomous system identifier delegation extensions
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509v3.h 28.In openssl/x509v3.h
28.Ft ASIdentifiers * 29.Ft ASIdentifiers *
29.Fo ASIdentifiers_new 30.Fo ASIdentifiers_new
diff --git a/src/lib/libcrypto/man/ASN1_BIT_STRING_set.3 b/src/lib/libcrypto/man/ASN1_BIT_STRING_set.3
index a916ca3ab2..d3ab3b1ee0 100644
--- a/src/lib/libcrypto/man/ASN1_BIT_STRING_set.3
+++ b/src/lib/libcrypto/man/ASN1_BIT_STRING_set.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_BIT_STRING_set.3,v 1.5 2024/12/24 09:48:56 schwarze Exp $ 1.\" $OpenBSD: ASN1_BIT_STRING_set.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 24 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_BIT_STRING_SET 3 18.Dt ASN1_BIT_STRING_SET 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm ASN1_BIT_STRING_get_bit 23.Nm ASN1_BIT_STRING_get_bit
24.Nd ASN.1 BIT STRING accessors 24.Nd ASN.1 BIT STRING accessors
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/asn1.h 27.In openssl/asn1.h
27.Ft int 28.Ft int
28.Fo ASN1_BIT_STRING_set 29.Fo ASN1_BIT_STRING_set
diff --git a/src/lib/libcrypto/man/ASN1_INTEGER_get.3 b/src/lib/libcrypto/man/ASN1_INTEGER_get.3
index 84f566eda9..985e2e5084 100644
--- a/src/lib/libcrypto/man/ASN1_INTEGER_get.3
+++ b/src/lib/libcrypto/man/ASN1_INTEGER_get.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_INTEGER_get.3,v 1.7 2023/05/22 19:38:04 tb Exp $ 1.\" $OpenBSD: ASN1_INTEGER_get.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" selective merge up to: 2.\" selective merge up to:
3.\" OpenSSL man3/ASN1_INTEGER_get_int64 24a535ea Sep 22 13:14:20 2020 +0100 3.\" OpenSSL man3/ASN1_INTEGER_get_int64 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: May 22 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt ASN1_INTEGER_GET 3 70.Dt ASN1_INTEGER_GET 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -88,6 +88,7 @@
88.Nm ASN1_ENUMERATED_to_BN 88.Nm ASN1_ENUMERATED_to_BN
89.Nd ASN.1 INTEGER and ENUMERATED utilities 89.Nd ASN.1 INTEGER and ENUMERATED utilities
90.Sh SYNOPSIS 90.Sh SYNOPSIS
91.Lb libcrypto
91.In openssl/asn1.h 92.In openssl/asn1.h
92.Ft int 93.Ft int
93.Fo ASN1_INTEGER_get_uint64 94.Fo ASN1_INTEGER_get_uint64
diff --git a/src/lib/libcrypto/man/ASN1_NULL_new.3 b/src/lib/libcrypto/man/ASN1_NULL_new.3
index b4d2428ed1..1244f2e252 100644
--- a/src/lib/libcrypto/man/ASN1_NULL_new.3
+++ b/src/lib/libcrypto/man/ASN1_NULL_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_NULL_new.3,v 1.3 2021/12/09 18:42:35 schwarze Exp $ 1.\" $OpenBSD: ASN1_NULL_new.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 9 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_NULL_NEW 3 18.Dt ASN1_NULL_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm ASN1_NULL_free 22.Nm ASN1_NULL_free
23.Nd ASN.1 NULL value 23.Nd ASN.1 NULL value
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/asn1.h 26.In openssl/asn1.h
26.Ft ASN1_NULL * 27.Ft ASN1_NULL *
27.Fn ASN1_NULL_new void 28.Fn ASN1_NULL_new void
diff --git a/src/lib/libcrypto/man/ASN1_OBJECT_new.3 b/src/lib/libcrypto/man/ASN1_OBJECT_new.3
index 3e2eac02ee..3df3dd8e68 100644
--- a/src/lib/libcrypto/man/ASN1_OBJECT_new.3
+++ b/src/lib/libcrypto/man/ASN1_OBJECT_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_OBJECT_new.3,v 1.16 2023/09/05 15:01:39 schwarze Exp $ 1.\" $OpenBSD: ASN1_OBJECT_new.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d4 Mar 19 12:28:58 2016 -0400 2.\" full merge up to: OpenSSL 99d63d4 Mar 19 12:28:58 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: September 5 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt ASN1_OBJECT_NEW 3 69.Dt ASN1_OBJECT_NEW 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -74,6 +74,7 @@
74.Nm ASN1_OBJECT_free 74.Nm ASN1_OBJECT_free
75.Nd ASN.1 object identifiers 75.Nd ASN.1 object identifiers
76.Sh SYNOPSIS 76.Sh SYNOPSIS
77.Lb libcrypto
77.In openssl/asn1.h 78.In openssl/asn1.h
78.Ft ASN1_OBJECT * 79.Ft ASN1_OBJECT *
79.Fo ASN1_OBJECT_new 80.Fo ASN1_OBJECT_new
diff --git a/src/lib/libcrypto/man/ASN1_PRINTABLE_type.3 b/src/lib/libcrypto/man/ASN1_PRINTABLE_type.3
index 391dd32e66..47288ee960 100644
--- a/src/lib/libcrypto/man/ASN1_PRINTABLE_type.3
+++ b/src/lib/libcrypto/man/ASN1_PRINTABLE_type.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_PRINTABLE_type.3,v 1.1 2021/11/15 13:39:40 schwarze Exp $ 1.\" $OpenBSD: ASN1_PRINTABLE_type.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 15 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_PRINTABLE_TYPE 3 18.Dt ASN1_PRINTABLE_TYPE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm ASN1_PRINTABLE_type 21.Nm ASN1_PRINTABLE_type
22.Nd classify a single-byte character string 22.Nd classify a single-byte character string
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/asn1.h 25.In openssl/asn1.h
25.Ft int 26.Ft int
26.Fo ASN1_PRINTABLE_type 27.Fo ASN1_PRINTABLE_type
diff --git a/src/lib/libcrypto/man/ASN1_STRING_TABLE_get.3 b/src/lib/libcrypto/man/ASN1_STRING_TABLE_get.3
index 2bf8831c12..4149b73d34 100644
--- a/src/lib/libcrypto/man/ASN1_STRING_TABLE_get.3
+++ b/src/lib/libcrypto/man/ASN1_STRING_TABLE_get.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_STRING_TABLE_get.3,v 1.4 2023/12/21 21:23:37 tb Exp $ 1.\" $OpenBSD: ASN1_STRING_TABLE_get.3,v 1.5 2025/06/08 22:37:23 schwarze Exp $
2.\" checked up to: 2.\" checked up to:
3.\" OpenSSL ASN1_STRING_TABLE_add.pod 7b608d08 Jul 27 01:18:50 2017 +0800 3.\" OpenSSL ASN1_STRING_TABLE_add.pod 7b608d08 Jul 27 01:18:50 2017 +0800
4.\" 4.\"
@@ -16,17 +16,15 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: December 21 2023 $ 19.Dd $Mdocdate: June 8 2025 $
20.Dt ASN1_STRING_TABLE_GET 3 20.Dt ASN1_STRING_TABLE_GET 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
23.\" .Nm ASN1_STRING_TABLE_add0 and
24.\" .Nm ASN1_STRING_TABLE_cleanup are intentionally undocumented
25.\" because they will be removed in the next major bump
26.\" .Dv STABLE_FLAGS_MALLOC is intentionally undocumented because it is unused 23.\" .Dv STABLE_FLAGS_MALLOC is intentionally undocumented because it is unused
27.Nm ASN1_STRING_TABLE_get 24.Nm ASN1_STRING_TABLE_get
28.Nd retrieve an entry from the global ASN.1 string table 25.Nd retrieve an entry from the global ASN.1 string table
29.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
30.In openssl/asn1.h 28.In openssl/asn1.h
31.Ft ASN1_STRING_TABLE * 29.Ft ASN1_STRING_TABLE *
32.Fo ASN1_STRING_TABLE_get 30.Fo ASN1_STRING_TABLE_get
diff --git a/src/lib/libcrypto/man/ASN1_STRING_length.3 b/src/lib/libcrypto/man/ASN1_STRING_length.3
index 0c397607a9..922ae89ac6 100644
--- a/src/lib/libcrypto/man/ASN1_STRING_length.3
+++ b/src/lib/libcrypto/man/ASN1_STRING_length.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_STRING_length.3,v 1.30 2024/12/27 15:30:17 schwarze Exp $ 1.\" $OpenBSD: ASN1_STRING_length.3,v 1.31 2025/06/08 22:37:23 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: December 27 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt ASN1_STRING_LENGTH 3 70.Dt ASN1_STRING_LENGTH 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -84,10 +84,9 @@
84.Nm ASN1_STRING_copy , 84.Nm ASN1_STRING_copy ,
85.Nm ASN1_STRING_to_UTF8 , 85.Nm ASN1_STRING_to_UTF8 ,
86.Nm ASN1_STRING_type 86.Nm ASN1_STRING_type
87.\" deprecated aliases, intentionally undocumented:
88.\" M_ASN1_STRING_data, M_ASN1_STRING_length
89.Nd ASN1_STRING utility functions 87.Nd ASN1_STRING utility functions
90.Sh SYNOPSIS 88.Sh SYNOPSIS
89.Lb libcrypto
91.In openssl/asn1.h 90.In openssl/asn1.h
92.Ft int 91.Ft int
93.Fo ASN1_STRING_cmp 92.Fo ASN1_STRING_cmp
diff --git a/src/lib/libcrypto/man/ASN1_STRING_new.3 b/src/lib/libcrypto/man/ASN1_STRING_new.3
index 212bacd413..d653b70dda 100644
--- a/src/lib/libcrypto/man/ASN1_STRING_new.3
+++ b/src/lib/libcrypto/man/ASN1_STRING_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_STRING_new.3,v 1.27 2024/12/27 15:30:17 schwarze Exp $ 1.\" $OpenBSD: ASN1_STRING_new.3,v 1.28 2025/06/08 22:37:23 schwarze Exp $
2.\" OpenSSL 99d63d46 Tue Mar 24 07:52:24 2015 -0400 2.\" OpenSSL 99d63d46 Tue Mar 24 07:52:24 2015 -0400
3.\" 3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: December 27 2024 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt ASN1_STRING_NEW 3 19.Dt ASN1_STRING_NEW 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -58,10 +58,9 @@
58.Nm ASN1_UTCTIME_free , 58.Nm ASN1_UTCTIME_free ,
59.Nm ASN1_TIME_new , 59.Nm ASN1_TIME_new ,
60.Nm ASN1_TIME_free 60.Nm ASN1_TIME_free
61.\" deprecated aliases, intentionally undocumented: M_ASN1_IA5STRING_new,
62.\" M_ASN1_ENUMERATED_free, M_ASN1_INTEGER_free, M_ASN1_OCTET_STRING_free
63.Nd allocate and free ASN1_STRING objects 61.Nd allocate and free ASN1_STRING objects
64.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
65.In openssl/asn1.h 64.In openssl/asn1.h
66.Ft ASN1_STRING * 65.Ft ASN1_STRING *
67.Fn ASN1_STRING_new void 66.Fn ASN1_STRING_new void
diff --git a/src/lib/libcrypto/man/ASN1_STRING_print_ex.3 b/src/lib/libcrypto/man/ASN1_STRING_print_ex.3
index eb43b2fe5c..8295b3e9dd 100644
--- a/src/lib/libcrypto/man/ASN1_STRING_print_ex.3
+++ b/src/lib/libcrypto/man/ASN1_STRING_print_ex.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_STRING_print_ex.3,v 1.18 2021/12/14 19:36:18 schwarze Exp $ 1.\" $OpenBSD: ASN1_STRING_print_ex.3,v 1.19 2025/06/08 22:37:23 schwarze Exp $
2.\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 2.\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: December 14 2021 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt ASN1_STRING_PRINT_EX 3 54.Dt ASN1_STRING_PRINT_EX 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -58,9 +58,9 @@
58.Nm ASN1_STRING_print_ex_fp , 58.Nm ASN1_STRING_print_ex_fp ,
59.Nm ASN1_STRING_print , 59.Nm ASN1_STRING_print ,
60.Nm ASN1_tag2str 60.Nm ASN1_tag2str
61.\" M_ASN1_OCTET_STRING_print is a deprecated alias, intentionally undocumented
62.Nd ASN1_STRING output routines 61.Nd ASN1_STRING output routines
63.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
64.In openssl/asn1.h 64.In openssl/asn1.h
65.Ft int 65.Ft int
66.Fo ASN1_STRING_print_ex 66.Fo ASN1_STRING_print_ex
diff --git a/src/lib/libcrypto/man/ASN1_TIME_set.3 b/src/lib/libcrypto/man/ASN1_TIME_set.3
index 233cb13f2c..8cfcf4339b 100644
--- a/src/lib/libcrypto/man/ASN1_TIME_set.3
+++ b/src/lib/libcrypto/man/ASN1_TIME_set.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_TIME_set.3,v 1.23 2024/03/05 18:30:40 tb Exp $ 1.\" $OpenBSD: ASN1_TIME_set.3,v 1.24 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 3d0f1cb9 Jul 11 03:01:24 2017 +0800 2.\" full merge up to: OpenSSL 3d0f1cb9 Jul 11 03:01:24 2017 +0800
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: March 5 2024 $ 71.Dd $Mdocdate: June 8 2025 $
72.Dt ASN1_TIME_SET 3 72.Dt ASN1_TIME_SET 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -101,6 +101,7 @@
101.Nm OPENSSL_tm_to_posix 101.Nm OPENSSL_tm_to_posix
102.Nd ASN.1 Time functions 102.Nd ASN.1 Time functions
103.Sh SYNOPSIS 103.Sh SYNOPSIS
104.Lb libcrypto
104.In openssl/asn1.h 105.In openssl/asn1.h
105.Ft ASN1_TIME * 106.Ft ASN1_TIME *
106.Fo ASN1_TIME_set 107.Fo ASN1_TIME_set
diff --git a/src/lib/libcrypto/man/ASN1_TYPE_get.3 b/src/lib/libcrypto/man/ASN1_TYPE_get.3
index 16af168d91..3b3359b6ff 100644
--- a/src/lib/libcrypto/man/ASN1_TYPE_get.3
+++ b/src/lib/libcrypto/man/ASN1_TYPE_get.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_TYPE_get.3,v 1.19 2023/10/09 16:06:01 tb Exp $ 1.\" $OpenBSD: ASN1_TYPE_get.3,v 1.20 2025/06/08 22:40:29 schwarze Exp $
2.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200 2.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: October 9 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt ASN1_TYPE_GET 3 69.Dt ASN1_TYPE_GET 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -81,6 +81,7 @@
81.Nm ASN1_TYPE_cmp 81.Nm ASN1_TYPE_cmp
82.Nd ASN.1 objects of arbitrary type 82.Nd ASN.1 objects of arbitrary type
83.Sh SYNOPSIS 83.Sh SYNOPSIS
84.Lb libcrypto
84.In openssl/asn1.h 85.In openssl/asn1.h
85.Ft ASN1_TYPE * 86.Ft ASN1_TYPE *
86.Fn ASN1_TYPE_new void 87.Fn ASN1_TYPE_new void
diff --git a/src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.3 b/src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.3
index 2af675295b..c76956107f 100644
--- a/src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.3
+++ b/src/lib/libcrypto/man/ASN1_UNIVERSALSTRING_to_string.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_UNIVERSALSTRING_to_string.3,v 1.1 2021/11/15 13:39:40 schwarze Exp $ 1.\" $OpenBSD: ASN1_UNIVERSALSTRING_to_string.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 15 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_UNIVERSALSTRING_TO_STRING 3 18.Dt ASN1_UNIVERSALSTRING_TO_STRING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm ASN1_UNIVERSALSTRING_to_string 21.Nm ASN1_UNIVERSALSTRING_to_string
22.Nd recode UTF-32 to ISO Latin-1 22.Nd recode UTF-32 to ISO Latin-1
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/asn1.h 25.In openssl/asn1.h
25.Ft int 26.Ft int
26.Fo ASN1_UNIVERSALSTRING_to_string 27.Fo ASN1_UNIVERSALSTRING_to_string
diff --git a/src/lib/libcrypto/man/ASN1_generate_nconf.3 b/src/lib/libcrypto/man/ASN1_generate_nconf.3
index b15d4295a9..ed92bb13b6 100644
--- a/src/lib/libcrypto/man/ASN1_generate_nconf.3
+++ b/src/lib/libcrypto/man/ASN1_generate_nconf.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_generate_nconf.3,v 1.13 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: ASN1_generate_nconf.3,v 1.14 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 05ea606a Fri May 20 20:52:46 2016 -0400 2.\" OpenSSL 05ea606a Fri May 20 20:52:46 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson. 4.\" This file was written by Dr. Stephen Henson.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 10 2019 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt ASN1_GENERATE_NCONF 3 53.Dt ASN1_GENERATE_NCONF 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm ASN1_generate_v3 57.Nm ASN1_generate_v3
58.Nd ASN.1 generation functions 58.Nd ASN.1 generation functions
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/asn1.h 61.In openssl/asn1.h
61.Ft ASN1_TYPE * 62.Ft ASN1_TYPE *
62.Fo ASN1_generate_nconf 63.Fo ASN1_generate_nconf
diff --git a/src/lib/libcrypto/man/ASN1_get_object.3 b/src/lib/libcrypto/man/ASN1_get_object.3
index 781b12ad5a..7f92ff6d05 100644
--- a/src/lib/libcrypto/man/ASN1_get_object.3
+++ b/src/lib/libcrypto/man/ASN1_get_object.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_get_object.3,v 1.2 2021/07/11 19:03:45 schwarze Exp $ 1.\" $OpenBSD: ASN1_get_object.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 11 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_GET_OBJECT 3 18.Dt ASN1_GET_OBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm ASN1_get_object 21.Nm ASN1_get_object
22.Nd parse identifier and length octets 22.Nd parse identifier and length octets
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/asn1.h 25.In openssl/asn1.h
25.Ft int 26.Ft int
26.Fo ASN1_get_object 27.Fo ASN1_get_object
diff --git a/src/lib/libcrypto/man/ASN1_item_d2i.3 b/src/lib/libcrypto/man/ASN1_item_d2i.3
index bc99f4a6da..cb5fd19f28 100644
--- a/src/lib/libcrypto/man/ASN1_item_d2i.3
+++ b/src/lib/libcrypto/man/ASN1_item_d2i.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_d2i.3,v 1.18 2023/05/01 07:37:45 tb Exp $ 1.\" $OpenBSD: ASN1_item_d2i.3,v 1.19 2025/06/08 22:40:29 schwarze Exp $
2.\" selective merge up to: 2.\" selective merge up to:
3.\" OpenSSL doc/man3/d2i_X509.pod 256989ce Jun 19 15:00:32 2020 +0200 3.\" OpenSSL doc/man3/d2i_X509.pod 256989ce Jun 19 15:00:32 2020 +0200
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: May 1 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt ASN1_ITEM_D2I 3 70.Dt ASN1_ITEM_D2I 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -82,6 +82,7 @@
82.Nm ASN1_item_print 82.Nm ASN1_item_print
83.Nd decode and encode ASN.1 objects 83.Nd decode and encode ASN.1 objects
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/asn1.h 86.In openssl/asn1.h
86.Ft ASN1_VALUE * 87.Ft ASN1_VALUE *
87.Fo ASN1_item_d2i 88.Fo ASN1_item_d2i
diff --git a/src/lib/libcrypto/man/ASN1_item_digest.3 b/src/lib/libcrypto/man/ASN1_item_digest.3
index 56a97555e9..829b82a56b 100644
--- a/src/lib/libcrypto/man/ASN1_item_digest.3
+++ b/src/lib/libcrypto/man/ASN1_item_digest.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_digest.3,v 1.2 2022/09/11 04:39:46 jsg Exp $ 1.\" $OpenBSD: ASN1_item_digest.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 11 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_ITEM_DIGEST 3 18.Dt ASN1_ITEM_DIGEST 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm ASN1_item_digest 21.Nm ASN1_item_digest
22.Nd DER-encode and hash an ASN.1 value 22.Nd DER-encode and hash an ASN.1 value
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/x509.h 25.In openssl/x509.h
25.Ft int 26.Ft int
26.Fo ASN1_item_digest 27.Fo ASN1_item_digest
diff --git a/src/lib/libcrypto/man/ASN1_item_new.3 b/src/lib/libcrypto/man/ASN1_item_new.3
index 7015ed6319..42e9dd8f68 100644
--- a/src/lib/libcrypto/man/ASN1_item_new.3
+++ b/src/lib/libcrypto/man/ASN1_item_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_new.3,v 1.11 2022/01/12 17:54:51 tb Exp $ 1.\" $OpenBSD: ASN1_item_new.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016, 2018 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016, 2018 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 12 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_ITEM_NEW 3 18.Dt ASN1_ITEM_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm ASN1_item_free 22.Nm ASN1_item_free
23.Nd generic ASN.1 value constructor and destructor 23.Nd generic ASN.1 value constructor and destructor
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/asn1.h 26.In openssl/asn1.h
26.Ft ASN1_VALUE * 27.Ft ASN1_VALUE *
27.Fo ASN1_item_new 28.Fo ASN1_item_new
diff --git a/src/lib/libcrypto/man/ASN1_item_pack.3 b/src/lib/libcrypto/man/ASN1_item_pack.3
index 4c87530622..d0023f599d 100644
--- a/src/lib/libcrypto/man/ASN1_item_pack.3
+++ b/src/lib/libcrypto/man/ASN1_item_pack.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_pack.3,v 1.1 2021/11/15 11:51:09 schwarze Exp $ 1.\" $OpenBSD: ASN1_item_pack.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 15 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_ITEM_PACK 3 18.Dt ASN1_ITEM_PACK 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm ASN1_item_unpack 22.Nm ASN1_item_unpack
23.Nd pack an ASN.1 object into an ASN1_STRING 23.Nd pack an ASN.1 object into an ASN1_STRING
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/asn1.h 26.In openssl/asn1.h
26.Ft ASN1_STRING * 27.Ft ASN1_STRING *
27.Fo ASN1_item_pack 28.Fo ASN1_item_pack
diff --git a/src/lib/libcrypto/man/ASN1_item_sign.3 b/src/lib/libcrypto/man/ASN1_item_sign.3
index 8c09fe77ff..72e317c310 100644
--- a/src/lib/libcrypto/man/ASN1_item_sign.3
+++ b/src/lib/libcrypto/man/ASN1_item_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_sign.3,v 1.3 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: ASN1_item_sign.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 6 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_ITEM_SIGN 3 18.Dt ASN1_ITEM_SIGN 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm ASN1_item_sign_ctx 22.Nm ASN1_item_sign_ctx
23.Nd DER-encode and sign an ASN.1 value 23.Nd DER-encode and sign an ASN.1 value
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509.h 26.In openssl/x509.h
26.Ft int 27.Ft int
27.Fo ASN1_item_sign 28.Fo ASN1_item_sign
diff --git a/src/lib/libcrypto/man/ASN1_item_verify.3 b/src/lib/libcrypto/man/ASN1_item_verify.3
index d2810879e3..282db875bb 100644
--- a/src/lib/libcrypto/man/ASN1_item_verify.3
+++ b/src/lib/libcrypto/man/ASN1_item_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_verify.3,v 1.3 2021/12/18 17:47:44 schwarze Exp $ 1.\" $OpenBSD: ASN1_item_verify.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 18 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_ITEM_VERIFY 3 18.Dt ASN1_ITEM_VERIFY 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm ASN1_item_verify 21.Nm ASN1_item_verify
22.Nd signature verification for ASN.1 values 22.Nd signature verification for ASN.1 values
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/x509.h 25.In openssl/x509.h
25.Ft int 26.Ft int
26.Fo ASN1_item_verify 27.Fo ASN1_item_verify
diff --git a/src/lib/libcrypto/man/ASN1_mbstring_copy.3 b/src/lib/libcrypto/man/ASN1_mbstring_copy.3
index e0b48aaa62..6a64bc7464 100644
--- a/src/lib/libcrypto/man/ASN1_mbstring_copy.3
+++ b/src/lib/libcrypto/man/ASN1_mbstring_copy.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_mbstring_copy.3,v 1.6 2022/02/21 00:22:03 jsg Exp $ 1.\" $OpenBSD: ASN1_mbstring_copy.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: February 21 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_MBSTRING_COPY 3 18.Dt ASN1_MBSTRING_COPY 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.Nm ASN1_tag2bit 27.Nm ASN1_tag2bit
28.Nd copy a multibyte string into an ASN.1 string object 28.Nd copy a multibyte string into an ASN.1 string object
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/asn1.h 31.In openssl/asn1.h
31.Ft int 32.Ft int
32.Fo ASN1_mbstring_copy 33.Fo ASN1_mbstring_copy
diff --git a/src/lib/libcrypto/man/ASN1_parse_dump.3 b/src/lib/libcrypto/man/ASN1_parse_dump.3
index 50761f38aa..45aa673d4c 100644
--- a/src/lib/libcrypto/man/ASN1_parse_dump.3
+++ b/src/lib/libcrypto/man/ASN1_parse_dump.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_parse_dump.3,v 1.3 2021/12/09 18:52:09 schwarze Exp $ 1.\" $OpenBSD: ASN1_parse_dump.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 9 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_PARSE_DUMP 3 18.Dt ASN1_PARSE_DUMP 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm ASN1_parse 22.Nm ASN1_parse
23.Nd parse BER and print information about it 23.Nd parse BER and print information about it
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/asn1.h 26.In openssl/asn1.h
26.Ft int 27.Ft int
27.Fo ASN1_parse_dump 28.Fo ASN1_parse_dump
diff --git a/src/lib/libcrypto/man/ASN1_put_object.3 b/src/lib/libcrypto/man/ASN1_put_object.3
index 97a352724c..94fa55366a 100644
--- a/src/lib/libcrypto/man/ASN1_put_object.3
+++ b/src/lib/libcrypto/man/ASN1_put_object.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_put_object.3,v 1.5 2022/01/12 17:54:51 tb Exp $ 1.\" $OpenBSD: ASN1_put_object.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 12 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ASN1_PUT_OBJECT 3 18.Dt ASN1_PUT_OBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm ASN1_object_size 23.Nm ASN1_object_size
24.Nd start and end the BER encoding of an arbitrary ASN.1 data element 24.Nd start and end the BER encoding of an arbitrary ASN.1 data element
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/asn1.h 27.In openssl/asn1.h
27.Ft void 28.Ft void
28.Fo ASN1_put_object 29.Fo ASN1_put_object
diff --git a/src/lib/libcrypto/man/ASRange_new.3 b/src/lib/libcrypto/man/ASRange_new.3
index dc58c98e58..b507213b48 100644
--- a/src/lib/libcrypto/man/ASRange_new.3
+++ b/src/lib/libcrypto/man/ASRange_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASRange_new.3,v 1.8 2023/10/11 12:06:11 tb Exp $ 1.\" $OpenBSD: ASRange_new.3,v 1.10 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 11 2023 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt ASRANGE_NEW 3 18.Dt ASRANGE_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,8 +32,9 @@
32.Nm i2d_ASIdentifierChoice 32.Nm i2d_ASIdentifierChoice
33.Nd RFC 3779 autonomous system identifiers and ranges 33.Nd RFC 3779 autonomous system identifiers and ranges
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/x509v3.h 36.In openssl/x509v3.h
36.Ft "ASRange *" 37.Ft ASRange *
37.Fn ASRange_new void 38.Fn ASRange_new void
38.Ft void 39.Ft void
39.Fn ASRange_free "ASRange *asrange" 40.Fn ASRange_free "ASRange *asrange"
@@ -48,7 +49,7 @@
48.Fa "ASRange *asrange" 49.Fa "ASRange *asrange"
49.Fa "unsigned char **der_out" 50.Fa "unsigned char **der_out"
50.Fc 51.Fc
51.Ft "ASIdOrRange *" 52.Ft ASIdOrRange *
52.Fn ASIdOrRange_new void 53.Fn ASIdOrRange_new void
53.Ft void 54.Ft void
54.Fn ASIdOrRange_free "ASIdOrRange *aor" 55.Fn ASIdOrRange_free "ASIdOrRange *aor"
@@ -63,7 +64,7 @@
63.Fa "ASIdOrRange *aor" 64.Fa "ASIdOrRange *aor"
64.Fa "unsigned char **der_out" 65.Fa "unsigned char **der_out"
65.Fc 66.Fc
66.Ft "ASIdentifierChoice *" 67.Ft ASIdentifierChoice *
67.Fn ASIdentifierChoice_new void 68.Fn ASIdentifierChoice_new void
68.Ft void 69.Ft void
69.Fn ASIdentifierChoice_free "ASIdentifierChoice *aic" 70.Fn ASIdentifierChoice_free "ASIdentifierChoice *aic"
diff --git a/src/lib/libcrypto/man/AUTHORITY_KEYID_new.3 b/src/lib/libcrypto/man/AUTHORITY_KEYID_new.3
index bff451ff36..982685d17f 100644
--- a/src/lib/libcrypto/man/AUTHORITY_KEYID_new.3
+++ b/src/lib/libcrypto/man/AUTHORITY_KEYID_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: AUTHORITY_KEYID_new.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $ 1.\" $OpenBSD: AUTHORITY_KEYID_new.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt AUTHORITY_KEYID_NEW 3 18.Dt AUTHORITY_KEYID_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm AUTHORITY_KEYID_free 22.Nm AUTHORITY_KEYID_free
23.Nd X.509 authority key identifier extension 23.Nd X.509 authority key identifier extension
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft AUTHORITY_KEYID * 27.Ft AUTHORITY_KEYID *
27.Fn AUTHORITY_KEYID_new void 28.Fn AUTHORITY_KEYID_new void
diff --git a/src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.3 b/src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.3
index e60b0d223c..f1b1486a8a 100644
--- a/src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.3
+++ b/src/lib/libcrypto/man/BASIC_CONSTRAINTS_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BASIC_CONSTRAINTS_new.3,v 1.6 2021/10/27 11:24:47 schwarze Exp $ 1.\" $OpenBSD: BASIC_CONSTRAINTS_new.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 27 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BASIC_CONSTRAINTS_NEW 3 18.Dt BASIC_CONSTRAINTS_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm BASIC_CONSTRAINTS_free 22.Nm BASIC_CONSTRAINTS_free
23.Nd X.509 extension to mark CA certificates 23.Nd X.509 extension to mark CA certificates
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft BASIC_CONSTRAINTS * 27.Ft BASIC_CONSTRAINTS *
27.Fn BASIC_CONSTRAINTS_new void 28.Fn BASIC_CONSTRAINTS_new void
diff --git a/src/lib/libcrypto/man/BF_set_key.3 b/src/lib/libcrypto/man/BF_set_key.3
index 5f4c7a689b..1299a0f2ef 100644
--- a/src/lib/libcrypto/man/BF_set_key.3
+++ b/src/lib/libcrypto/man/BF_set_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BF_set_key.3,v 1.12 2023/08/05 18:27:55 jmc Exp $ 1.\" $OpenBSD: BF_set_key.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 99d63d46 Jul 19 09:27:53 2016 -0400 2.\" OpenSSL 99d63d46 Jul 19 09:27:53 2016 -0400
3.\" 3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>. 4.\" This file was written by Richard Levitte <levitte@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: August 5 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt BF_SET_KEY 3 53.Dt BF_SET_KEY 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -62,6 +62,7 @@
62.Nm BF_ofb64_encrypt 62.Nm BF_ofb64_encrypt
63.Nd Blowfish encryption 63.Nd Blowfish encryption
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libcrypto
65.In openssl/blowfish.h 66.In openssl/blowfish.h
66.Ft void 67.Ft void
67.Fo BF_set_key 68.Fo BF_set_key
diff --git a/src/lib/libcrypto/man/BIO_accept.3 b/src/lib/libcrypto/man/BIO_accept.3
index e2547ac0dd..73b415017f 100644
--- a/src/lib/libcrypto/man/BIO_accept.3
+++ b/src/lib/libcrypto/man/BIO_accept.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_accept.3,v 1.2 2023/04/30 13:38:48 schwarze Exp $ 1.\" $OpenBSD: BIO_accept.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 30 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BIO_ACCEPT 3 18.Dt BIO_ACCEPT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -43,6 +43,7 @@
43.\" .Nm BIO_sock_cleanup 43.\" .Nm BIO_sock_cleanup
44.Nd wrappers for socket operations 44.Nd wrappers for socket operations
45.Sh SYNOPSIS 45.Sh SYNOPSIS
46.Lb libcrypto
46.In openssl/bio.h 47.In openssl/bio.h
47.Ft int 48.Ft int
48.Fo BIO_get_host_ip 49.Fo BIO_get_host_ip
diff --git a/src/lib/libcrypto/man/BIO_ctrl.3 b/src/lib/libcrypto/man/BIO_ctrl.3
index 2c537956e1..ca13f2067b 100644
--- a/src/lib/libcrypto/man/BIO_ctrl.3
+++ b/src/lib/libcrypto/man/BIO_ctrl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_ctrl.3,v 1.25 2023/11/16 20:19:23 schwarze Exp $ 1.\" $OpenBSD: BIO_ctrl.3,v 1.26 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535eaf Tue Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL 24a535eaf Tue Sep 22 13:14:20 2020 +0100
3.\" selective merge up to: OpenSSL 0c5bc96f Tue Mar 15 13:57:22 2022 +0000 3.\" selective merge up to: OpenSSL 0c5bc96f Tue Mar 15 13:57:22 2022 +0000
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: November 16 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BIO_CTRL 3 70.Dt BIO_CTRL 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -91,6 +91,7 @@
91.Nm bio_info_cb 91.Nm bio_info_cb
92.Nd BIO control operations 92.Nd BIO control operations
93.Sh SYNOPSIS 93.Sh SYNOPSIS
94.Lb libcrypto
94.In openssl/bio.h 95.In openssl/bio.h
95.Ft long 96.Ft long
96.Fo BIO_ctrl 97.Fo BIO_ctrl
diff --git a/src/lib/libcrypto/man/BIO_dump.3 b/src/lib/libcrypto/man/BIO_dump.3
index 8817f0c4ca..2c06c8cc9c 100644
--- a/src/lib/libcrypto/man/BIO_dump.3
+++ b/src/lib/libcrypto/man/BIO_dump.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_dump.3,v 1.4 2022/12/20 15:34:03 schwarze Exp $ 1.\" $OpenBSD: BIO_dump.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,19 +14,15 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 20 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BIO_DUMP 3 18.Dt BIO_DUMP 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm BIO_dump , 21.Nm BIO_dump ,
22.Nm BIO_dump_indent , 22.Nm BIO_dump_indent
23.Nm BIO_dump_fp ,
24.Nm BIO_dump_indent_fp
25.\" intentionally undocumented because nothing uses these two functions:
26.\" .Nm BIO_dump_cb
27.\" .Nm BIO_dump_indent_cb
28.Nd hexadecimal printout of arbitrary byte arrays 23.Nd hexadecimal printout of arbitrary byte arrays
29.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
30.In openssl/bio.h 26.In openssl/bio.h
31.Ft int 27.Ft int
32.Fo BIO_dump 28.Fo BIO_dump
@@ -41,19 +37,6 @@
41.Fa "int len" 37.Fa "int len"
42.Fa "int indent" 38.Fa "int indent"
43.Fc 39.Fc
44.Ft int
45.Fo BIO_dump_fp
46.Fa "FILE *fp"
47.Fa "const char *s"
48.Fa "int len"
49.Fc
50.Ft int
51.Fo BIO_dump_indent_fp
52.Fa "FILE *fp"
53.Fa "const char *s"
54.Fa "int len"
55.Fa "int indent"
56.Fc
57.Sh DESCRIPTION 40.Sh DESCRIPTION
58.Fn BIO_dump 41.Fn BIO_dump
59prints 42prints
@@ -92,14 +75,6 @@ If
92.Fa indent 75.Fa indent
93is 7 or more, the number of data columns is reduced such that the 76is 7 or more, the number of data columns is reduced such that the
94total width of the output does not exceed 79 characters per line. 77total width of the output does not exceed 79 characters per line.
95.Pp
96.Fn BIO_dump_fp
97and
98.Fn BIO_dump_indent_fp
99are similar except that
100.Xr fwrite 3
101is used instead of
102.Xr BIO_write 3 .
103.Sh RETURN VALUES 78.Sh RETURN VALUES
104On success these functions return the total number of bytes written by 79On success these functions return the total number of bytes written by
105.Xr BIO_write 3 80.Xr BIO_write 3
@@ -120,9 +95,3 @@ first appeared in SSLeay 0.6.5 and has been available since
120.Fn BIO_dump_indent 95.Fn BIO_dump_indent
121first appeared in OpenSSL 0.9.6 and has been available since 96first appeared in OpenSSL 0.9.6 and has been available since
122.Ox 2.9 . 97.Ox 2.9 .
123.Pp
124.Fn BIO_dump_fp
125and
126.Fn BIO_dump_indent_fp
127first appeared in OpenSSL 0.9.8 and have been available since
128.Ox 4.5 .
diff --git a/src/lib/libcrypto/man/BIO_dup_chain.3 b/src/lib/libcrypto/man/BIO_dup_chain.3
index 5c5e8c6533..ad753e71a5 100644
--- a/src/lib/libcrypto/man/BIO_dup_chain.3
+++ b/src/lib/libcrypto/man/BIO_dup_chain.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_dup_chain.3,v 1.2 2023/04/09 06:27:52 jsg Exp $ 1.\" $OpenBSD: BIO_dup_chain.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 9 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BIO_DUP_CHAIN 3 18.Dt BIO_DUP_CHAIN 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm BIO_dup_state 22.Nm BIO_dup_state
23.Nd copy a BIO chain 23.Nd copy a BIO chain
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/bio.h 26.In openssl/bio.h
26.Ft BIO * 27.Ft BIO *
27.Fn BIO_dup_chain "BIO *b" 28.Fn BIO_dup_chain "BIO *b"
diff --git a/src/lib/libcrypto/man/BIO_f_base64.3 b/src/lib/libcrypto/man/BIO_f_base64.3
index e4589de035..f652dac100 100644
--- a/src/lib/libcrypto/man/BIO_f_base64.3
+++ b/src/lib/libcrypto/man/BIO_f_base64.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_f_base64.3,v 1.15 2023/09/11 04:00:40 jsg Exp $ 1.\" $OpenBSD: BIO_f_base64.3,v 1.16 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL fc1d88f0 Wed Jul 2 22:42:40 2014 -0400 2.\" OpenSSL fc1d88f0 Wed Jul 2 22:42:40 2014 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: September 11 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt BIO_F_BASE64 3 53.Dt BIO_F_BASE64 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -60,6 +60,7 @@
60.\" and practically unused outside evp/bio_b64.c. 60.\" and practically unused outside evp/bio_b64.c.
61.Nd base64 BIO filter 61.Nd base64 BIO filter
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/bio.h 64.In openssl/bio.h
64.In openssl/evp.h 65.In openssl/evp.h
65.Ft const BIO_METHOD * 66.Ft const BIO_METHOD *
diff --git a/src/lib/libcrypto/man/BIO_f_buffer.3 b/src/lib/libcrypto/man/BIO_f_buffer.3
index a3012c5c5d..28c4f3166f 100644
--- a/src/lib/libcrypto/man/BIO_f_buffer.3
+++ b/src/lib/libcrypto/man/BIO_f_buffer.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_f_buffer.3,v 1.17 2023/04/29 12:22:08 schwarze Exp $ 1.\" $OpenBSD: BIO_f_buffer.3,v 1.18 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: April 29 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BIO_F_BUFFER 3 70.Dt BIO_F_BUFFER 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -82,6 +82,7 @@
82.\" whatever that is supposed to be, but are NOOPs, and nothing uses them. 82.\" whatever that is supposed to be, but are NOOPs, and nothing uses them.
83.Nd buffering BIO 83.Nd buffering BIO
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/bio.h 86.In openssl/bio.h
86.Ft const BIO_METHOD * 87.Ft const BIO_METHOD *
87.Fo BIO_f_buffer 88.Fo BIO_f_buffer
diff --git a/src/lib/libcrypto/man/BIO_f_cipher.3 b/src/lib/libcrypto/man/BIO_f_cipher.3
index c5d00c6981..3f7fe7bfaf 100644
--- a/src/lib/libcrypto/man/BIO_f_cipher.3
+++ b/src/lib/libcrypto/man/BIO_f_cipher.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_f_cipher.3,v 1.16 2023/04/29 12:01:53 schwarze Exp $ 1.\" $OpenBSD: BIO_f_cipher.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 29 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt BIO_F_CIPHER 3 53.Dt BIO_F_CIPHER 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -60,6 +60,7 @@
60.\" .Nm BIO_CTRL_SET is intentionally undocumented because it has no effect. 60.\" .Nm BIO_CTRL_SET is intentionally undocumented because it has no effect.
61.Nd cipher BIO filter 61.Nd cipher BIO filter
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/bio.h 64.In openssl/bio.h
64.In openssl/evp.h 65.In openssl/evp.h
65.Ft const BIO_METHOD * 66.Ft const BIO_METHOD *
diff --git a/src/lib/libcrypto/man/BIO_f_md.3 b/src/lib/libcrypto/man/BIO_f_md.3
index 279aabc980..ba5a0d9b85 100644
--- a/src/lib/libcrypto/man/BIO_f_md.3
+++ b/src/lib/libcrypto/man/BIO_f_md.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_f_md.3,v 1.15 2023/04/28 16:20:01 schwarze Exp $ 1.\" $OpenBSD: BIO_f_md.3,v 1.16 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: April 28 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BIO_F_MD 3 70.Dt BIO_F_MD 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -77,6 +77,7 @@
77.Nm BIO_set_md_ctx 77.Nm BIO_set_md_ctx
78.Nd message digest BIO filter 78.Nd message digest BIO filter
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libcrypto
80.In openssl/bio.h 81.In openssl/bio.h
81.In openssl/evp.h 82.In openssl/evp.h
82.Ft const BIO_METHOD * 83.Ft const BIO_METHOD *
diff --git a/src/lib/libcrypto/man/BIO_f_null.3 b/src/lib/libcrypto/man/BIO_f_null.3
index 687d991b52..ea75a242a4 100644
--- a/src/lib/libcrypto/man/BIO_f_null.3
+++ b/src/lib/libcrypto/man/BIO_f_null.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_f_null.3,v 1.12 2023/04/11 16:58:43 schwarze Exp $ 1.\" $OpenBSD: BIO_f_null.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 11 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BIO_F_NULL 3 52.Dt BIO_F_NULL 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.\" except in openssl(1) s_client/s_server -nbio_test. 58.\" except in openssl(1) s_client/s_server -nbio_test.
59.Nd null filter 59.Nd null filter
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/bio.h 62.In openssl/bio.h
62.Ft const BIO_METHOD * 63.Ft const BIO_METHOD *
63.Fo BIO_f_null 64.Fo BIO_f_null
diff --git a/src/lib/libcrypto/man/BIO_find_type.3 b/src/lib/libcrypto/man/BIO_find_type.3
index 4a9eee7832..88f36032c7 100644
--- a/src/lib/libcrypto/man/BIO_find_type.3
+++ b/src/lib/libcrypto/man/BIO_find_type.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_find_type.3,v 1.12 2023/07/26 20:01:04 tb Exp $ 1.\" $OpenBSD: BIO_find_type.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100 2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: July 26 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BIO_FIND_TYPE 3 69.Dt BIO_FIND_TYPE 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -75,6 +75,7 @@
75.Nm BIO_method_name 75.Nm BIO_method_name
76.Nd BIO chain traversal 76.Nd BIO chain traversal
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/bio.h 79.In openssl/bio.h
79.Ft BIO * 80.Ft BIO *
80.Fo BIO_find_type 81.Fo BIO_find_type
diff --git a/src/lib/libcrypto/man/BIO_get_data.3 b/src/lib/libcrypto/man/BIO_get_data.3
index 63750ac37b..26783929b1 100644
--- a/src/lib/libcrypto/man/BIO_get_data.3
+++ b/src/lib/libcrypto/man/BIO_get_data.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_get_data.3,v 1.8 2023/11/16 20:27:43 schwarze Exp $ 1.\" $OpenBSD: BIO_get_data.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: November 16 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BIO_GET_DATA 3 69.Dt BIO_GET_DATA 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -87,6 +87,7 @@
87.Nm BIO_get_shutdown 87.Nm BIO_get_shutdown
88.Nd manage BIO state information 88.Nd manage BIO state information
89.Sh SYNOPSIS 89.Sh SYNOPSIS
90.Lb libcrypto
90.In openssl/bio.h 91.In openssl/bio.h
91.Ft void 92.Ft void
92.Fo BIO_set_data 93.Fo BIO_set_data
diff --git a/src/lib/libcrypto/man/BIO_get_ex_new_index.3 b/src/lib/libcrypto/man/BIO_get_ex_new_index.3
index 54d00775e7..13d20e14a8 100644
--- a/src/lib/libcrypto/man/BIO_get_ex_new_index.3
+++ b/src/lib/libcrypto/man/BIO_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_get_ex_new_index.3,v 1.17 2023/11/19 10:26:36 tb Exp $ 1.\" $OpenBSD: BIO_get_ex_new_index.3,v 1.18 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 3.\"
4.\" This file was written by Rich Salz <rsalz@akamai.com>. 4.\" This file was written by Rich Salz <rsalz@akamai.com>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 19 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BIO_GET_EX_NEW_INDEX 3 52.Dt BIO_GET_EX_NEW_INDEX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -68,6 +68,7 @@
68.Nm EC_KEY_set_ex_data 68.Nm EC_KEY_set_ex_data
69.Nd application-specific data 69.Nd application-specific data
70.Sh SYNOPSIS 70.Sh SYNOPSIS
71.Lb libcrypto
71.In openssl/bio.h 72.In openssl/bio.h
72.In openssl/ui.h 73.In openssl/ui.h
73.In openssl/x509.h 74.In openssl/x509.h
diff --git a/src/lib/libcrypto/man/BIO_meth_new.3 b/src/lib/libcrypto/man/BIO_meth_new.3
index 2159560596..98feac5bcc 100644
--- a/src/lib/libcrypto/man/BIO_meth_new.3
+++ b/src/lib/libcrypto/man/BIO_meth_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_meth_new.3,v 1.5 2018/07/09 09:52:18 tb Exp $ 1.\" $OpenBSD: BIO_meth_new.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: July 9 2018 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BIO_METH_NEW 3 70.Dt BIO_METH_NEW 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -91,6 +91,7 @@
91.Nm BIO_meth_set_callback_ctrl 91.Nm BIO_meth_set_callback_ctrl
92.Nd manipulate BIO_METHOD structures 92.Nd manipulate BIO_METHOD structures
93.Sh SYNOPSIS 93.Sh SYNOPSIS
94.Lb libcrypto
94.In openssl/bio.h 95.In openssl/bio.h
95.Ft int 96.Ft int
96.Fn BIO_get_new_index void 97.Fn BIO_get_new_index void
diff --git a/src/lib/libcrypto/man/BIO_new.3 b/src/lib/libcrypto/man/BIO_new.3
index f97a314826..f0079948fb 100644
--- a/src/lib/libcrypto/man/BIO_new.3
+++ b/src/lib/libcrypto/man/BIO_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_new.3,v 1.28 2023/07/26 20:01:04 tb Exp $ 1.\" $OpenBSD: BIO_new.3,v 1.29 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/BIO_new.pod fb46be03 Feb 26 11:51:31 2016 +0000 3.\" OpenSSL man3/BIO_new.pod fb46be03 Feb 26 11:51:31 2016 +0000
4.\" OpenSSL man7/bio.pod 631c37be Dec 12 16:56:50 2017 +0100 4.\" OpenSSL man7/bio.pod 631c37be Dec 12 16:56:50 2017 +0100
@@ -52,7 +52,7 @@
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE. 53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\" 54.\"
55.Dd $Mdocdate: July 26 2023 $ 55.Dd $Mdocdate: June 8 2025 $
56.Dt BIO_NEW 3 56.Dt BIO_NEW 3
57.Os 57.Os
58.Sh NAME 58.Sh NAME
@@ -64,6 +64,7 @@
64.Nm BIO_free_all 64.Nm BIO_free_all
65.Nd construct and destruct I/O abstraction objects 65.Nd construct and destruct I/O abstraction objects
66.Sh SYNOPSIS 66.Sh SYNOPSIS
67.Lb libcrypto
67.In openssl/bio.h 68.In openssl/bio.h
68.Ft BIO * 69.Ft BIO *
69.Fo BIO_new 70.Fo BIO_new
diff --git a/src/lib/libcrypto/man/BIO_new_CMS.3 b/src/lib/libcrypto/man/BIO_new_CMS.3
index ab93e1c00c..0279f704f4 100644
--- a/src/lib/libcrypto/man/BIO_new_CMS.3
+++ b/src/lib/libcrypto/man/BIO_new_CMS.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_new_CMS.3,v 1.9 2023/05/01 07:28:11 tb Exp $ 1.\" $OpenBSD: BIO_new_CMS.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bfc Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bfc Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 1 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BIO_NEW_CMS 3 52.Dt BIO_NEW_CMS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm BIO_new_CMS 55.Nm BIO_new_CMS
56.Nd CMS streaming filter BIO 56.Nd CMS streaming filter BIO
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft BIO * 60.Ft BIO *
60.Fo BIO_new_CMS 61.Fo BIO_new_CMS
diff --git a/src/lib/libcrypto/man/BIO_printf.3 b/src/lib/libcrypto/man/BIO_printf.3
index 32dec0a828..6df31ad24c 100644
--- a/src/lib/libcrypto/man/BIO_printf.3
+++ b/src/lib/libcrypto/man/BIO_printf.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_printf.3,v 1.4 2024/03/02 09:18:28 tb Exp $ 1.\" $OpenBSD: BIO_printf.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 2ca2e917 Mon Mar 20 16:25:22 2017 -0400 2.\" OpenSSL 2ca2e917 Mon Mar 20 16:25:22 2017 -0400
3.\" 3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,13 +15,14 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 2 2024 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt BIO_PRINTF 3 19.Dt BIO_PRINTF 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
22.Nm BIO_printf 22.Nm BIO_printf
23.Nd formatted output to a BIO 23.Nd formatted output to a BIO
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/bio.h 26.In openssl/bio.h
26.Ft int 27.Ft int
27.Fo BIO_printf 28.Fo BIO_printf
diff --git a/src/lib/libcrypto/man/BIO_push.3 b/src/lib/libcrypto/man/BIO_push.3
index 46c736e2c2..21b798a54f 100644
--- a/src/lib/libcrypto/man/BIO_push.3
+++ b/src/lib/libcrypto/man/BIO_push.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_push.3,v 1.14 2022/12/16 16:02:17 schwarze Exp $ 1.\" $OpenBSD: BIO_push.3,v 1.15 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL doc/man3/BIO_push.pod 791bfd91 Nov 19 20:38:27 2021 +0100 3.\" OpenSSL doc/man3/BIO_push.pod 791bfd91 Nov 19 20:38:27 2021 +0100
4.\" OpenSSL doc/man7/bio.pod 1cb7eff4 Sep 10 13:56:40 2019 +0100 4.\" OpenSSL doc/man7/bio.pod 1cb7eff4 Sep 10 13:56:40 2019 +0100
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 16 2022 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt BIO_PUSH 3 71.Dt BIO_PUSH 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -76,6 +76,7 @@
76.Nm BIO_set_next 76.Nm BIO_set_next
77.Nd manipulate BIO chains 77.Nd manipulate BIO chains
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/bio.h 80.In openssl/bio.h
80.Ft BIO * 81.Ft BIO *
81.Fo BIO_push 82.Fo BIO_push
diff --git a/src/lib/libcrypto/man/BIO_read.3 b/src/lib/libcrypto/man/BIO_read.3
index 5fea9f728a..2a65b18535 100644
--- a/src/lib/libcrypto/man/BIO_read.3
+++ b/src/lib/libcrypto/man/BIO_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_read.3,v 1.11 2022/12/18 17:40:55 schwarze Exp $ 1.\" $OpenBSD: BIO_read.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 18 2022 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BIO_READ 3 69.Dt BIO_READ 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -78,6 +78,7 @@
78.Nm BIO_number_written 78.Nm BIO_number_written
79.Nd BIO I/O functions 79.Nd BIO I/O functions
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/bio.h 82.In openssl/bio.h
82.Ft int 83.Ft int
83.Fo BIO_read 84.Fo BIO_read
diff --git a/src/lib/libcrypto/man/BIO_s_accept.3 b/src/lib/libcrypto/man/BIO_s_accept.3
index 8e88fe1c52..c5a8f6d293 100644
--- a/src/lib/libcrypto/man/BIO_s_accept.3
+++ b/src/lib/libcrypto/man/BIO_s_accept.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_accept.3,v 1.16 2023/04/29 13:06:10 schwarze Exp $ 1.\" $OpenBSD: BIO_s_accept.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL c03726ca Thu Aug 27 12:28:08 2015 -0400 2.\" full merge up to: OpenSSL c03726ca Thu Aug 27 12:28:08 2015 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: April 29 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BIO_S_ACCEPT 3 69.Dt BIO_S_ACCEPT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -80,6 +80,7 @@
80.Nm BIO_do_accept 80.Nm BIO_do_accept
81.Nd accept BIO 81.Nd accept BIO
82.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
83.In openssl/bio.h 84.In openssl/bio.h
84.Ft const BIO_METHOD * 85.Ft const BIO_METHOD *
85.Fo BIO_s_accept 86.Fo BIO_s_accept
diff --git a/src/lib/libcrypto/man/BIO_s_bio.3 b/src/lib/libcrypto/man/BIO_s_bio.3
index efda019df3..6590ff81ec 100644
--- a/src/lib/libcrypto/man/BIO_s_bio.3
+++ b/src/lib/libcrypto/man/BIO_s_bio.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_bio.3,v 1.20 2024/05/19 07:12:50 jsg Exp $ 1.\" $OpenBSD: BIO_s_bio.3,v 1.21 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by 4.\" This file was written by
@@ -53,7 +53,7 @@
53.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 53.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54.\" OF THE POSSIBILITY OF SUCH DAMAGE. 54.\" OF THE POSSIBILITY OF SUCH DAMAGE.
55.\" 55.\"
56.Dd $Mdocdate: May 19 2024 $ 56.Dd $Mdocdate: June 8 2025 $
57.Dt BIO_S_BIO 3 57.Dt BIO_S_BIO 3
58.Os 58.Os
59.Sh NAME 59.Sh NAME
@@ -71,6 +71,7 @@
71.Nm BIO_ctrl_reset_read_request 71.Nm BIO_ctrl_reset_read_request
72.Nd BIO pair BIO 72.Nd BIO pair BIO
73.Sh SYNOPSIS 73.Sh SYNOPSIS
74.Lb libcrypto
74.In openssl/bio.h 75.In openssl/bio.h
75.Ft const BIO_METHOD * 76.Ft const BIO_METHOD *
76.Fo BIO_s_bio 77.Fo BIO_s_bio
diff --git a/src/lib/libcrypto/man/BIO_s_connect.3 b/src/lib/libcrypto/man/BIO_s_connect.3
index bce68a26b9..ca7ee6d988 100644
--- a/src/lib/libcrypto/man/BIO_s_connect.3
+++ b/src/lib/libcrypto/man/BIO_s_connect.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_connect.3,v 1.19 2023/04/30 13:53:54 schwarze Exp $ 1.\" $OpenBSD: BIO_s_connect.3,v 1.20 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 0e474b8b Nov 1 15:45:49 2015 +0100 2.\" full merge up to: OpenSSL 0e474b8b Nov 1 15:45:49 2015 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: April 30 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BIO_S_CONNECT 3 69.Dt BIO_S_CONNECT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -83,6 +83,7 @@
83.Nm BIO_do_connect 83.Nm BIO_do_connect
84.Nd connect BIO 84.Nd connect BIO
85.Sh SYNOPSIS 85.Sh SYNOPSIS
86.Lb libcrypto
86.In openssl/bio.h 87.In openssl/bio.h
87.Ft const BIO_METHOD * 88.Ft const BIO_METHOD *
88.Fo BIO_s_connect 89.Fo BIO_s_connect
diff --git a/src/lib/libcrypto/man/BIO_s_datagram.3 b/src/lib/libcrypto/man/BIO_s_datagram.3
index 104823e7a7..bbe80b259c 100644
--- a/src/lib/libcrypto/man/BIO_s_datagram.3
+++ b/src/lib/libcrypto/man/BIO_s_datagram.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_datagram.3,v 1.3 2023/04/28 16:49:00 schwarze Exp $ 1.\" $OpenBSD: BIO_s_datagram.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 28 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BIO_S_DATAGRAM 3 18.Dt BIO_S_DATAGRAM 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,6 +32,7 @@
32.\" They are almost unused, and OpenBSD does not appear to support them. 32.\" They are almost unused, and OpenBSD does not appear to support them.
33.Nd datagram socket BIO 33.Nd datagram socket BIO
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/bio.h 36.In openssl/bio.h
36.Ft const BIO_METHOD * 37.Ft const BIO_METHOD *
37.Fn BIO_s_datagram void 38.Fn BIO_s_datagram void
diff --git a/src/lib/libcrypto/man/BIO_s_fd.3 b/src/lib/libcrypto/man/BIO_s_fd.3
index 852a06756a..b1165f30a1 100644
--- a/src/lib/libcrypto/man/BIO_s_fd.3
+++ b/src/lib/libcrypto/man/BIO_s_fd.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_fd.3,v 1.13 2023/11/16 20:19:23 schwarze Exp $ 1.\" $OpenBSD: BIO_s_fd.3,v 1.14 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: November 16 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BIO_S_FD 3 69.Dt BIO_S_FD 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -77,6 +77,7 @@
77.Nm BIO_fd_should_retry 77.Nm BIO_fd_should_retry
78.Nd file descriptor BIO 78.Nd file descriptor BIO
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libcrypto
80.In openssl/bio.h 81.In openssl/bio.h
81.Ft const BIO_METHOD * 82.Ft const BIO_METHOD *
82.Fo BIO_s_fd 83.Fo BIO_s_fd
diff --git a/src/lib/libcrypto/man/BIO_s_file.3 b/src/lib/libcrypto/man/BIO_s_file.3
index 14950cad13..d59e157c33 100644
--- a/src/lib/libcrypto/man/BIO_s_file.3
+++ b/src/lib/libcrypto/man/BIO_s_file.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_file.3,v 1.17 2023/11/16 20:19:23 schwarze Exp $ 1.\" $OpenBSD: BIO_s_file.3,v 1.18 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100 3.\" selective merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: November 16 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BIO_S_FILE 3 70.Dt BIO_S_FILE 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -82,6 +82,7 @@
82.\" Nm BIO_CTRL_SET_FILENAME is unused and intentionally undocumented. 82.\" Nm BIO_CTRL_SET_FILENAME is unused and intentionally undocumented.
83.Nd FILE BIO 83.Nd FILE BIO
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/bio.h 86.In openssl/bio.h
86.Ft const BIO_METHOD * 87.Ft const BIO_METHOD *
87.Fo BIO_s_file 88.Fo BIO_s_file
diff --git a/src/lib/libcrypto/man/BIO_s_mem.3 b/src/lib/libcrypto/man/BIO_s_mem.3
index d7bbf6af43..e43be66e2f 100644
--- a/src/lib/libcrypto/man/BIO_s_mem.3
+++ b/src/lib/libcrypto/man/BIO_s_mem.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_mem.3,v 1.19 2023/11/16 20:19:23 schwarze Exp $ 1.\" $OpenBSD: BIO_s_mem.3,v 1.20 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 8711efb4 Mon Apr 20 11:33:12 2009 +0000 2.\" full merge up to: OpenSSL 8711efb4 Mon Apr 20 11:33:12 2009 +0000
3.\" selective merge up to: OpenSSL 36359cec Mar 7 14:37:23 2018 +0100 3.\" selective merge up to: OpenSSL 36359cec Mar 7 14:37:23 2018 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: November 16 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt BIO_S_MEM 3 53.Dt BIO_S_MEM 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -61,6 +61,7 @@
61.Nm BIO_new_mem_buf 61.Nm BIO_new_mem_buf
62.Nd memory BIO 62.Nd memory BIO
63.Sh SYNOPSIS 63.Sh SYNOPSIS
64.Lb libcrypto
64.In openssl/bio.h 65.In openssl/bio.h
65.Ft const BIO_METHOD * 66.Ft const BIO_METHOD *
66.Fo BIO_s_mem 67.Fo BIO_s_mem
diff --git a/src/lib/libcrypto/man/BIO_s_null.3 b/src/lib/libcrypto/man/BIO_s_null.3
index 6e7cad6d37..7198797b99 100644
--- a/src/lib/libcrypto/man/BIO_s_null.3
+++ b/src/lib/libcrypto/man/BIO_s_null.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_null.3,v 1.10 2023/04/11 16:58:43 schwarze Exp $ 1.\" $OpenBSD: BIO_s_null.3,v 1.12 2025/07/16 18:10:53 tb Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,14 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 11 2023 $ 51.Dd $Mdocdate: July 16 2025 $
52.Dt BIO_S_NULL 3 52.Dt BIO_S_NULL 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm BIO_s_null 55.Nm BIO_s_null
56.\" .Nm BIO_s_log is intentionally undocumented because it is unused
57.Nd null data sink 56.Nd null data sink
58.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
59.In openssl/bio.h 59.In openssl/bio.h
60.Ft const BIO_METHOD * 60.Ft const BIO_METHOD *
61.Fo BIO_s_null 61.Fo BIO_s_null
diff --git a/src/lib/libcrypto/man/BIO_s_socket.3 b/src/lib/libcrypto/man/BIO_s_socket.3
index 402622b3bd..aebf399b2b 100644
--- a/src/lib/libcrypto/man/BIO_s_socket.3
+++ b/src/lib/libcrypto/man/BIO_s_socket.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_s_socket.3,v 1.10 2023/04/11 16:58:43 schwarze Exp $ 1.\" $OpenBSD: BIO_s_socket.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL bbdc9c98 Oct 19 22:02:21 2000 +0000 2.\" OpenSSL bbdc9c98 Oct 19 22:02:21 2000 +0000
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 11 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BIO_S_SOCKET 3 52.Dt BIO_S_SOCKET 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm BIO_new_socket 56.Nm BIO_new_socket
57.Nd socket BIO 57.Nd socket BIO
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/bio.h 60.In openssl/bio.h
60.Ft const BIO_METHOD * 61.Ft const BIO_METHOD *
61.Fo BIO_s_socket 62.Fo BIO_s_socket
diff --git a/src/lib/libcrypto/man/BIO_set_callback.3 b/src/lib/libcrypto/man/BIO_set_callback.3
index 56a0102be6..f3f40cba8e 100644
--- a/src/lib/libcrypto/man/BIO_set_callback.3
+++ b/src/lib/libcrypto/man/BIO_set_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_set_callback.3,v 1.12 2023/04/30 13:57:29 schwarze Exp $ 1.\" $OpenBSD: BIO_set_callback.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: April 30 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BIO_SET_CALLBACK 3 69.Dt BIO_SET_CALLBACK 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -85,6 +85,7 @@
85.\" .Nm BIO_cb_post 85.\" .Nm BIO_cb_post
86.Nd BIO callback functions 86.Nd BIO callback functions
87.Sh SYNOPSIS 87.Sh SYNOPSIS
88.Lb libcrypto
88.In openssl/bio.h 89.In openssl/bio.h
89.Ft typedef long 90.Ft typedef long
90.Fo (*BIO_callback_fn_ex) 91.Fo (*BIO_callback_fn_ex)
diff --git a/src/lib/libcrypto/man/BIO_should_retry.3 b/src/lib/libcrypto/man/BIO_should_retry.3
index 9b93743516..4a0948ff86 100644
--- a/src/lib/libcrypto/man/BIO_should_retry.3
+++ b/src/lib/libcrypto/man/BIO_should_retry.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_should_retry.3,v 1.11 2023/04/30 14:03:47 schwarze Exp $ 1.\" $OpenBSD: BIO_should_retry.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 57fd5170 May 13 11:24:11 2018 +0200 3.\" selective merge up to: OpenSSL 57fd5170 May 13 11:24:11 2018 +0200
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: April 30 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BIO_SHOULD_RETRY 3 70.Dt BIO_SHOULD_RETRY 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -80,6 +80,7 @@
80.Nm BIO_set_retry_reason 80.Nm BIO_set_retry_reason
81.Nd BIO retry functions 81.Nd BIO retry functions
82.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
83.In openssl/bio.h 84.In openssl/bio.h
84.Ft int 85.Ft int
85.Fo BIO_should_read 86.Fo BIO_should_read
diff --git a/src/lib/libcrypto/man/BN_CTX_new.3 b/src/lib/libcrypto/man/BN_CTX_new.3
index 336b918896..0d5a3e847c 100644
--- a/src/lib/libcrypto/man/BN_CTX_new.3
+++ b/src/lib/libcrypto/man/BN_CTX_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_CTX_new.3,v 1.10 2023/04/25 17:21:51 tb Exp $ 1.\" $OpenBSD: BN_CTX_new.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL aafbe1cc Jun 12 23:42:08 2013 +0100 2.\" OpenSSL aafbe1cc Jun 12 23:42:08 2013 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 25 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BN_CTX_NEW 3 52.Dt BN_CTX_NEW 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm BN_CTX_free 56.Nm BN_CTX_free
57.Nd allocate and free BN_CTX structures 57.Nd allocate and free BN_CTX structures
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/bn.h 60.In openssl/bn.h
60.Ft BN_CTX * 61.Ft BN_CTX *
61.Fo BN_CTX_new 62.Fo BN_CTX_new
diff --git a/src/lib/libcrypto/man/BN_CTX_start.3 b/src/lib/libcrypto/man/BN_CTX_start.3
index a2b62eff5c..27159ce90d 100644
--- a/src/lib/libcrypto/man/BN_CTX_start.3
+++ b/src/lib/libcrypto/man/BN_CTX_start.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_CTX_start.3,v 1.8 2019/08/20 10:59:09 schwarze Exp $ 1.\" $OpenBSD: BN_CTX_start.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200 2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 20 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BN_CTX_START 3 52.Dt BN_CTX_START 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm BN_CTX_end 57.Nm BN_CTX_end
58.Nd use temporary BIGNUM variables 58.Nd use temporary BIGNUM variables
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/bn.h 61.In openssl/bn.h
61.Ft void 62.Ft void
62.Fo BN_CTX_start 63.Fo BN_CTX_start
diff --git a/src/lib/libcrypto/man/BN_add.3 b/src/lib/libcrypto/man/BN_add.3
index e7de441b7a..32378f6940 100644
--- a/src/lib/libcrypto/man/BN_add.3
+++ b/src/lib/libcrypto/man/BN_add.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_add.3,v 1.20 2023/04/27 09:47:03 tb Exp $ 1.\" $OpenBSD: BN_add.3,v 1.21 2025/06/08 22:37:23 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: April 27 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BN_ADD 3 70.Dt BN_ADD 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -94,13 +94,11 @@
94.\" The following are public, but intentionally undocumented for now: 94.\" The following are public, but intentionally undocumented for now:
95.\" .Nm BN_mod_exp_mont , r \(== a ^ p (mod m) 95.\" .Nm BN_mod_exp_mont , r \(== a ^ p (mod m)
96.\" .Nm BN_mod_exp_mont_consttime , 96.\" .Nm BN_mod_exp_mont_consttime ,
97.\" .Nm BN_mod_exp_mont_word ,
98.\" .Nm BN_mod_exp_simple ,
99.\" .Nm BN_mod_exp2_mont r \(== (a1 ^ p1) * (a2 ^ p2) (mod m)
100.\" Maybe they should be deleted from <openssl/bn.h>. 97.\" Maybe they should be deleted from <openssl/bn.h>.
101.Nm BN_gcd 98.Nm BN_gcd
102.Nd arithmetic operations on BIGNUMs 99.Nd arithmetic operations on BIGNUMs
103.Sh SYNOPSIS 100.Sh SYNOPSIS
101.Lb libcrypto
104.In openssl/bn.h 102.In openssl/bn.h
105.Ft int 103.Ft int
106.Fo BN_add 104.Fo BN_add
diff --git a/src/lib/libcrypto/man/BN_add_word.3 b/src/lib/libcrypto/man/BN_add_word.3
index 161029c302..b8b45bfb2c 100644
--- a/src/lib/libcrypto/man/BN_add_word.3
+++ b/src/lib/libcrypto/man/BN_add_word.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_add_word.3,v 1.10 2022/11/22 19:02:07 schwarze Exp $ 1.\" $OpenBSD: BN_add_word.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500 2.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 22 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BN_ADD_WORD 3 52.Dt BN_ADD_WORD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm BN_mod_word 59.Nm BN_mod_word
60.Nd arithmetic functions on BIGNUMs with integers 60.Nd arithmetic functions on BIGNUMs with integers
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/bn.h 63.In openssl/bn.h
63.Ft int 64.Ft int
64.Fo BN_add_word 65.Fo BN_add_word
diff --git a/src/lib/libcrypto/man/BN_bn2bin.3 b/src/lib/libcrypto/man/BN_bn2bin.3
index 0fe9a90738..cf72e6dd1b 100644
--- a/src/lib/libcrypto/man/BN_bn2bin.3
+++ b/src/lib/libcrypto/man/BN_bn2bin.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_bn2bin.3,v 1.16 2023/07/09 06:45:03 tb Exp $ 1.\" $OpenBSD: BN_bn2bin.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> 4.\" This file was written by Ulf Moeller <ulf@openssl.org>
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: July 9 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt BN_BN2BIN 3 53.Dt BN_BN2BIN 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -69,6 +69,7 @@
69.Nm BN_mpi2bn 69.Nm BN_mpi2bn
70.Nd format conversions 70.Nd format conversions
71.Sh SYNOPSIS 71.Sh SYNOPSIS
72.Lb libcrypto
72.In openssl/bn.h 73.In openssl/bn.h
73.Ft int 74.Ft int
74.Fo BN_bn2bin 75.Fo BN_bn2bin
diff --git a/src/lib/libcrypto/man/BN_cmp.3 b/src/lib/libcrypto/man/BN_cmp.3
index ba973313f0..3837ffcd1a 100644
--- a/src/lib/libcrypto/man/BN_cmp.3
+++ b/src/lib/libcrypto/man/BN_cmp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_cmp.3,v 1.10 2022/11/22 19:02:07 schwarze Exp $ 1.\" $OpenBSD: BN_cmp.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 5b31b9df Aug 4 10:45:52 2021 +0300 2.\" full merge up to: OpenSSL 5b31b9df Aug 4 10:45:52 2021 +0300
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 22 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BN_CMP 3 52.Dt BN_CMP 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -61,6 +61,7 @@
61.Nm BN_is_odd 61.Nm BN_is_odd
62.Nd BIGNUM comparison and test functions 62.Nd BIGNUM comparison and test functions
63.Sh SYNOPSIS 63.Sh SYNOPSIS
64.Lb libcrypto
64.In openssl/bn.h 65.In openssl/bn.h
65.Ft int 66.Ft int
66.Fo BN_cmp 67.Fo BN_cmp
diff --git a/src/lib/libcrypto/man/BN_copy.3 b/src/lib/libcrypto/man/BN_copy.3
index 383255e382..5481431e97 100644
--- a/src/lib/libcrypto/man/BN_copy.3
+++ b/src/lib/libcrypto/man/BN_copy.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_copy.3,v 1.10 2021/12/06 19:45:27 schwarze Exp $ 1.\" $OpenBSD: BN_copy.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> 4.\" This file was written by Ulf Moeller <ulf@openssl.org>
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: December 6 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt BN_COPY 3 53.Dt BN_COPY 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -58,6 +58,7 @@
58.Nm BN_with_flags 58.Nm BN_with_flags
59.Nd copy BIGNUMs 59.Nd copy BIGNUMs
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/bn.h 62.In openssl/bn.h
62.Ft BIGNUM * 63.Ft BIGNUM *
63.Fo BN_copy 64.Fo BN_copy
diff --git a/src/lib/libcrypto/man/BN_generate_prime.3 b/src/lib/libcrypto/man/BN_generate_prime.3
index d9144155c6..55eed14e75 100644
--- a/src/lib/libcrypto/man/BN_generate_prime.3
+++ b/src/lib/libcrypto/man/BN_generate_prime.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_generate_prime.3,v 1.25 2023/12/29 19:12:46 tb Exp $ 1.\" $OpenBSD: BN_generate_prime.3,v 1.26 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL f987a4dd Jun 27 10:12:08 2019 +0200 2.\" full merge up to: OpenSSL f987a4dd Jun 27 10:12:08 2019 +0200
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 29 2023 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt BN_GENERATE_PRIME 3 71.Dt BN_GENERATE_PRIME 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -84,6 +84,7 @@
84.\" because it should not be used outside of libcrypto. 84.\" because it should not be used outside of libcrypto.
85.Nd generate primes and test for primality 85.Nd generate primes and test for primality
86.Sh SYNOPSIS 86.Sh SYNOPSIS
87.Lb libcrypto
87.In openssl/bn.h 88.In openssl/bn.h
88.Ft int 89.Ft int
89.Fo BN_is_prime_ex 90.Fo BN_is_prime_ex
diff --git a/src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3 b/src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3
index abaf80ef20..41345de274 100644
--- a/src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3
+++ b/src/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_get_rfc3526_prime_8192.3,v 1.1 2023/07/20 16:26:40 tb Exp $ 1.\" $OpenBSD: BN_get_rfc3526_prime_8192.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" checked up to: OpenSSL DH_get_1024_160 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" checked up to: OpenSSL DH_get_1024_160 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: July 20 2023 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt BN_GET_RFC3526_PRIME_8192 3 19.Dt BN_GET_RFC3526_PRIME_8192 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -29,6 +29,7 @@
29.Nm BN_get_rfc3526_prime_8192 29.Nm BN_get_rfc3526_prime_8192
30.Nd standard moduli for Diffie-Hellman key exchange 30.Nd standard moduli for Diffie-Hellman key exchange
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libcrypto
32.In openssl/bn.h 33.In openssl/bn.h
33.Ft BIGNUM * 34.Ft BIGNUM *
34.Fn BN_get_rfc2409_prime_768 "BIGNUM *bn" 35.Fn BN_get_rfc2409_prime_768 "BIGNUM *bn"
diff --git a/src/lib/libcrypto/man/BN_kronecker.3 b/src/lib/libcrypto/man/BN_kronecker.3
index 90b7f43230..6a5b7ecd88 100644
--- a/src/lib/libcrypto/man/BN_kronecker.3
+++ b/src/lib/libcrypto/man/BN_kronecker.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_kronecker.3,v 1.2 2022/11/15 17:55:00 schwarze Exp $ 1.\" $OpenBSD: BN_kronecker.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 15 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BN_KRONECKER 3 18.Dt BN_KRONECKER 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm BN_kronecker 21.Nm BN_kronecker
22.Nd Kronecker symbol 22.Nd Kronecker symbol
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/bn.h 25.In openssl/bn.h
25.Ft int 26.Ft int
26.Fo BN_kronecker 27.Fo BN_kronecker
diff --git a/src/lib/libcrypto/man/BN_mod_inverse.3 b/src/lib/libcrypto/man/BN_mod_inverse.3
index d0a4b458f4..ce10fa216e 100644
--- a/src/lib/libcrypto/man/BN_mod_inverse.3
+++ b/src/lib/libcrypto/man/BN_mod_inverse.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_mod_inverse.3,v 1.13 2023/10/21 13:53:43 schwarze Exp $ 1.\" $OpenBSD: BN_mod_inverse.3,v 1.14 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: October 21 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BN_MOD_INVERSE 3 52.Dt BN_MOD_INVERSE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm BN_mod_inverse 55.Nm BN_mod_inverse
56.Nd compute inverse modulo m 56.Nd compute inverse modulo m
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/bn.h 59.In openssl/bn.h
59.Ft BIGNUM * 60.Ft BIGNUM *
60.Fo BN_mod_inverse 61.Fo BN_mod_inverse
diff --git a/src/lib/libcrypto/man/BN_mod_mul_montgomery.3 b/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
index ed004c2549..2f9e3a532e 100644
--- a/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
+++ b/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.16 2025/03/09 15:24:25 tb Exp $ 1.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 2.\" full merge up to: OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: March 9 2025 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BN_MOD_MUL_MONTGOMERY 3 70.Dt BN_MOD_MUL_MONTGOMERY 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -80,6 +80,7 @@
80.Nm BN_to_montgomery 80.Nm BN_to_montgomery
81.Nd Montgomery multiplication 81.Nd Montgomery multiplication
82.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
83.In openssl/bn.h 84.In openssl/bn.h
84.Ft BN_MONT_CTX * 85.Ft BN_MONT_CTX *
85.Fo BN_MONT_CTX_new 86.Fo BN_MONT_CTX_new
diff --git a/src/lib/libcrypto/man/BN_mod_sqrt.3 b/src/lib/libcrypto/man/BN_mod_sqrt.3
index 7247d907a0..f2cd80e658 100644
--- a/src/lib/libcrypto/man/BN_mod_sqrt.3
+++ b/src/lib/libcrypto/man/BN_mod_sqrt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_mod_sqrt.3,v 1.2 2022/12/06 22:22:42 tb Exp $ 1.\" $OpenBSD: BN_mod_sqrt.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 6 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BN_MOD_SQRT 3 18.Dt BN_MOD_SQRT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm BN_mod_sqrt 21.Nm BN_mod_sqrt
22.Nd square root in a prime field 22.Nd square root in a prime field
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/bn.h 25.In openssl/bn.h
25.Ft BIGNUM * 26.Ft BIGNUM *
26.Fo BN_mod_sqrt 27.Fo BN_mod_sqrt
diff --git a/src/lib/libcrypto/man/BN_new.3 b/src/lib/libcrypto/man/BN_new.3
index 26a2a7d68a..8e61a1fcc3 100644
--- a/src/lib/libcrypto/man/BN_new.3
+++ b/src/lib/libcrypto/man/BN_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_new.3,v 1.32 2025/04/25 12:11:17 tb Exp $ 1.\" $OpenBSD: BN_new.3,v 1.33 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL man3/BN_new 2457c19d Mar 6 08:43:36 2004 +0000 2.\" full merge up to: OpenSSL man3/BN_new 2457c19d Mar 6 08:43:36 2004 +0000
3.\" selective merge up to: man3/BN_new 681acb31 Sep 29 13:10:34 2017 +0200 3.\" selective merge up to: man3/BN_new 681acb31 Sep 29 13:10:34 2017 +0200
4.\" full merge up to: OpenSSL man7/bn 05ea606a May 20 20:52:46 2016 -0400 4.\" full merge up to: OpenSSL man7/bn 05ea606a May 20 20:52:46 2016 -0400
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: April 25 2025 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt BN_NEW 3 54.Dt BN_NEW 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -60,6 +60,7 @@
60.Nm BN_clear_free 60.Nm BN_clear_free
61.Nd allocate and free BIGNUMs 61.Nd allocate and free BIGNUMs
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/bn.h 64.In openssl/bn.h
64.Ft BIGNUM * 65.Ft BIGNUM *
65.Fo BN_new 66.Fo BN_new
diff --git a/src/lib/libcrypto/man/BN_num_bytes.3 b/src/lib/libcrypto/man/BN_num_bytes.3
index 785f43e2f0..608bb2ebb8 100644
--- a/src/lib/libcrypto/man/BN_num_bytes.3
+++ b/src/lib/libcrypto/man/BN_num_bytes.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_num_bytes.3,v 1.9 2022/11/22 18:55:04 schwarze Exp $ 1.\" $OpenBSD: BN_num_bytes.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500 2.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: November 22 2022 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt BN_NUM_BYTES 3 70.Dt BN_NUM_BYTES 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -75,6 +75,7 @@
75.Nm BN_num_bytes 75.Nm BN_num_bytes
76.Nd get BIGNUM size 76.Nd get BIGNUM size
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/bn.h 79.In openssl/bn.h
79.Ft int 80.Ft int
80.Fo BN_num_bits_word 81.Fo BN_num_bits_word
diff --git a/src/lib/libcrypto/man/BN_rand.3 b/src/lib/libcrypto/man/BN_rand.3
index 3d4401a429..b21155af0d 100644
--- a/src/lib/libcrypto/man/BN_rand.3
+++ b/src/lib/libcrypto/man/BN_rand.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_rand.3,v 1.18 2021/11/30 18:34:35 tb Exp $ 1.\" $OpenBSD: BN_rand.3,v 1.19 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: November 30 2021 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt BN_RAND 3 54.Dt BN_RAND 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -60,6 +60,7 @@
60.Nm BN_pseudo_rand_range 60.Nm BN_pseudo_rand_range
61.Nd generate pseudo-random number 61.Nd generate pseudo-random number
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/bn.h 64.In openssl/bn.h
64.Ft int 65.Ft int
65.Fo BN_rand 66.Fo BN_rand
diff --git a/src/lib/libcrypto/man/BN_set_bit.3 b/src/lib/libcrypto/man/BN_set_bit.3
index 2c53066777..c13122b729 100644
--- a/src/lib/libcrypto/man/BN_set_bit.3
+++ b/src/lib/libcrypto/man/BN_set_bit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_set_bit.3,v 1.8 2021/11/30 18:34:35 tb Exp $ 1.\" $OpenBSD: BN_set_bit.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 30 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt BN_SET_BIT 3 52.Dt BN_SET_BIT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -62,6 +62,7 @@
62.Nm BN_rshift1 62.Nm BN_rshift1
63.Nd bit operations on BIGNUMs 63.Nd bit operations on BIGNUMs
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libcrypto
65.In openssl/bn.h 66.In openssl/bn.h
66.Ft int 67.Ft int
67.Fo BN_set_bit 68.Fo BN_set_bit
diff --git a/src/lib/libcrypto/man/BN_set_flags.3 b/src/lib/libcrypto/man/BN_set_flags.3
index 1285ae2b28..eb4840a54b 100644
--- a/src/lib/libcrypto/man/BN_set_flags.3
+++ b/src/lib/libcrypto/man/BN_set_flags.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_set_flags.3,v 1.6 2023/04/27 07:22:22 tb Exp $ 1.\" $OpenBSD: BN_set_flags.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 27 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BN_SET_FLAGS 3 18.Dt BN_SET_FLAGS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm BN_get_flags 22.Nm BN_get_flags
23.Nd enable and inspect flags on BIGNUM objects 23.Nd enable and inspect flags on BIGNUM objects
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/bn.h 26.In openssl/bn.h
26.Ft void 27.Ft void
27.Fo BN_set_flags 28.Fo BN_set_flags
diff --git a/src/lib/libcrypto/man/BN_set_negative.3 b/src/lib/libcrypto/man/BN_set_negative.3
index 6cdff5c974..579bcf2123 100644
--- a/src/lib/libcrypto/man/BN_set_negative.3
+++ b/src/lib/libcrypto/man/BN_set_negative.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_set_negative.3,v 1.6 2021/12/06 19:45:27 schwarze Exp $ 1.\" $OpenBSD: BN_set_negative.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 6 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt BN_SET_NEGATIVE 3 18.Dt BN_SET_NEGATIVE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm BN_is_negative 22.Nm BN_is_negative
23.Nd change and inspect the sign of a BIGNUM 23.Nd change and inspect the sign of a BIGNUM
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/bn.h 26.In openssl/bn.h
26.Ft void 27.Ft void
27.Fo BN_set_negative 28.Fo BN_set_negative
diff --git a/src/lib/libcrypto/man/BN_swap.3 b/src/lib/libcrypto/man/BN_swap.3
index 218ca1cf02..a6a5fa95ba 100644
--- a/src/lib/libcrypto/man/BN_swap.3
+++ b/src/lib/libcrypto/man/BN_swap.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_swap.3,v 1.6 2021/12/19 22:06:35 schwarze Exp $ 1.\" $OpenBSD: BN_swap.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 19 2021 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt BN_SWAP 3 69.Dt BN_SWAP 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -73,6 +73,7 @@
73.Nm BN_consttime_swap 73.Nm BN_consttime_swap
74.Nd exchange BIGNUMs 74.Nd exchange BIGNUMs
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libcrypto
76.In openssl/bn.h 77.In openssl/bn.h
77.Ft void 78.Ft void
78.Fo BN_swap 79.Fo BN_swap
diff --git a/src/lib/libcrypto/man/BN_zero.3 b/src/lib/libcrypto/man/BN_zero.3
index 0b677b246f..18a31a1080 100644
--- a/src/lib/libcrypto/man/BN_zero.3
+++ b/src/lib/libcrypto/man/BN_zero.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_zero.3,v 1.13 2023/04/30 19:23:54 tb Exp $ 1.\" $OpenBSD: BN_zero.3,v 1.15 2025/06/14 06:48:47 tb Exp $
2.\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" selective merge up to: OpenSSL b713c4ff Jan 22 14:41:09 2018 -0500 3.\" selective merge up to: OpenSSL b713c4ff Jan 22 14:41:09 2018 -0500
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: April 30 2023 $ 70.Dd $Mdocdate: June 14 2025 $
71.Dt BN_ZERO 3 71.Dt BN_ZERO 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -78,8 +78,9 @@
78.Nm BN_get_word 78.Nm BN_get_word
79.Nd BIGNUM assignment operations 79.Nd BIGNUM assignment operations
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/bn.h 82.In openssl/bn.h
82.Ft int 83.Ft void
83.Fo BN_zero 84.Fo BN_zero
84.Fa "BIGNUM *a" 85.Fa "BIGNUM *a"
85.Fc 86.Fc
@@ -136,8 +137,7 @@ or a number with all bits set if
136cannot be represented as a 137cannot be represented as a
137.Vt BN_ULONG . 138.Vt BN_ULONG .
138.Pp 139.Pp
139.Fn BN_zero , 140.Fn BN_one
140.Fn BN_one ,
141and 141and
142.Fn BN_set_word 142.Fn BN_set_word
143return 1 on success, 0 otherwise. 143return 1 on success, 0 otherwise.
diff --git a/src/lib/libcrypto/man/BUF_MEM_new.3 b/src/lib/libcrypto/man/BUF_MEM_new.3
index 8c72091abe..ef9e473cc3 100644
--- a/src/lib/libcrypto/man/BUF_MEM_new.3
+++ b/src/lib/libcrypto/man/BUF_MEM_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BUF_MEM_new.3,v 1.19 2024/07/24 08:57:58 tb Exp $ 1.\" $OpenBSD: BUF_MEM_new.3,v 1.20 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL doc/crypto/buffer.pod 18edda0f Sep 20 03:28:54 2000 +0000 2.\" OpenSSL doc/crypto/buffer.pod 18edda0f Sep 20 03:28:54 2000 +0000
3.\" not merged: 74924dcb, 58e3457a, 21b0fa91, 7644a9ae 3.\" not merged: 74924dcb, 58e3457a, 21b0fa91, 7644a9ae
4.\" OpenSSL doc/crypto/BUF_MEM_new.pod 53934822 Jun 9 16:39:19 2016 -0400 4.\" OpenSSL doc/crypto/BUF_MEM_new.pod 53934822 Jun 9 16:39:19 2016 -0400
@@ -52,7 +52,7 @@
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE. 53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\" 54.\"
55.Dd $Mdocdate: July 24 2024 $ 55.Dd $Mdocdate: June 8 2025 $
56.Dt BUF_MEM_NEW 3 56.Dt BUF_MEM_NEW 3
57.Os 57.Os
58.Sh NAME 58.Sh NAME
@@ -62,6 +62,7 @@
62.Nm BUF_MEM_grow_clean 62.Nm BUF_MEM_grow_clean
63.Nd simple character arrays structure 63.Nd simple character arrays structure
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libcrypto
65.In openssl/buffer.h 66.In openssl/buffer.h
66.Ft BUF_MEM * 67.Ft BUF_MEM *
67.Fo BUF_MEM_new 68.Fo BUF_MEM_new
diff --git a/src/lib/libcrypto/man/CMAC_Init.3 b/src/lib/libcrypto/man/CMAC_Init.3
index fd32ca085a..b1b62a6359 100644
--- a/src/lib/libcrypto/man/CMAC_Init.3
+++ b/src/lib/libcrypto/man/CMAC_Init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMAC_Init.3,v 1.9 2024/11/12 00:42:28 schwarze Exp $ 1.\" $OpenBSD: CMAC_Init.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 12 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt CMAC_INIT 3 18.Dt CMAC_INIT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.Nm CMAC_CTX_free 28.Nm CMAC_CTX_free
29.Nd Cipher-based message authentication code 29.Nd Cipher-based message authentication code
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/cmac.h 32.In openssl/cmac.h
32.Ft CMAC_CTX * 33.Ft CMAC_CTX *
33.Fn CMAC_CTX_new void 34.Fn CMAC_CTX_new void
diff --git a/src/lib/libcrypto/man/CMS_ContentInfo_new.3 b/src/lib/libcrypto/man/CMS_ContentInfo_new.3
index d5117fa4ae..b44f65ee91 100644
--- a/src/lib/libcrypto/man/CMS_ContentInfo_new.3
+++ b/src/lib/libcrypto/man/CMS_ContentInfo_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_ContentInfo_new.3,v 1.4 2024/01/22 14:00:13 tb Exp $ 1.\" $OpenBSD: CMS_ContentInfo_new.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: January 22 2024 $ 16.Dd $Mdocdate: June 8 2025 $
17.Dt CMS_CONTENTINFO_NEW 3 17.Dt CMS_CONTENTINFO_NEW 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
@@ -24,6 +24,7 @@
24.Nm CMS_ReceiptRequest_free 24.Nm CMS_ReceiptRequest_free
25.Nd Cryptographic Message Syntax data structures 25.Nd Cryptographic Message Syntax data structures
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/cms.h 28.In openssl/cms.h
28.Ft CMS_ContentInfo * 29.Ft CMS_ContentInfo *
29.Fn CMS_ContentInfo_new void 30.Fn CMS_ContentInfo_new void
diff --git a/src/lib/libcrypto/man/CMS_add0_cert.3 b/src/lib/libcrypto/man/CMS_add0_cert.3
index be9357cc9a..d0e9be6bd5 100644
--- a/src/lib/libcrypto/man/CMS_add0_cert.3
+++ b/src/lib/libcrypto/man/CMS_add0_cert.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_add0_cert.3,v 1.10 2024/11/30 21:21:40 tb Exp $ 1.\" $OpenBSD: CMS_add0_cert.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: November 30 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt CMS_ADD0_CERT 3 69.Dt CMS_ADD0_CERT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -77,6 +77,7 @@
77.Nm CMS_get1_crls 77.Nm CMS_get1_crls
78.Nd CMS certificate and CRL utility functions 78.Nd CMS certificate and CRL utility functions
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libcrypto
80.In openssl/cms.h 81.In openssl/cms.h
81.Ft int 82.Ft int
82.Fo CMS_add0_cert 83.Fo CMS_add0_cert
diff --git a/src/lib/libcrypto/man/CMS_add1_recipient_cert.3 b/src/lib/libcrypto/man/CMS_add1_recipient_cert.3
index 465119397d..7c0c3fae90 100644
--- a/src/lib/libcrypto/man/CMS_add1_recipient_cert.3
+++ b/src/lib/libcrypto/man/CMS_add1_recipient_cert.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_add1_recipient_cert.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_add1_recipient_cert.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: November 2 2019 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt CMS_ADD1_RECIPIENT_CERT 3 69.Dt CMS_ADD1_RECIPIENT_CERT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -73,6 +73,7 @@
73.Nm CMS_add0_recipient_key 73.Nm CMS_add0_recipient_key
74.Nd add recipients to a CMS EnvelopedData structure 74.Nd add recipients to a CMS EnvelopedData structure
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libcrypto
76.In openssl/cms.h 77.In openssl/cms.h
77.Ft CMS_RecipientInfo * 78.Ft CMS_RecipientInfo *
78.Fo CMS_add1_recipient_cert 79.Fo CMS_add1_recipient_cert
diff --git a/src/lib/libcrypto/man/CMS_add1_signer.3 b/src/lib/libcrypto/man/CMS_add1_signer.3
index 316d63c5ad..68bdb12c73 100644
--- a/src/lib/libcrypto/man/CMS_add1_signer.3
+++ b/src/lib/libcrypto/man/CMS_add1_signer.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_add1_signer.3,v 1.10 2024/04/18 16:50:22 tb Exp $ 1.\" $OpenBSD: CMS_add1_signer.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: April 18 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt CMS_ADD1_SIGNER 3 69.Dt CMS_ADD1_SIGNER 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -73,6 +73,7 @@
73.Nm CMS_SignerInfo_sign 73.Nm CMS_SignerInfo_sign
74.Nd add a signer to a CMS SignedData structure 74.Nd add a signer to a CMS SignedData structure
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libcrypto
76.In openssl/cms.h 77.In openssl/cms.h
77.Ft CMS_SignerInfo * 78.Ft CMS_SignerInfo *
78.Fo CMS_add1_signer 79.Fo CMS_add1_signer
diff --git a/src/lib/libcrypto/man/CMS_compress.3 b/src/lib/libcrypto/man/CMS_compress.3
index 242e4e96cb..9026837fc8 100644
--- a/src/lib/libcrypto/man/CMS_compress.3
+++ b/src/lib/libcrypto/man/CMS_compress.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_compress.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_compress.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,13 +65,14 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: November 2 2019 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt CMS_COMPRESS 3 69.Dt CMS_COMPRESS 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
72.Nm CMS_compress 72.Nm CMS_compress
73.Nd create a CMS CompressedData structure 73.Nd create a CMS CompressedData structure
74.Sh SYNOPSIS 74.Sh SYNOPSIS
75.Lb libcrypto
75.In openssl/cms.h 76.In openssl/cms.h
76.Ft CMS_ContentInfo * 77.Ft CMS_ContentInfo *
77.Fo CMS_compress 78.Fo CMS_compress
diff --git a/src/lib/libcrypto/man/CMS_decrypt.3 b/src/lib/libcrypto/man/CMS_decrypt.3
index 243ab2f30e..2141098084 100644
--- a/src/lib/libcrypto/man/CMS_decrypt.3
+++ b/src/lib/libcrypto/man/CMS_decrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_decrypt.3,v 1.8 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_decrypt.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: November 2 2019 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt CMS_DECRYPT 3 69.Dt CMS_DECRYPT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -74,6 +74,7 @@
74.Nm CMS_decrypt_set1_key 74.Nm CMS_decrypt_set1_key
75.Nd decrypt content from a CMS EnvelopedData structure 75.Nd decrypt content from a CMS EnvelopedData structure
76.Sh SYNOPSIS 76.Sh SYNOPSIS
77.Lb libcrypto
77.In openssl/cms.h 78.In openssl/cms.h
78.Ft int 79.Ft int
79.Fo CMS_decrypt 80.Fo CMS_decrypt
diff --git a/src/lib/libcrypto/man/CMS_encrypt.3 b/src/lib/libcrypto/man/CMS_encrypt.3
index 03d8b4edbb..5eda883857 100644
--- a/src/lib/libcrypto/man/CMS_encrypt.3
+++ b/src/lib/libcrypto/man/CMS_encrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_encrypt.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_encrypt.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 2 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_ENCRYPT 3 52.Dt CMS_ENCRYPT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm CMS_encrypt 55.Nm CMS_encrypt
56.Nd create a CMS EnvelopedData structure 56.Nd create a CMS EnvelopedData structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft CMS_ContentInfo * 60.Ft CMS_ContentInfo *
60.Fo CMS_encrypt 61.Fo CMS_encrypt
diff --git a/src/lib/libcrypto/man/CMS_final.3 b/src/lib/libcrypto/man/CMS_final.3
index 4ca8945923..f2b5755fa9 100644
--- a/src/lib/libcrypto/man/CMS_final.3
+++ b/src/lib/libcrypto/man/CMS_final.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_final.3,v 1.6 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_final.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 25ccb589 Jul 1 02:02:06 2019 +0800 2.\" full merge up to: OpenSSL 25ccb589 Jul 1 02:02:06 2019 +0800
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 2 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_FINAL 3 52.Dt CMS_FINAL 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm CMS_final 55.Nm CMS_final
56.Nd finalise a CMS_ContentInfo structure 56.Nd finalise a CMS_ContentInfo structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft int 60.Ft int
60.Fo CMS_final 61.Fo CMS_final
diff --git a/src/lib/libcrypto/man/CMS_get0_RecipientInfos.3 b/src/lib/libcrypto/man/CMS_get0_RecipientInfos.3
index 094d6ec487..beb54bdccc 100644
--- a/src/lib/libcrypto/man/CMS_get0_RecipientInfos.3
+++ b/src/lib/libcrypto/man/CMS_get0_RecipientInfos.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_get0_RecipientInfos.3,v 1.8 2022/03/31 17:27:16 naddy Exp $ 1.\" $OpenBSD: CMS_get0_RecipientInfos.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 31 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_GET0_RECIPIENTINFOS 3 52.Dt CMS_GET0_RECIPIENTINFOS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -64,6 +64,7 @@
64.Nm CMS_RecipientInfo_encrypt 64.Nm CMS_RecipientInfo_encrypt
65.Nd CMS EnvelopedData RecipientInfo routines 65.Nd CMS EnvelopedData RecipientInfo routines
66.Sh SYNOPSIS 66.Sh SYNOPSIS
67.Lb libcrypto
67.In openssl/cms.h 68.In openssl/cms.h
68.Ft STACK_OF(CMS_RecipientInfo) * 69.Ft STACK_OF(CMS_RecipientInfo) *
69.Fo CMS_get0_RecipientInfos 70.Fo CMS_get0_RecipientInfos
diff --git a/src/lib/libcrypto/man/CMS_get0_SignerInfos.3 b/src/lib/libcrypto/man/CMS_get0_SignerInfos.3
index 017fdd40f2..f141508eb1 100644
--- a/src/lib/libcrypto/man/CMS_get0_SignerInfos.3
+++ b/src/lib/libcrypto/man/CMS_get0_SignerInfos.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_get0_SignerInfos.3,v 1.9 2024/01/22 14:00:13 tb Exp $ 1.\" $OpenBSD: CMS_get0_SignerInfos.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: January 22 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_GET0_SIGNERINFOS 3 52.Dt CMS_GET0_SIGNERINFOS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -60,6 +60,7 @@
60.Nm CMS_SignerInfo_set1_signer_cert 60.Nm CMS_SignerInfo_set1_signer_cert
61.Nd CMS SignedData signer functions 61.Nd CMS SignedData signer functions
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/cms.h 64.In openssl/cms.h
64.Ft STACK_OF(CMS_SignerInfo) * 65.Ft STACK_OF(CMS_SignerInfo) *
65.Fo CMS_get0_SignerInfos 66.Fo CMS_get0_SignerInfos
diff --git a/src/lib/libcrypto/man/CMS_get0_type.3 b/src/lib/libcrypto/man/CMS_get0_type.3
index 55adacd86d..5547de494a 100644
--- a/src/lib/libcrypto/man/CMS_get0_type.3
+++ b/src/lib/libcrypto/man/CMS_get0_type.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_get0_type.3,v 1.9 2023/07/27 05:31:28 tb Exp $ 1.\" $OpenBSD: CMS_get0_type.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000 2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: July 27 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt CMS_GET0_TYPE 3 69.Dt CMS_GET0_TYPE 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -76,6 +76,7 @@
76.Nm CMS_get0_content 76.Nm CMS_get0_content
77.Nd get and set CMS content types and content 77.Nd get and set CMS content types and content
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/cms.h 80.In openssl/cms.h
80.Ft const ASN1_OBJECT * 81.Ft const ASN1_OBJECT *
81.Fo CMS_get0_type 82.Fo CMS_get0_type
diff --git a/src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3 b/src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3
index 9feedd13a2..17a14c47e3 100644
--- a/src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3
+++ b/src/lib/libcrypto/man/CMS_get1_ReceiptRequest.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_get1_ReceiptRequest.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_get1_ReceiptRequest.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 2 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_GET1_RECEIPTREQUEST 3 52.Dt CMS_GET1_RECEIPTREQUEST 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm CMS_ReceiptRequest_get0_values 58.Nm CMS_ReceiptRequest_get0_values
59.Nd CMS signed receipt request functions 59.Nd CMS signed receipt request functions
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/cms.h 62.In openssl/cms.h
62.Ft CMS_ReceiptRequest * 63.Ft CMS_ReceiptRequest *
63.Fo CMS_ReceiptRequest_create0 64.Fo CMS_ReceiptRequest_create0
diff --git a/src/lib/libcrypto/man/CMS_sign.3 b/src/lib/libcrypto/man/CMS_sign.3
index c9b26716d6..82f9ff9896 100644
--- a/src/lib/libcrypto/man/CMS_sign.3
+++ b/src/lib/libcrypto/man/CMS_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_sign.3,v 1.12 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: CMS_sign.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 17 2025 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_SIGN 3 52.Dt CMS_SIGN 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm CMS_sign 55.Nm CMS_sign
56.Nd create a CMS SignedData structure 56.Nd create a CMS SignedData structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft CMS_ContentInfo * 60.Ft CMS_ContentInfo *
60.Fo CMS_sign 61.Fo CMS_sign
diff --git a/src/lib/libcrypto/man/CMS_sign_receipt.3 b/src/lib/libcrypto/man/CMS_sign_receipt.3
index 6394957846..32807b26e1 100644
--- a/src/lib/libcrypto/man/CMS_sign_receipt.3
+++ b/src/lib/libcrypto/man/CMS_sign_receipt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_sign_receipt.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_sign_receipt.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 2 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_SIGN_RECEIPT 3 52.Dt CMS_SIGN_RECEIPT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm CMS_sign_receipt 55.Nm CMS_sign_receipt
56.Nd create a CMS signed receipt 56.Nd create a CMS signed receipt
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft CMS_ContentInfo * 60.Ft CMS_ContentInfo *
60.Fo CMS_sign_receipt 61.Fo CMS_sign_receipt
diff --git a/src/lib/libcrypto/man/CMS_signed_add1_attr.3 b/src/lib/libcrypto/man/CMS_signed_add1_attr.3
index 1a50c0b9d1..10a959bba6 100644
--- a/src/lib/libcrypto/man/CMS_signed_add1_attr.3
+++ b/src/lib/libcrypto/man/CMS_signed_add1_attr.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_signed_add1_attr.3,v 1.5 2024/09/02 07:54:21 tb Exp $ 1.\" $OpenBSD: CMS_signed_add1_attr.3,v 1.7 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Job Snijders <job@openbsd.org> 3.\" Copyright (c) 2024 Job Snijders <job@openbsd.org>
4.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org> 4.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: September 2 2024 $ 19.Dd $Mdocdate: June 13 2025 $
20.Dt CMS_SIGNED_ADD1_ATTR 3 20.Dt CMS_SIGNED_ADD1_ATTR 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -42,6 +42,7 @@
42.Nm CMS_unsigned_get_attr_count 42.Nm CMS_unsigned_get_attr_count
43.Nd change signed and unsigned attributes of a CMS SignerInfo object 43.Nd change signed and unsigned attributes of a CMS SignerInfo object
44.Sh SYNOPSIS 44.Sh SYNOPSIS
45.Lb libcrypto
45.In openssl/cms.h 46.In openssl/cms.h
46.Ft int 47.Ft int
47.Fo CMS_signed_add1_attr 48.Fo CMS_signed_add1_attr
@@ -72,19 +73,19 @@
72.Fa "const void *bytes" 73.Fa "const void *bytes"
73.Fa "int len" 74.Fa "int len"
74.Fc 75.Fc
75.Ft "X509_ATTRIBUTE *" 76.Ft X509_ATTRIBUTE *
76.Fo CMS_signed_delete_attr 77.Fo CMS_signed_delete_attr
77.Fa "CMS_SignerInfo *si" 78.Fa "CMS_SignerInfo *si"
78.Fa "int loc" 79.Fa "int loc"
79.Fc 80.Fc
80.Ft "void *" 81.Ft void *
81.Fo CMS_signed_get0_data_by_OBJ 82.Fo CMS_signed_get0_data_by_OBJ
82.Fa "CMS_SignerInfo *si" 83.Fa "CMS_SignerInfo *si"
83.Fa "const ASN1_OBJECT *oid" 84.Fa "const ASN1_OBJECT *oid"
84.Fa "int start_after" 85.Fa "int start_after"
85.Fa "int type" 86.Fa "int type"
86.Fc 87.Fc
87.Ft "X509_ATTRIBUTE *" 88.Ft X509_ATTRIBUTE *
88.Fo CMS_signed_get_attr 89.Fo CMS_signed_get_attr
89.Fa "const CMS_SignerInfo *si" 90.Fa "const CMS_SignerInfo *si"
90.Fa "int loc" 91.Fa "int loc"
@@ -134,19 +135,19 @@
134.Fa "const void *bytes" 135.Fa "const void *bytes"
135.Fa "int len" 136.Fa "int len"
136.Fc 137.Fc
137.Ft "X509_ATTRIBUTE *" 138.Ft X509_ATTRIBUTE *
138.Fo CMS_unsigned_delete_attr 139.Fo CMS_unsigned_delete_attr
139.Fa "CMS_SignerInfo *si" 140.Fa "CMS_SignerInfo *si"
140.Fa "int loc" 141.Fa "int loc"
141.Fc 142.Fc
142.Ft "void *" 143.Ft void *
143.Fo CMS_unsigned_get0_data_by_OBJ 144.Fo CMS_unsigned_get0_data_by_OBJ
144.Fa "CMS_SignerInfo *si" 145.Fa "CMS_SignerInfo *si"
145.Fa "ASN1_OBJECT *oid" 146.Fa "ASN1_OBJECT *oid"
146.Fa "int start_after" 147.Fa "int start_after"
147.Fa "int type" 148.Fa "int type"
148.Fc 149.Fc
149.Ft "X509_ATTRIBUTE *" 150.Ft X509_ATTRIBUTE *
150.Fo CMS_unsigned_get_attr 151.Fo CMS_unsigned_get_attr
151.Fa "const CMS_SignerInfo *si" 152.Fa "const CMS_SignerInfo *si"
152.Fa "int loc" 153.Fa "int loc"
diff --git a/src/lib/libcrypto/man/CMS_uncompress.3 b/src/lib/libcrypto/man/CMS_uncompress.3
index ed2172521e..2a5e2f593b 100644
--- a/src/lib/libcrypto/man/CMS_uncompress.3
+++ b/src/lib/libcrypto/man/CMS_uncompress.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_uncompress.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_uncompress.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 2 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_UNCOMPRESS 3 52.Dt CMS_UNCOMPRESS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm CMS_uncompress 55.Nm CMS_uncompress
56.Nd uncompress a CMS CompressedData structure 56.Nd uncompress a CMS CompressedData structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft int 60.Ft int
60.Fo CMS_uncompress 61.Fo CMS_uncompress
diff --git a/src/lib/libcrypto/man/CMS_verify.3 b/src/lib/libcrypto/man/CMS_verify.3
index 63f1b8bb18..a8803b0595 100644
--- a/src/lib/libcrypto/man/CMS_verify.3
+++ b/src/lib/libcrypto/man/CMS_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_verify.3,v 1.10 2024/03/29 06:43:12 tb Exp $ 1.\" $OpenBSD: CMS_verify.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200 2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 29 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_VERIFY 3 52.Dt CMS_VERIFY 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm CMS_get0_signers 56.Nm CMS_get0_signers
57.Nd verify a CMS SignedData structure 57.Nd verify a CMS SignedData structure
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/cms.h 60.In openssl/cms.h
60.Ft int 61.Ft int
61.Fo CMS_verify 62.Fo CMS_verify
diff --git a/src/lib/libcrypto/man/CMS_verify_receipt.3 b/src/lib/libcrypto/man/CMS_verify_receipt.3
index ac50087a4c..98f5c4ad91 100644
--- a/src/lib/libcrypto/man/CMS_verify_receipt.3
+++ b/src/lib/libcrypto/man/CMS_verify_receipt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CMS_verify_receipt.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: CMS_verify_receipt.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 2 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CMS_VERIFY_RECEIPT 3 52.Dt CMS_VERIFY_RECEIPT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm CMS_verify_receipt 55.Nm CMS_verify_receipt
56.Nd verify a CMS signed receipt 56.Nd verify a CMS signed receipt
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft int 60.Ft int
60.Fo CMS_verify_receipt 61.Fo CMS_verify_receipt
diff --git a/src/lib/libcrypto/man/CONF_modules_free.3 b/src/lib/libcrypto/man/CONF_modules_free.3
index c5fb840942..ab299bcbda 100644
--- a/src/lib/libcrypto/man/CONF_modules_free.3
+++ b/src/lib/libcrypto/man/CONF_modules_free.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CONF_modules_free.3,v 1.6 2023/07/21 10:46:54 tb Exp $ 1.\" $OpenBSD: CONF_modules_free.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 21 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CONF_MODULES_FREE 3 52.Dt CONF_MODULES_FREE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm CONF_modules_unload 57.Nm CONF_modules_unload
58.Nd OpenSSL configuration cleanup functions 58.Nd OpenSSL configuration cleanup functions
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/conf.h 61.In openssl/conf.h
61.Ft void 62.Ft void
62.Fo CONF_modules_free 63.Fo CONF_modules_free
diff --git a/src/lib/libcrypto/man/CONF_modules_load_file.3 b/src/lib/libcrypto/man/CONF_modules_load_file.3
index d1bcd49a38..78cfc32f0d 100644
--- a/src/lib/libcrypto/man/CONF_modules_load_file.3
+++ b/src/lib/libcrypto/man/CONF_modules_load_file.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CONF_modules_load_file.3,v 1.14 2023/11/19 20:58:07 tb Exp $ 1.\" $OpenBSD: CONF_modules_load_file.3,v 1.16 2025/06/09 12:43:53 schwarze Exp $
2.\" full merge up to: e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: e9b77246 Jan 20 19:58:49 2017 +0100
3.\" selective merge up to: d090fc00 Feb 26 13:11:10 2019 +0800 3.\" selective merge up to: d090fc00 Feb 26 13:11:10 2019 +0800
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: November 19 2023 $ 69.Dd $Mdocdate: June 9 2025 $
70.Dt CONF_MODULES_LOAD_FILE 3 70.Dt CONF_MODULES_LOAD_FILE 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -75,6 +75,7 @@
75.Nm X509_get_default_cert_area 75.Nm X509_get_default_cert_area
76.Nd OpenSSL configuration functions 76.Nd OpenSSL configuration functions
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/conf.h 79.In openssl/conf.h
79.Ft int 80.Ft int
80.Fo CONF_modules_load_file 81.Fo CONF_modules_load_file
@@ -222,7 +223,6 @@ Load custom configuration file and section instead of the standard one,
222only print warnings on error, missing configuration file ignored: 223only print warnings on error, missing configuration file ignored:
223.Bd -literal 224.Bd -literal
224OPENSSL_no_config(); 225OPENSSL_no_config();
225OPENSSL_load_builtin_modules();
226if (CONF_modules_load_file("/something/app.cnf", "myapp", 226if (CONF_modules_load_file("/something/app.cnf", "myapp",
227 CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) { 227 CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
228 fprintf(stderr, "WARNING: error loading configuration file\en"); 228 fprintf(stderr, "WARNING: error loading configuration file\en");
@@ -233,11 +233,7 @@ if (CONF_modules_load_file("/something/app.cnf", "myapp",
233In the previous example, the call to 233In the previous example, the call to
234.Xr OPENSSL_no_config 3 234.Xr OPENSSL_no_config 3
235is required first to suppress automatic loading 235is required first to suppress automatic loading
236of the standard configuration file, and the call to 236of the standard configuration file.
237.Xr OPENSSL_load_builtin_modules 3
238is needed so that the configuration of builtin modules
239is loaded in addition to the configuration of
240.Qq myapp .
241.Pp 237.Pp
242Load and parse configuration file manually, custom error handling: 238Load and parse configuration file manually, custom error handling:
243.Bd -literal 239.Bd -literal
@@ -268,8 +264,7 @@ if (fp == NULL) {
268.Sh SEE ALSO 264.Sh SEE ALSO
269.Xr CONF_modules_free 3 , 265.Xr CONF_modules_free 3 ,
270.Xr ERR 3 , 266.Xr ERR 3 ,
271.Xr OPENSSL_config 3 , 267.Xr OPENSSL_config 3
272.Xr OPENSSL_load_builtin_modules 3
273.Sh HISTORY 268.Sh HISTORY
274.Fn X509_get_default_cert_area 269.Fn X509_get_default_cert_area
275first appeared in SSLeay 0.4.1 and has been available since 270first appeared in SSLeay 0.4.1 and has been available since
diff --git a/src/lib/libcrypto/man/CRYPTO_lock.3 b/src/lib/libcrypto/man/CRYPTO_lock.3
index afc5eb54c5..7877dd5804 100644
--- a/src/lib/libcrypto/man/CRYPTO_lock.3
+++ b/src/lib/libcrypto/man/CRYPTO_lock.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CRYPTO_lock.3,v 1.3 2024/03/14 22:09:40 tb Exp $ 1.\" $OpenBSD: CRYPTO_lock.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL doc/crypto/threads.pod fb552ac6 Sep 30 23:43:01 2009 +0000 2.\" OpenSSL doc/crypto/threads.pod fb552ac6 Sep 30 23:43:01 2009 +0000
3.\" 3.\"
4.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 14 2024 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt CRYPTO_LOCK 3 19.Dt CRYPTO_LOCK 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -27,6 +27,7 @@
27.Nm CRYPTO_add 27.Nm CRYPTO_add
28.Nd thread support 28.Nd thread support
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/crypto.h 31.In openssl/crypto.h
31.Ft void 32.Ft void
32.Fo CRYPTO_lock 33.Fo CRYPTO_lock
diff --git a/src/lib/libcrypto/man/CRYPTO_memcmp.3 b/src/lib/libcrypto/man/CRYPTO_memcmp.3
index cbc0030c55..fbe092cb90 100644
--- a/src/lib/libcrypto/man/CRYPTO_memcmp.3
+++ b/src/lib/libcrypto/man/CRYPTO_memcmp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CRYPTO_memcmp.3,v 1.1 2019/08/25 06:20:22 schwarze Exp $ 1.\" $OpenBSD: CRYPTO_memcmp.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 1075139c Jun 24 09:18:48 2019 +1000 2.\" full merge up to: OpenSSL 1075139c Jun 24 09:18:48 2019 +1000
3.\" 3.\"
4.\" This file was written by Pauli <paul.dale@oracle.com>. 4.\" This file was written by Pauli <paul.dale@oracle.com>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 25 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt CRYPTO_MEMCMP 3 52.Dt CRYPTO_MEMCMP 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm CRYPTO_memcmp 55.Nm CRYPTO_memcmp
56.Nd constant time memory comparison 56.Nd constant time memory comparison
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/crypto.h 59.In openssl/crypto.h
59.Ft int 60.Ft int
60.Fo CRYPTO_memcmp 61.Fo CRYPTO_memcmp
diff --git a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
index c22fb22352..57cdbfb4ca 100644
--- a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
+++ b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.15 2023/09/18 14:49:43 schwarze Exp $ 1.\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.16 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 18 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt CRYPTO_SET_EX_DATA 3 18.Dt CRYPTO_SET_EX_DATA 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.Nm CRYPTO_free_ex_data 28.Nm CRYPTO_free_ex_data
29.Nd low-level functions for application specific data 29.Nd low-level functions for application specific data
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/crypto.h 32.In openssl/crypto.h
32.Ft int 33.Ft int
33.Fo CRYPTO_get_ex_new_index 34.Fo CRYPTO_get_ex_new_index
diff --git a/src/lib/libcrypto/man/CRYPTO_set_mem_functions.3 b/src/lib/libcrypto/man/CRYPTO_set_mem_functions.3
index d020d10ff6..4fc88339a8 100644
--- a/src/lib/libcrypto/man/CRYPTO_set_mem_functions.3
+++ b/src/lib/libcrypto/man/CRYPTO_set_mem_functions.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: CRYPTO_set_mem_functions.3,v 1.2 2025/03/08 17:17:09 tb Exp $ 1.\" $OpenBSD: CRYPTO_set_mem_functions.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 8 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt CRYPTO_SET_MEM_FUNCTIONS 3 18.Dt CRYPTO_SET_MEM_FUNCTIONS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.Nm CRYPTO_mem_leaks_cb 25.Nm CRYPTO_mem_leaks_cb
26.Nd legacy OpenSSL memory allocation control 26.Nd legacy OpenSSL memory allocation control
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/crypto.h 29.In openssl/crypto.h
29.Ft int 30.Ft int
30.Fo CRYPTO_set_mem_functions 31.Fo CRYPTO_set_mem_functions
diff --git a/src/lib/libcrypto/man/ChaCha.3 b/src/lib/libcrypto/man/ChaCha.3
index 9aae6d70cf..54cd597f6c 100644
--- a/src/lib/libcrypto/man/ChaCha.3
+++ b/src/lib/libcrypto/man/ChaCha.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ChaCha.3,v 1.3 2022/02/18 10:24:32 jsg Exp $ 1.\" $OpenBSD: ChaCha.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: February 18 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt CHACHA 3 18.Dt CHACHA 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm CRYPTO_xchacha_20 26.Nm CRYPTO_xchacha_20
27.Nd ChaCha20 stream cipher 27.Nd ChaCha20 stream cipher
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/chacha.h 30.In openssl/chacha.h
30.Ft void 31.Ft void
31.Fo ChaCha_set_key 32.Fo ChaCha_set_key
diff --git a/src/lib/libcrypto/man/DES_set_key.3 b/src/lib/libcrypto/man/DES_set_key.3
index fd09d77730..3794285006 100644
--- a/src/lib/libcrypto/man/DES_set_key.3
+++ b/src/lib/libcrypto/man/DES_set_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DES_set_key.3,v 1.17 2024/05/24 19:18:07 tb Exp $ 1.\" $OpenBSD: DES_set_key.3,v 1.18 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/DES_random_key 521738e9 Oct 5 14:58:30 2018 -0400 3.\" OpenSSL man3/DES_random_key 521738e9 Oct 5 14:58:30 2018 -0400
4.\" 4.\"
@@ -115,7 +115,7 @@
115.\" copied and put under another distribution licence 115.\" copied and put under another distribution licence
116.\" [including the GNU Public Licence.] 116.\" [including the GNU Public Licence.]
117.\" 117.\"
118.Dd $Mdocdate: May 24 2024 $ 118.Dd $Mdocdate: June 8 2025 $
119.Dt DES_SET_KEY 3 119.Dt DES_SET_KEY 3
120.Os 120.Os
121.Sh NAME 121.Sh NAME
@@ -151,6 +151,7 @@
151.Nm DES_crypt 151.Nm DES_crypt
152.Nd DES encryption 152.Nd DES encryption
153.Sh SYNOPSIS 153.Sh SYNOPSIS
154.Lb libcrypto
154.In openssl/des.h 155.In openssl/des.h
155.Ft void 156.Ft void
156.Fo DES_random_key 157.Fo DES_random_key
diff --git a/src/lib/libcrypto/man/DH_generate_key.3 b/src/lib/libcrypto/man/DH_generate_key.3
index 076b49f7a1..c3158b8132 100644
--- a/src/lib/libcrypto/man/DH_generate_key.3
+++ b/src/lib/libcrypto/man/DH_generate_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DH_generate_key.3,v 1.12 2019/08/19 13:08:26 schwarze Exp $ 1.\" $OpenBSD: DH_generate_key.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 19 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DH_GENERATE_KEY 3 52.Dt DH_GENERATE_KEY 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm DH_compute_key 56.Nm DH_compute_key
57.Nd perform Diffie-Hellman key exchange 57.Nd perform Diffie-Hellman key exchange
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/dh.h 60.In openssl/dh.h
60.Ft int 61.Ft int
61.Fo DH_generate_key 62.Fo DH_generate_key
diff --git a/src/lib/libcrypto/man/DH_generate_parameters.3 b/src/lib/libcrypto/man/DH_generate_parameters.3
index ac29521ec4..f47475e3b1 100644
--- a/src/lib/libcrypto/man/DH_generate_parameters.3
+++ b/src/lib/libcrypto/man/DH_generate_parameters.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DH_generate_parameters.3,v 1.14 2022/07/13 13:47:59 schwarze Exp $ 1.\" $OpenBSD: DH_generate_parameters.3,v 1.15 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000 3.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: July 13 2022 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt DH_GENERATE_PARAMETERS 3 71.Dt DH_GENERATE_PARAMETERS 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -77,6 +77,7 @@
77.Nm DH_generate_parameters 77.Nm DH_generate_parameters
78.Nd generate and check Diffie-Hellman parameters 78.Nd generate and check Diffie-Hellman parameters
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libcrypto
80.In openssl/dh.h 81.In openssl/dh.h
81.Ft int 82.Ft int
82.Fo DH_generate_parameters_ex 83.Fo DH_generate_parameters_ex
diff --git a/src/lib/libcrypto/man/DH_get0_pqg.3 b/src/lib/libcrypto/man/DH_get0_pqg.3
index eb012980f9..e30d628c7f 100644
--- a/src/lib/libcrypto/man/DH_get0_pqg.3
+++ b/src/lib/libcrypto/man/DH_get0_pqg.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DH_get0_pqg.3,v 1.8 2024/07/21 08:36:43 tb Exp $ 1.\" $OpenBSD: DH_get0_pqg.3,v 1.10 2025/06/13 18:34:00 schwarze Exp $
2.\" selective merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" selective merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 4.\" This file was written by Matt Caswell <matt@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 21 2024 $ 51.Dd $Mdocdate: June 13 2025 $
52.Dt DH_GET0_PQG 3 52.Dt DH_GET0_PQG 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -68,6 +68,7 @@
68.Nm DH_set_length 68.Nm DH_set_length
69.Nd get data from and set data in a DH object 69.Nd get data from and set data in a DH object
70.Sh SYNOPSIS 70.Sh SYNOPSIS
71.Lb libcrypto
71.In openssl/dh.h 72.In openssl/dh.h
72.Ft void 73.Ft void
73.Fo DH_get0_pqg 74.Fo DH_get0_pqg
@@ -76,15 +77,15 @@
76.Fa "const BIGNUM **q" 77.Fa "const BIGNUM **q"
77.Fa "const BIGNUM **g" 78.Fa "const BIGNUM **g"
78.Fc 79.Fc
79.Ft "const BIGNUM *" 80.Ft const BIGNUM *
80.Fo DH_get0_p 81.Fo DH_get0_p
81.Fa "const DH *dh" 82.Fa "const DH *dh"
82.Fc 83.Fc
83.Ft "const BIGNUM *" 84.Ft const BIGNUM *
84.Fo DH_get0_q 85.Fo DH_get0_q
85.Fa "const DH *dh" 86.Fa "const DH *dh"
86.Fc 87.Fc
87.Ft "const BIGNUM *" 88.Ft const BIGNUM *
88.Fo DH_get0_g 89.Fo DH_get0_g
89.Fa "const DH *dh" 90.Fa "const DH *dh"
90.Fc 91.Fc
@@ -101,11 +102,11 @@
101.Fa "const BIGNUM **pub_key" 102.Fa "const BIGNUM **pub_key"
102.Fa "const BIGNUM **priv_key" 103.Fa "const BIGNUM **priv_key"
103.Fc 104.Fc
104.Ft "const BIGNUM *" 105.Ft const BIGNUM *
105.Fo DH_get0_pub_key 106.Fo DH_get0_pub_key
106.Fa "const DH *dh" 107.Fa "const DH *dh"
107.Fc 108.Fc
108.Ft "const BIGNUM *" 109.Ft const BIGNUM *
109.Fo DH_get0_priv_key 110.Fo DH_get0_priv_key
110.Fa "const DH *dh" 111.Fa "const DH *dh"
111.Fc 112.Fc
diff --git a/src/lib/libcrypto/man/DH_get_ex_new_index.3 b/src/lib/libcrypto/man/DH_get_ex_new_index.3
index 81a0aff8ec..e0d1f1b813 100644
--- a/src/lib/libcrypto/man/DH_get_ex_new_index.3
+++ b/src/lib/libcrypto/man/DH_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DH_get_ex_new_index.3,v 1.5 2018/03/23 23:18:17 schwarze Exp $ 1.\" $OpenBSD: DH_get_ex_new_index.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 23 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DH_GET_EX_NEW_INDEX 3 52.Dt DH_GET_EX_NEW_INDEX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm DH_get_ex_data 57.Nm DH_get_ex_data
58.Nd add application specific data to DH structures 58.Nd add application specific data to DH structures
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/dh.h 61.In openssl/dh.h
61.Ft int 62.Ft int
62.Fo DH_get_ex_new_index 63.Fo DH_get_ex_new_index
diff --git a/src/lib/libcrypto/man/DH_new.3 b/src/lib/libcrypto/man/DH_new.3
index 4993456897..0e01a26733 100644
--- a/src/lib/libcrypto/man/DH_new.3
+++ b/src/lib/libcrypto/man/DH_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DH_new.3,v 1.12 2022/07/13 21:51:35 schwarze Exp $ 1.\" $OpenBSD: DH_new.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 13 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DH_NEW 3 52.Dt DH_NEW 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm DH_free 57.Nm DH_free
58.Nd allocate and free DH objects 58.Nd allocate and free DH objects
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/dh.h 61.In openssl/dh.h
61.Ft DH* 62.Ft DH*
62.Fn DH_new void 63.Fn DH_new void
diff --git a/src/lib/libcrypto/man/DH_set_method.3 b/src/lib/libcrypto/man/DH_set_method.3
index 70cf367c9d..3491cf8f6e 100644
--- a/src/lib/libcrypto/man/DH_set_method.3
+++ b/src/lib/libcrypto/man/DH_set_method.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DH_set_method.3,v 1.9 2023/11/19 10:34:26 tb Exp $ 1.\" $OpenBSD: DH_set_method.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 19 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DH_SET_METHOD 3 52.Dt DH_SET_METHOD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm DH_OpenSSL 59.Nm DH_OpenSSL
60.Nd select DH method 60.Nd select DH method
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/dh.h 63.In openssl/dh.h
63.Ft void 64.Ft void
64.Fo DH_set_default_method 65.Fo DH_set_default_method
diff --git a/src/lib/libcrypto/man/DH_size.3 b/src/lib/libcrypto/man/DH_size.3
index 4e6dbc0cba..09c019f366 100644
--- a/src/lib/libcrypto/man/DH_size.3
+++ b/src/lib/libcrypto/man/DH_size.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DH_size.3,v 1.10 2022/07/13 21:51:35 schwarze Exp $ 1.\" $OpenBSD: DH_size.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> 4.\" This file was written by Ulf Moeller <ulf@openssl.org>
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: July 13 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt DH_SIZE 3 53.Dt DH_SIZE 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm DH_bits 57.Nm DH_bits
58.Nd get Diffie-Hellman prime size 58.Nd get Diffie-Hellman prime size
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/dh.h 61.In openssl/dh.h
61.Ft int 62.Ft int
62.Fo DH_size 63.Fo DH_size
diff --git a/src/lib/libcrypto/man/DIST_POINT_new.3 b/src/lib/libcrypto/man/DIST_POINT_new.3
index 6a5cc40468..e5aeb2a5d5 100644
--- a/src/lib/libcrypto/man/DIST_POINT_new.3
+++ b/src/lib/libcrypto/man/DIST_POINT_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DIST_POINT_new.3,v 1.5 2019/06/06 01:06:58 schwarze Exp $ 1.\" $OpenBSD: DIST_POINT_new.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt DIST_POINT_NEW 3 18.Dt DIST_POINT_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.Nm ISSUING_DIST_POINT_free 28.Nm ISSUING_DIST_POINT_free
29.Nd X.509 CRL distribution point extensions 29.Nd X.509 CRL distribution point extensions
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/x509v3.h 32.In openssl/x509v3.h
32.Ft DIST_POINT * 33.Ft DIST_POINT *
33.Fn DIST_POINT_new void 34.Fn DIST_POINT_new void
diff --git a/src/lib/libcrypto/man/DSA_SIG_new.3 b/src/lib/libcrypto/man/DSA_SIG_new.3
index 160b453939..003f71f0f1 100644
--- a/src/lib/libcrypto/man/DSA_SIG_new.3
+++ b/src/lib/libcrypto/man/DSA_SIG_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_SIG_new.3,v 1.8 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: DSA_SIG_new.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>, 4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: June 10 2019 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt DSA_SIG_NEW 3 54.Dt DSA_SIG_NEW 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -60,6 +60,7 @@
60.Nm DSA_SIG_set0 60.Nm DSA_SIG_set0
61.Nd manipulate DSA signature objects 61.Nd manipulate DSA signature objects
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/dsa.h 64.In openssl/dsa.h
64.Ft DSA_SIG * 65.Ft DSA_SIG *
65.Fn DSA_SIG_new void 66.Fn DSA_SIG_new void
diff --git a/src/lib/libcrypto/man/DSA_do_sign.3 b/src/lib/libcrypto/man/DSA_do_sign.3
index 4602bed872..f7de537bf9 100644
--- a/src/lib/libcrypto/man/DSA_do_sign.3
+++ b/src/lib/libcrypto/man/DSA_do_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_do_sign.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: DSA_do_sign.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 10 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_DO_SIGN 3 52.Dt DSA_DO_SIGN 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm DSA_do_verify 56.Nm DSA_do_verify
57.Nd raw DSA signature operations 57.Nd raw DSA signature operations
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/dsa.h 60.In openssl/dsa.h
60.Ft DSA_SIG * 61.Ft DSA_SIG *
61.Fo DSA_do_sign 62.Fo DSA_do_sign
diff --git a/src/lib/libcrypto/man/DSA_dup_DH.3 b/src/lib/libcrypto/man/DSA_dup_DH.3
index d6163fd3c3..a3ec94f628 100644
--- a/src/lib/libcrypto/man/DSA_dup_DH.3
+++ b/src/lib/libcrypto/man/DSA_dup_DH.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_dup_DH.3,v 1.9 2023/08/12 08:26:38 tb Exp $ 1.\" $OpenBSD: DSA_dup_DH.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 12 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_DUP_DH 3 52.Dt DSA_DUP_DH 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm DSA_dup_DH 55.Nm DSA_dup_DH
56.Nd create a DH structure out of DSA structure 56.Nd create a DH structure out of DSA structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/dsa.h 59.In openssl/dsa.h
59.Ft DH * 60.Ft DH *
60.Fo DSA_dup_DH 61.Fo DSA_dup_DH
diff --git a/src/lib/libcrypto/man/DSA_generate_key.3 b/src/lib/libcrypto/man/DSA_generate_key.3
index 37d8ec1c0f..161e0680cc 100644
--- a/src/lib/libcrypto/man/DSA_generate_key.3
+++ b/src/lib/libcrypto/man/DSA_generate_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_generate_key.3,v 1.11 2023/12/29 19:12:47 tb Exp $ 1.\" $OpenBSD: DSA_generate_key.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 29 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_GENERATE_KEY 3 52.Dt DSA_GENERATE_KEY 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm DSA_generate_key 55.Nm DSA_generate_key
56.Nd generate DSA key pair 56.Nd generate DSA key pair
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/dsa.h 59.In openssl/dsa.h
59.Ft int 60.Ft int
60.Fo DSA_generate_key 61.Fo DSA_generate_key
diff --git a/src/lib/libcrypto/man/DSA_generate_parameters_ex.3 b/src/lib/libcrypto/man/DSA_generate_parameters_ex.3
index a318bf8298..fb610b8191 100644
--- a/src/lib/libcrypto/man/DSA_generate_parameters_ex.3
+++ b/src/lib/libcrypto/man/DSA_generate_parameters_ex.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_generate_parameters_ex.3,v 1.1 2023/12/29 19:15:15 tb Exp $ 1.\" $OpenBSD: DSA_generate_parameters_ex.3,v 1.2 2025/06/08 22:37:23 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 7 22:14:47 2015 -0400 2.\" OpenSSL 9b86974e Aug 7 22:14:47 2015 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>, 4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
@@ -49,15 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: December 29 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt DSA_GENERATE_PARAMETERS_EX 3 53.Dt DSA_GENERATE_PARAMETERS_EX 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.\" .Nm DSA_generate_parameters is intentionally undocumented
57.\" because it will be removed in the next major bump
58.Nm DSA_generate_parameters_ex 56.Nm DSA_generate_parameters_ex
59.Nd generate DSA parameters 57.Nd generate DSA parameters
60.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
61.In openssl/dsa.h 60.In openssl/dsa.h
62.Ft int 61.Ft int
63.Fo DSA_generate_parameters_ex 62.Fo DSA_generate_parameters_ex
diff --git a/src/lib/libcrypto/man/DSA_get0_pqg.3 b/src/lib/libcrypto/man/DSA_get0_pqg.3
index b82affba66..e609b6250d 100644
--- a/src/lib/libcrypto/man/DSA_get0_pqg.3
+++ b/src/lib/libcrypto/man/DSA_get0_pqg.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_get0_pqg.3,v 1.11 2024/07/21 08:36:43 tb Exp $ 1.\" $OpenBSD: DSA_get0_pqg.3,v 1.13 2025/06/13 18:34:00 schwarze Exp $
2.\" full merge up to: OpenSSL e90fc053 Jul 15 09:39:45 2017 -0400 2.\" full merge up to: OpenSSL e90fc053 Jul 15 09:39:45 2017 -0400
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 4.\" This file was written by Matt Caswell <matt@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 21 2024 $ 51.Dd $Mdocdate: June 13 2025 $
52.Dt DSA_GET0_PQG 3 52.Dt DSA_GET0_PQG 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -67,6 +67,7 @@
67.Nm DSA_get0_engine 67.Nm DSA_get0_engine
68.Nd get data from and set data in a DSA object 68.Nd get data from and set data in a DSA object
69.Sh SYNOPSIS 69.Sh SYNOPSIS
70.Lb libcrypto
70.In openssl/dsa.h 71.In openssl/dsa.h
71.Ft void 72.Ft void
72.Fo DSA_get0_pqg 73.Fo DSA_get0_pqg
@@ -75,15 +76,15 @@
75.Fa "const BIGNUM **q" 76.Fa "const BIGNUM **q"
76.Fa "const BIGNUM **g" 77.Fa "const BIGNUM **g"
77.Fc 78.Fc
78.Ft "const BIGNUM *" 79.Ft const BIGNUM *
79.Fo DSA_get0_p 80.Fo DSA_get0_p
80.Fa "const DSA *d" 81.Fa "const DSA *d"
81.Fc 82.Fc
82.Ft "const BIGNUM *" 83.Ft const BIGNUM *
83.Fo DSA_get0_q 84.Fo DSA_get0_q
84.Fa "const DSA *d" 85.Fa "const DSA *d"
85.Fc 86.Fc
86.Ft "const BIGNUM *" 87.Ft const BIGNUM *
87.Fo DSA_get0_g 88.Fo DSA_get0_g
88.Fa "const DSA *d" 89.Fa "const DSA *d"
89.Fc 90.Fc
@@ -100,11 +101,11 @@
100.Fa "const BIGNUM **pub_key" 101.Fa "const BIGNUM **pub_key"
101.Fa "const BIGNUM **priv_key" 102.Fa "const BIGNUM **priv_key"
102.Fc 103.Fc
103.Ft "const BIGNUM *" 104.Ft const BIGNUM *
104.Fo DSA_get0_pub_key 105.Fo DSA_get0_pub_key
105.Fa "const DSA *d" 106.Fa "const DSA *d"
106.Fc 107.Fc
107.Ft "const BIGNUM *" 108.Ft const BIGNUM *
108.Fo DSA_get0_priv_key 109.Fo DSA_get0_priv_key
109.Fa "const DSA *d" 110.Fa "const DSA *d"
110.Fc 111.Fc
diff --git a/src/lib/libcrypto/man/DSA_get_ex_new_index.3 b/src/lib/libcrypto/man/DSA_get_ex_new_index.3
index 8fe055f337..477c011c53 100644
--- a/src/lib/libcrypto/man/DSA_get_ex_new_index.3
+++ b/src/lib/libcrypto/man/DSA_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_get_ex_new_index.3,v 1.5 2018/03/22 16:06:33 schwarze Exp $ 1.\" $OpenBSD: DSA_get_ex_new_index.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 22 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_GET_EX_NEW_INDEX 3 52.Dt DSA_GET_EX_NEW_INDEX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm DSA_get_ex_data 57.Nm DSA_get_ex_data
58.Nd add application specific data to DSA structures 58.Nd add application specific data to DSA structures
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/dsa.h 61.In openssl/dsa.h
61.Ft int 62.Ft int
62.Fo DSA_get_ex_new_index 63.Fo DSA_get_ex_new_index
diff --git a/src/lib/libcrypto/man/DSA_meth_new.3 b/src/lib/libcrypto/man/DSA_meth_new.3
index d89cd397b0..abd023346e 100644
--- a/src/lib/libcrypto/man/DSA_meth_new.3
+++ b/src/lib/libcrypto/man/DSA_meth_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_meth_new.3,v 1.3 2022/07/10 13:41:59 schwarze Exp $ 1.\" $OpenBSD: DSA_meth_new.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" selective merge up to: OpenSSL c4d3c19b Apr 3 13:57:12 2018 +0100 2.\" selective merge up to: OpenSSL c4d3c19b Apr 3 13:57:12 2018 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: July 10 2022 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt DSA_METH_NEW 3 69.Dt DSA_METH_NEW 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -78,6 +78,7 @@
78.Nm DSA_meth_set_finish 78.Nm DSA_meth_set_finish
79.Nd build up DSA methods 79.Nd build up DSA methods
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/dsa.h 82.In openssl/dsa.h
82.Ft DSA_METHOD * 83.Ft DSA_METHOD *
83.Fo DSA_meth_new 84.Fo DSA_meth_new
diff --git a/src/lib/libcrypto/man/DSA_new.3 b/src/lib/libcrypto/man/DSA_new.3
index 5a958b58c4..5340bec4bd 100644
--- a/src/lib/libcrypto/man/DSA_new.3
+++ b/src/lib/libcrypto/man/DSA_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_new.3,v 1.14 2023/12/29 19:12:47 tb Exp $ 1.\" $OpenBSD: DSA_new.3,v 1.15 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 29 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_NEW 3 52.Dt DSA_NEW 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm DSA_free 57.Nm DSA_free
58.Nd allocate and free DSA objects 58.Nd allocate and free DSA objects
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/dsa.h 61.In openssl/dsa.h
61.Ft DSA* 62.Ft DSA*
62.Fn DSA_new void 63.Fn DSA_new void
diff --git a/src/lib/libcrypto/man/DSA_set_method.3 b/src/lib/libcrypto/man/DSA_set_method.3
index c60a3e29c3..f2a6eca57c 100644
--- a/src/lib/libcrypto/man/DSA_set_method.3
+++ b/src/lib/libcrypto/man/DSA_set_method.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_set_method.3,v 1.12 2024/05/11 06:53:19 tb Exp $ 1.\" $OpenBSD: DSA_set_method.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 11 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_SET_METHOD 3 52.Dt DSA_SET_METHOD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm DSA_OpenSSL 59.Nm DSA_OpenSSL
60.Nd select DSA method 60.Nd select DSA method
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/dsa.h 63.In openssl/dsa.h
63.Ft void 64.Ft void
64.Fo DSA_set_default_method 65.Fo DSA_set_default_method
diff --git a/src/lib/libcrypto/man/DSA_sign.3 b/src/lib/libcrypto/man/DSA_sign.3
index 59f9042ba6..787dc903ea 100644
--- a/src/lib/libcrypto/man/DSA_sign.3
+++ b/src/lib/libcrypto/man/DSA_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_sign.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: DSA_sign.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 10 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_SIGN 3 52.Dt DSA_SIGN 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm DSA_verify 57.Nm DSA_verify
58.Nd DSA signatures 58.Nd DSA signatures
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/dsa.h 61.In openssl/dsa.h
61.Ft int 62.Ft int
62.Fo DSA_sign 63.Fo DSA_sign
diff --git a/src/lib/libcrypto/man/DSA_size.3 b/src/lib/libcrypto/man/DSA_size.3
index 4786acc7e9..09ce80e132 100644
--- a/src/lib/libcrypto/man/DSA_size.3
+++ b/src/lib/libcrypto/man/DSA_size.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DSA_size.3,v 1.8 2022/07/13 21:44:23 schwarze Exp $ 1.\" $OpenBSD: DSA_size.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: July 13 2022 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt DSA_SIZE 3 70.Dt DSA_SIZE 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -74,6 +74,7 @@
74.Nm DSA_bits 74.Nm DSA_bits
75.Nd get DSA signature or key size 75.Nd get DSA signature or key size
76.Sh SYNOPSIS 76.Sh SYNOPSIS
77.Lb libcrypto
77.In openssl/dsa.h 78.In openssl/dsa.h
78.Ft int 79.Ft int
79.Fo DSA_size 80.Fo DSA_size
diff --git a/src/lib/libcrypto/man/ECDH_compute_key.3 b/src/lib/libcrypto/man/ECDH_compute_key.3
index 93cbf3c078..b0ae6ad34c 100644
--- a/src/lib/libcrypto/man/ECDH_compute_key.3
+++ b/src/lib/libcrypto/man/ECDH_compute_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ECDH_compute_key.3,v 1.4 2025/04/25 20:04:09 tb Exp $ 1.\" $OpenBSD: ECDH_compute_key.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: April 25 2025 $ 16.Dd $Mdocdate: June 8 2025 $
17.Dt ECDH_COMPUTE_KEY 3 17.Dt ECDH_COMPUTE_KEY 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
@@ -21,6 +21,7 @@
21.Nm ECDH_size 21.Nm ECDH_size
22.Nd Elliptic Curve Diffie-Hellman key exchange 22.Nd Elliptic Curve Diffie-Hellman key exchange
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/ec.h 25.In openssl/ec.h
25.Ft int 26.Ft int
26.Fo ECDH_compute_key 27.Fo ECDH_compute_key
diff --git a/src/lib/libcrypto/man/ECDSA_SIG_new.3 b/src/lib/libcrypto/man/ECDSA_SIG_new.3
index 8755fe7967..4554af035c 100644
--- a/src/lib/libcrypto/man/ECDSA_SIG_new.3
+++ b/src/lib/libcrypto/man/ECDSA_SIG_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ECDSA_SIG_new.3,v 1.22 2025/04/25 20:04:09 tb Exp $ 1.\" $OpenBSD: ECDSA_SIG_new.3,v 1.24 2025/06/13 18:34:00 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" selective merge up to: OpenSSL da4ea0cf Aug 5 16:13:24 2019 +0100 3.\" selective merge up to: OpenSSL da4ea0cf Aug 5 16:13:24 2019 +0100
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: April 25 2025 $ 53.Dd $Mdocdate: June 13 2025 $
54.Dt ECDSA_SIG_NEW 3 54.Dt ECDSA_SIG_NEW 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -69,8 +69,9 @@
69.Nm ECDSA_do_verify 69.Nm ECDSA_do_verify
70.Nd Elliptic Curve Digital Signature Algorithm 70.Nd Elliptic Curve Digital Signature Algorithm
71.Sh SYNOPSIS 71.Sh SYNOPSIS
72.Lb libcrypto
72.In openssl/ec.h 73.In openssl/ec.h
73.Ft ECDSA_SIG* 74.Ft ECDSA_SIG *
74.Fo ECDSA_SIG_new 75.Fo ECDSA_SIG_new
75.Fa void 76.Fa void
76.Fc 77.Fc
@@ -84,11 +85,11 @@
84.Fa "const BIGNUM **r" 85.Fa "const BIGNUM **r"
85.Fa "const BIGNUM **s" 86.Fa "const BIGNUM **s"
86.Fc 87.Fc
87.Ft "const BIGNUM *" 88.Ft const BIGNUM *
88.Fo ECDSA_SIG_get0_r 89.Fo ECDSA_SIG_get0_r
89.Fa "const ECDSA_SIG *sig" 90.Fa "const ECDSA_SIG *sig"
90.Fc 91.Fc
91.Ft "const BIGNUM *" 92.Ft const BIGNUM *
92.Fo ECDSA_SIG_get0_s 93.Fo ECDSA_SIG_get0_s
93.Fa "const ECDSA_SIG *sig" 94.Fa "const ECDSA_SIG *sig"
94.Fc 95.Fc
@@ -103,7 +104,7 @@
103.Fa "const ECDSA_SIG *sig_in" 104.Fa "const ECDSA_SIG *sig_in"
104.Fa "unsigned char **der_out" 105.Fa "unsigned char **der_out"
105.Fc 106.Fc
106.Ft ECDSA_SIG* 107.Ft ECDSA_SIG *
107.Fo d2i_ECDSA_SIG 108.Fo d2i_ECDSA_SIG
108.Fa "ECDSA_SIG **sig_out" 109.Fa "ECDSA_SIG **sig_out"
109.Fa "const unsigned char **der_in" 110.Fa "const unsigned char **der_in"
@@ -131,7 +132,7 @@
131.Fa "int siglen" 132.Fa "int siglen"
132.Fa "EC_KEY *eckey" 133.Fa "EC_KEY *eckey"
133.Fc 134.Fc
134.Ft ECDSA_SIG* 135.Ft ECDSA_SIG *
135.Fo ECDSA_do_sign 136.Fo ECDSA_do_sign
136.Fa "const unsigned char *dgst" 137.Fa "const unsigned char *dgst"
137.Fa "int dgst_len" 138.Fa "int dgst_len"
diff --git a/src/lib/libcrypto/man/EC_GROUP_check.3 b/src/lib/libcrypto/man/EC_GROUP_check.3
index e000be212b..146c3d255d 100644
--- a/src/lib/libcrypto/man/EC_GROUP_check.3
+++ b/src/lib/libcrypto/man/EC_GROUP_check.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_GROUP_check.3,v 1.1 2025/04/25 19:57:12 tb Exp $ 1.\" $OpenBSD: EC_GROUP_check.3,v 1.6 2025/07/04 05:16:56 jsg Exp $
2.\" 2.\"
3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 25 2025 $ 17.Dd $Mdocdate: July 4 2025 $
18.Dt EC_GROUP_CHECK 3 18.Dt EC_GROUP_CHECK 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,17 +24,18 @@
24.Vt EC_GROUP 24.Vt EC_GROUP
25objects 25objects
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/bn.h 28.In openssl/bn.h
28.In openssl/ec.h 29.In openssl/ec.h
29.Pp 30.Pp
30Deprecated: 31Deprecated:
31.Pp 32.Pp
32.Ft "int" 33.Ft int
33.Fo EC_GROUP_check_discriminant 34.Fo EC_GROUP_check_discriminant
34.Fa "const EC_GROUP *group" 35.Fa "const EC_GROUP *group"
35.Fa "BN_CTX *ctx" 36.Fa "BN_CTX *ctx"
36.Fc 37.Fc
37.Ft "int" 38.Ft int
38.Fo EC_GROUP_check 39.Fo EC_GROUP_check
39.Fa "const EC_GROUP *group" 40.Fa "const EC_GROUP *group"
40.Fa "BN_CTX *ctx" 41.Fa "BN_CTX *ctx"
@@ -43,8 +44,8 @@ Deprecated:
43These functions are deprecated. 44These functions are deprecated.
44Only standardized curves built into the library should be used, see 45Only standardized curves built into the library should be used, see
45.Xr EC_GROUP_new_by_curve_name 3 . 46.Xr EC_GROUP_new_by_curve_name 3 .
46For builtin curves far more thorough checks than the minimal checks 47Builtin curves went through far more thorough checking than
47performed by these functions have been performed. 48the minimal, incomplete tests performed by these functions.
48.Pp 49.Pp
49These functions have an optional 50These functions have an optional
50.Fa ctx 51.Fa ctx
@@ -67,7 +68,7 @@ this implies that the Weierstrass equation defines an elliptic curve.
67.Fn EC_GROUP_check 68.Fn EC_GROUP_check
68partially verifies that 69partially verifies that
69.Fa group 70.Fa group
70represents an an elliptic curve and that 71represents an elliptic curve and that
71.Fa generator 72.Fa generator
72is a point on the curve whose order divides 73is a point on the curve whose order divides
73.Fa order . 74.Fa order .
@@ -79,17 +80,19 @@ and then verifies that that
79is non-zero and that the product 80is non-zero and that the product
80.Fa generator No * Fa order 81.Fa generator No * Fa order
81is the point at infinity. 82is the point at infinity.
82This implies that 83This implies that the
83.Fa order 84.Fa order
85set on
86.Fa group
84is an integer multiple of the 87is an integer multiple of the
85.Fa generator Ns 's 88.Fa generator Ns 's
86.Fa order . 89order.
87The verification that 90The verification that
88.Fa p 91.Fa p
89is a prime 92is a prime
90and that 93and that
91.Fa order 94.Fa order
92is the 95is equal to the
93.Fa generator Ns 's 96.Fa generator Ns 's
94order are skipped because they are too expensive. 97order are skipped because they are too expensive.
95.Sh RETURN VALUES 98.Sh RETURN VALUES
diff --git a/src/lib/libcrypto/man/EC_GROUP_get_curve_name.3 b/src/lib/libcrypto/man/EC_GROUP_get_curve_name.3
index 438debd7d1..940aa3c1a1 100644
--- a/src/lib/libcrypto/man/EC_GROUP_get_curve_name.3
+++ b/src/lib/libcrypto/man/EC_GROUP_get_curve_name.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_GROUP_get_curve_name.3,v 1.2 2025/04/26 05:31:27 tb Exp $ 1.\" $OpenBSD: EC_GROUP_get_curve_name.3,v 1.4 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 26 2025 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt EC_GROUP_GET_CURVE_NAME 3 18.Dt EC_GROUP_GET_CURVE_NAME 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,6 +32,7 @@
32.Vt EC_GROUP 32.Vt EC_GROUP
33and related objects 33and related objects
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/ec.h 36.In openssl/ec.h
36.Ft int 37.Ft int
37.Fo EC_GROUP_get_curve_name 38.Fo EC_GROUP_get_curve_name
@@ -51,7 +52,7 @@ and related objects
51.Fa "EC_GROUP *group" 52.Fa "EC_GROUP *group"
52.Fa "int flag" 53.Fa "int flag"
53.Fc 54.Fc
54.Ft "unsigned char *" 55.Ft unsigned char *
55.Fo EC_GROUP_get0_seed 56.Fo EC_GROUP_get0_seed
56.Fa "const EC_GROUP *group" 57.Fa "const EC_GROUP *group"
57.Fc 58.Fc
diff --git a/src/lib/libcrypto/man/EC_GROUP_new_by_curve_name.3 b/src/lib/libcrypto/man/EC_GROUP_new_by_curve_name.3
index 216dc56c3f..e05365874f 100644
--- a/src/lib/libcrypto/man/EC_GROUP_new_by_curve_name.3
+++ b/src/lib/libcrypto/man/EC_GROUP_new_by_curve_name.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_GROUP_new_by_curve_name.3,v 1.2 2025/04/28 17:41:55 tb Exp $ 1.\" $OpenBSD: EC_GROUP_new_by_curve_name.3,v 1.4 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024, 2025 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2024, 2025 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 28 2025 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt EC_GROUP_NEW_BY_CURVE_NAME 3 18.Dt EC_GROUP_NEW_BY_CURVE_NAME 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,10 +27,11 @@
27.Nm EC_curve_nist2nid 27.Nm EC_curve_nist2nid
28.Nd instantiate named curves built into libcrypto 28.Nd instantiate named curves built into libcrypto
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/bn.h 31.In openssl/bn.h
31.In openssl/ec.h 32.In openssl/ec.h
32.In openssl/objects.h 33.In openssl/objects.h
33.Ft "EC_GROUP *" 34.Ft EC_GROUP *
34.Fo EC_GROUP_new_by_curve_name 35.Fo EC_GROUP_new_by_curve_name
35.Fa "int nid" 36.Fa "int nid"
36.Fc 37.Fc
@@ -64,7 +65,7 @@ typedef struct {
64.Fo EC_curve_nist2nid 65.Fo EC_curve_nist2nid
65.Fa "const char *name" 66.Fa "const char *name"
66.Fc 67.Fc
67.Ft "const char *" 68.Ft const char *
68.Fo EC_curve_nid2nist 69.Fo EC_curve_nid2nist
69.Fa "int nid" 70.Fa "int nid"
70.Fc 71.Fc
diff --git a/src/lib/libcrypto/man/EC_GROUP_new_curve_GFp.3 b/src/lib/libcrypto/man/EC_GROUP_new_curve_GFp.3
index 3346bd80ef..038deff434 100644
--- a/src/lib/libcrypto/man/EC_GROUP_new_curve_GFp.3
+++ b/src/lib/libcrypto/man/EC_GROUP_new_curve_GFp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_GROUP_new_curve_GFp.3,v 1.2 2025/04/26 07:07:29 tb Exp $ 1.\" $OpenBSD: EC_GROUP_new_curve_GFp.3,v 1.5 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 26 2025 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt EC_GROUP_NEW_CURVE_GFP 3 18.Dt EC_GROUP_NEW_CURVE_GFP 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,9 +32,10 @@
32.Nm EC_GROUP_get_curve_GFp 32.Nm EC_GROUP_get_curve_GFp
33.Nd define elliptic curves and retrieve information from them 33.Nd define elliptic curves and retrieve information from them
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/bn.h 36.In openssl/bn.h
36.In openssl/ec.h 37.In openssl/ec.h
37.Ft "EC_GROUP *" 38.Ft EC_GROUP *
38.Fo EC_GROUP_new_curve_GFp 39.Fo EC_GROUP_new_curve_GFp
39.Fa "const BIGNUM *p" 40.Fa "const BIGNUM *p"
40.Fa "const BIGNUM *a" 41.Fa "const BIGNUM *a"
@@ -64,7 +65,7 @@
64.Fa "const BIGNUM *order" 65.Fa "const BIGNUM *order"
65.Fa "const BIGNUM *cofactor" 66.Fa "const BIGNUM *cofactor"
66.Fc 67.Fc
67.Ft "const EC_POINT *" 68.Ft const EC_POINT *
68.Fo EC_GROUP_get0_generator 69.Fo EC_GROUP_get0_generator
69.Fa "const EC_GROUP *group" 70.Fa "const EC_GROUP *group"
70.Fc 71.Fc
@@ -125,7 +126,9 @@ elliptic curves in Weierstrass form.
125These curves are defined over the prime field of order 126These curves are defined over the prime field of order
126.Fa p 127.Fa p
127via the Weierstrass equation 128via the Weierstrass equation
129.Pp
128.Dl y^2 = x^3 + ax + b 130.Dl y^2 = x^3 + ax + b
131.Pp
129where 132where
130.Fa a 133.Fa a
131and 134and
@@ -143,7 +146,9 @@ the product of
143and another integer called the 146and another integer called the
144.Fa cofactor . 147.Fa cofactor .
145Hasse's theorem is the inequality 148Hasse's theorem is the inequality
149.Pp
146.Dl | Ns Fa order No * Fa cofactor No - (p + 1)| <= 2 sqrt(p) 150.Dl | Ns Fa order No * Fa cofactor No - (p + 1)| <= 2 sqrt(p)
151.Pp
147which implies an upper bound on 152which implies an upper bound on
148.Fa order 153.Fa order
149in terms of 154in terms of
@@ -445,7 +450,7 @@ have been available since
445Too many. 450Too many.
446The API is unergonomic and the design is very poor even by 451The API is unergonomic and the design is very poor even by
447OpenSSL's standards. 452OpenSSL's standards.
448Naming is inconsistent, especially in regards to the _GFp suffix 453Naming is inconsistent, especially in regard to the _GFp suffix
449and the _get_ infix. 454and the _get_ infix.
450Function signatures are inconsistent. 455Function signatures are inconsistent.
451In particular, functions that should have a 456In particular, functions that should have a
diff --git a/src/lib/libcrypto/man/EC_KEY_METHOD_new.3 b/src/lib/libcrypto/man/EC_KEY_METHOD_new.3
index 5f5795d5cc..a0ab6bac9e 100644
--- a/src/lib/libcrypto/man/EC_KEY_METHOD_new.3
+++ b/src/lib/libcrypto/man/EC_KEY_METHOD_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_KEY_METHOD_new.3,v 1.5 2025/04/25 19:57:12 tb Exp $ 1.\" $OpenBSD: EC_KEY_METHOD_new.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: April 25 2025 $ 16.Dd $Mdocdate: June 8 2025 $
17.Dt EC_KEY_METHOD_NEW 3 17.Dt EC_KEY_METHOD_NEW 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
@@ -37,6 +37,7 @@
37.Nm EC_KEY_get_method 37.Nm EC_KEY_get_method
38.Nd custom EC_KEY implementations 38.Nd custom EC_KEY implementations
39.Sh SYNOPSIS 39.Sh SYNOPSIS
40.Lb libcrypto
40.In openssl/ec.h 41.In openssl/ec.h
41.Ft EC_KEY_METHOD * 42.Ft EC_KEY_METHOD *
42.Fo EC_KEY_METHOD_new 43.Fo EC_KEY_METHOD_new
diff --git a/src/lib/libcrypto/man/EC_KEY_new.3 b/src/lib/libcrypto/man/EC_KEY_new.3
index a2592a20ae..41ebbbe878 100644
--- a/src/lib/libcrypto/man/EC_KEY_new.3
+++ b/src/lib/libcrypto/man/EC_KEY_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_KEY_new.3,v 1.22 2025/04/25 19:57:12 tb Exp $ 1.\" $OpenBSD: EC_KEY_new.3,v 1.23 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 3aef36ff Jan 5 13:06:03 2016 -0500 2.\" full merge up to: OpenSSL 3aef36ff Jan 5 13:06:03 2016 -0500
3.\" partial merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 3.\" partial merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 25 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EC_KEY_NEW 3 53.Dt EC_KEY_NEW 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -81,6 +81,7 @@
81.Nm EC_KEY_print_fp 81.Nm EC_KEY_print_fp
82.Nd create, destroy and manipulate EC_KEY objects 82.Nd create, destroy and manipulate EC_KEY objects
83.Sh SYNOPSIS 83.Sh SYNOPSIS
84.Lb libcrypto
84.In openssl/ec.h 85.In openssl/ec.h
85.In openssl/bn.h 86.In openssl/bn.h
86.Ft EC_KEY * 87.Ft EC_KEY *
diff --git a/src/lib/libcrypto/man/EC_POINT_add.3 b/src/lib/libcrypto/man/EC_POINT_add.3
index 9c75f0dcd3..28f3143a8d 100644
--- a/src/lib/libcrypto/man/EC_POINT_add.3
+++ b/src/lib/libcrypto/man/EC_POINT_add.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_POINT_add.3,v 1.16 2025/04/25 19:57:12 tb Exp $ 1.\" $OpenBSD: EC_POINT_add.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 4.\" This file was written by Matt Caswell <matt@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 25 2025 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EC_POINT_ADD 3 52.Dt EC_POINT_ADD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -62,6 +62,7 @@
62.Nm EC_POINT_mul 62.Nm EC_POINT_mul
63.Nd perform mathematical operations and tests on EC_POINT objects 63.Nd perform mathematical operations and tests on EC_POINT objects
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libcrypto
65.In openssl/ec.h 66.In openssl/ec.h
66.In openssl/bn.h 67.In openssl/bn.h
67.Ft int 68.Ft int
diff --git a/src/lib/libcrypto/man/EC_POINT_get_affine_coordinates.3 b/src/lib/libcrypto/man/EC_POINT_get_affine_coordinates.3
index b36d480530..76ef516307 100644
--- a/src/lib/libcrypto/man/EC_POINT_get_affine_coordinates.3
+++ b/src/lib/libcrypto/man/EC_POINT_get_affine_coordinates.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_POINT_get_affine_coordinates.3,v 1.1 2025/04/25 19:57:12 tb Exp $ 1.\" $OpenBSD: EC_POINT_get_affine_coordinates.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 25 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt EC_POINT_GET_AFFINE_COORDINATES 3 18.Dt EC_POINT_GET_AFFINE_COORDINATES 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.Nm EC_POINT_set_compressed_coordinates_GFp 27.Nm EC_POINT_set_compressed_coordinates_GFp
28.Nd get and set coordinates of elliptic curve points 28.Nd get and set coordinates of elliptic curve points
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/bn.h 31.In openssl/bn.h
31.In openssl/ec.h 32.In openssl/ec.h
32.Pp 33.Pp
diff --git a/src/lib/libcrypto/man/EC_POINT_new.3 b/src/lib/libcrypto/man/EC_POINT_new.3
index cfc988f294..0a797f8bc9 100644
--- a/src/lib/libcrypto/man/EC_POINT_new.3
+++ b/src/lib/libcrypto/man/EC_POINT_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_POINT_new.3,v 1.18 2025/04/25 19:57:12 tb Exp $ 1.\" $OpenBSD: EC_POINT_new.3,v 1.21 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 25 2025 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt EC_POINT_NEW 3 18.Dt EC_POINT_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,26 +25,27 @@
25.Nm EC_POINT_dup 25.Nm EC_POINT_dup
26.Nd allocate, free and copy elliptic curve points 26.Nd allocate, free and copy elliptic curve points
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/ec.h 29.In openssl/ec.h
29.Pp 30.Pp
30.Ft "EC_POINT *" 31.Ft EC_POINT *
31.Fo EC_POINT_new 32.Fo EC_POINT_new
32.Fa "const EC_GROUP *group" 33.Fa "const EC_GROUP *group"
33.Fc 34.Fc
34.Ft "void" 35.Ft void
35.Fo EC_POINT_free 36.Fo EC_POINT_free
36.Fa "EC_POINT *point" 37.Fa "EC_POINT *point"
37.Fc 38.Fc
38.Ft "void" 39.Ft void
39.Fo EC_POINT_clear_free 40.Fo EC_POINT_clear_free
40.Fa "EC_POINT *point" 41.Fa "EC_POINT *point"
41.Fc 42.Fc
42.Ft "int" 43.Ft int
43.Fo EC_POINT_copy 44.Fo EC_POINT_copy
44.Fa "EC_POINT *dst" 45.Fa "EC_POINT *dst"
45.Fa "const EC_POINT *src" 46.Fa "const EC_POINT *src"
46.Fc 47.Fc
47.Ft "EC_POINT *" 48.Ft EC_POINT *
48.Fo EC_POINT_dup 49.Fo EC_POINT_dup
49.Fa "const EC_POINT *point" 50.Fa "const EC_POINT *point"
50.Fa "const EC_GROUP *group" 51.Fa "const EC_GROUP *group"
@@ -178,7 +179,7 @@ A fundamental flaw in the OpenSSL API toolkit is that
178.Fn *_new 179.Fn *_new
179functions usually create invalid objects that are tricky to 180functions usually create invalid objects that are tricky to
180turn into valid objects. 181turn into valid objects.
181A fundamental flaw in the EC library is that 182One specific flaw in the EC library internals is that
182.Vt EC_POINT 183.Vt EC_POINT
183objects do not hold a reference to the group they live on 184objects do not hold a reference to the group they live on
184despite the fact that 185despite the fact that
@@ -191,12 +192,12 @@ This is difficult to fix because
191objects are not reference counted and 192objects are not reference counted and
192because of const qualifiers in the API. 193because of const qualifiers in the API.
193This is the root cause for various contortions in the EC library 194This is the root cause for various contortions in the EC library
194and API. 195and API and
195This has security implications because not 196there are security implications because not
196only does the library not know whether an 197only does the library not know whether an
197.Fa EC_POINT 198.Fa EC_POINT
198object represents a valid point, 199object represents a valid point,
199even if it did know that it would not know on what curve. 200even if it did know that it would still not know on what curve.
200.Pp 201.Pp
201The signature of 202The signature of
202.Fn EC_GROUP_dup 203.Fn EC_GROUP_dup
diff --git a/src/lib/libcrypto/man/EC_POINT_point2oct.3 b/src/lib/libcrypto/man/EC_POINT_point2oct.3
index ebb09f8001..ac89c9b1d4 100644
--- a/src/lib/libcrypto/man/EC_POINT_point2oct.3
+++ b/src/lib/libcrypto/man/EC_POINT_point2oct.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EC_POINT_point2oct.3,v 1.2 2025/04/26 09:03:03 tb Exp $ 1.\" $OpenBSD: EC_POINT_point2oct.3,v 1.6 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 26 2025 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt EC_POINT_POINT2OCT 3 18.Dt EC_POINT_POINT2OCT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm EC_POINT_hex2point 26.Nm EC_POINT_hex2point
27.Nd encode and decode elliptic curve points 27.Nd encode and decode elliptic curve points
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/bn.h 30.In openssl/bn.h
30.In openssl/ec.h 31.In openssl/ec.h
31.Bd -literal 32.Bd -literal
@@ -53,7 +54,7 @@ typedef enum {
53.Fa "size_t len" 54.Fa "size_t len"
54.Fa "BN_CTX *ctx" 55.Fa "BN_CTX *ctx"
55.Fc 56.Fc
56.Ft "BIGNUM *" 57.Ft BIGNUM *
57.Fo EC_POINT_point2bn 58.Fo EC_POINT_point2bn
58.Fa "const EC_GROUP *group" 59.Fa "const EC_GROUP *group"
59.Fa "const EC_POINT *point" 60.Fa "const EC_POINT *point"
@@ -61,21 +62,21 @@ typedef enum {
61.Fa "BIGNUM *bn" 62.Fa "BIGNUM *bn"
62.Fa "BN_CTX *ctx" 63.Fa "BN_CTX *ctx"
63.Fc 64.Fc
64.Ft "EC_POINT *" 65.Ft EC_POINT *
65.Fo EC_POINT_bn2point 66.Fo EC_POINT_bn2point
66.Fa "const EC_GROUP *group" 67.Fa "const EC_GROUP *group"
67.Fa "const BIGNUM *bn" 68.Fa "const BIGNUM *bn"
68.Fa "EC_POINT *point" 69.Fa "EC_POINT *point"
69.Fa "BN_CTX *ctx" 70.Fa "BN_CTX *ctx"
70.Fc 71.Fc
71.Ft "char *" 72.Ft char *
72.Fo EC_POINT_point2hex 73.Fo EC_POINT_point2hex
73.Fa "const EC_GROUP *group" 74.Fa "const EC_GROUP *group"
74.Fa "const EC_POINT *point" 75.Fa "const EC_POINT *point"
75.Fa "point_conversion_form_t form" 76.Fa "point_conversion_form_t form"
76.Fa "BN_CTX *ctx" 77.Fa "BN_CTX *ctx"
77.Fc 78.Fc
78.Ft "EC_POINT *" 79.Ft EC_POINT *
79.Fo EC_POINT_hex2point 80.Fo EC_POINT_hex2point
80.Fa "const EC_GROUP *group" 81.Fa "const EC_GROUP *group"
81.Fa "const char *hex" 82.Fa "const char *hex"
@@ -95,7 +96,9 @@ object.
95It is either the point at infinity or it has a representation 96It is either the point at infinity or it has a representation
96(x, y) in standard affine coordinates, 97(x, y) in standard affine coordinates,
97in which case it satisfies the curve's Weierstrass equation 98in which case it satisfies the curve's Weierstrass equation
99.Pp
98.Dl y^2 = x^3 + ax + b 100.Dl y^2 = x^3 + ax + b
101.Pp
99in the prime field of size p. 102in the prime field of size p.
100Thus, y is a square root of x^3 + ax + b. 103Thus, y is a square root of x^3 + ax + b.
101Since p > 3 is odd, p - y is another square root 104Since p > 3 is odd, p - y is another square root
@@ -152,7 +155,7 @@ is not
152and its length 155and its length
153.Fa len 156.Fa len
154is sufficiently big, 157is sufficiently big,
155.Fn EC_POINT_point2oct 3 158.Fn EC_POINT_point2oct
156writes the 159writes the
157.Fa point Ns 's 160.Fa point Ns 's
158encoding of type 161encoding of type
@@ -242,7 +245,7 @@ The string must be freed by the caller using
242is equivalent to 245is equivalent to
243.Fn EC_POINT_point2bn 246.Fn EC_POINT_point2bn
244followed by 247followed by
245.Fn BN_bn2hex 3 . 248.Xr BN_bn2hex 3 .
246.Pp 249.Pp
247.Fn EC_POINT_hex2point 250.Fn EC_POINT_hex2point
248interprets 251interprets
diff --git a/src/lib/libcrypto/man/ENGINE_new.3 b/src/lib/libcrypto/man/ENGINE_new.3
index 55ed963563..f70adecc17 100644
--- a/src/lib/libcrypto/man/ENGINE_new.3
+++ b/src/lib/libcrypto/man/ENGINE_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ENGINE_new.3,v 1.10 2023/11/19 21:13:47 tb Exp $ 1.\" $OpenBSD: ENGINE_new.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: November 19 2023 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt ENGINE_NEW 3 19.Dt ENGINE_NEW 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -40,6 +40,7 @@
40.Nm ENGINE_cleanup 40.Nm ENGINE_cleanup
41.Nd ENGINE stub functions 41.Nd ENGINE stub functions
42.Sh SYNOPSIS 42.Sh SYNOPSIS
43.Lb libcrypto
43.In openssl/engine.h 44.In openssl/engine.h
44.Ft ENGINE * 45.Ft ENGINE *
45.Fn ENGINE_new void 46.Fn ENGINE_new void
diff --git a/src/lib/libcrypto/man/ERR.3 b/src/lib/libcrypto/man/ERR.3
index 8f17e7a329..7d67c4f556 100644
--- a/src/lib/libcrypto/man/ERR.3
+++ b/src/lib/libcrypto/man/ERR.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR.3,v 1.11 2023/07/26 20:15:51 tb Exp $ 1.\" $OpenBSD: ERR.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 2.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: July 26 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt ERR 3 53.Dt ERR 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm ERR 56.Nm ERR
57.Nd OpenSSL error codes 57.Nd OpenSSL error codes
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/err.h 60.In openssl/err.h
60.Sh DESCRIPTION 61.Sh DESCRIPTION
61When a call to the OpenSSL library fails, this is usually signaled by 62When a call to the OpenSSL library fails, this is usually signaled by
diff --git a/src/lib/libcrypto/man/ERR_GET_LIB.3 b/src/lib/libcrypto/man/ERR_GET_LIB.3
index bc14f0e2ac..754f7fafe3 100644
--- a/src/lib/libcrypto/man/ERR_GET_LIB.3
+++ b/src/lib/libcrypto/man/ERR_GET_LIB.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_GET_LIB.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: ERR_GET_LIB.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL doc/man3/ERR_GET_LIB.pod 3dfda1a6 Dec 12 11:14:40 2016 -0500 2.\" OpenSSL doc/man3/ERR_GET_LIB.pod 3dfda1a6 Dec 12 11:14:40 2016 -0500
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt ERR_GET_LIB 3 52.Dt ERR_GET_LIB 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm ERR_FATAL_ERROR 58.Nm ERR_FATAL_ERROR
59.Nd get library, function and reason codes for OpenSSL errors 59.Nd get library, function and reason codes for OpenSSL errors
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/err.h 62.In openssl/err.h
62.Ft int 63.Ft int
63.Fo ERR_GET_LIB 64.Fo ERR_GET_LIB
diff --git a/src/lib/libcrypto/man/ERR_asprintf_error_data.3 b/src/lib/libcrypto/man/ERR_asprintf_error_data.3
index 4291dea23e..edd8655d6d 100644
--- a/src/lib/libcrypto/man/ERR_asprintf_error_data.3
+++ b/src/lib/libcrypto/man/ERR_asprintf_error_data.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_asprintf_error_data.3,v 1.3 2024/08/29 20:23:21 tb Exp $ 1.\" $OpenBSD: ERR_asprintf_error_data.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Bob Beck <beck@openbsd.org> 3.\" Copyright (c) 2017 Bob Beck <beck@openbsd.org>
4.\" 4.\"
@@ -13,13 +13,14 @@
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.Dd $Mdocdate: August 29 2024 $ 16.Dd $Mdocdate: June 8 2025 $
17.Dt ERR_ASPRINTF_ERROR_DATA 3 17.Dt ERR_ASPRINTF_ERROR_DATA 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
20.Nm ERR_asprintf_error_data 20.Nm ERR_asprintf_error_data
21.Nd record a LibreSSL error using a formatted string 21.Nd record a LibreSSL error using a formatted string
22.Sh SYNOPSIS 22.Sh SYNOPSIS
23.Lb libcrypto
23.In openssl/err.h 24.In openssl/err.h
24.Ft void 25.Ft void
25.Fo ERR_asprintf_error_data 26.Fo ERR_asprintf_error_data
diff --git a/src/lib/libcrypto/man/ERR_clear_error.3 b/src/lib/libcrypto/man/ERR_clear_error.3
index 54f563e166..d39ac11956 100644
--- a/src/lib/libcrypto/man/ERR_clear_error.3
+++ b/src/lib/libcrypto/man/ERR_clear_error.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_clear_error.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: ERR_clear_error.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt ERR_CLEAR_ERROR 3 52.Dt ERR_CLEAR_ERROR 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm ERR_clear_error 55.Nm ERR_clear_error
56.Nd clear the OpenSSL error queue 56.Nd clear the OpenSSL error queue
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/err.h 59.In openssl/err.h
59.Ft void 60.Ft void
60.Fn ERR_clear_error void 61.Fn ERR_clear_error void
diff --git a/src/lib/libcrypto/man/ERR_error_string.3 b/src/lib/libcrypto/man/ERR_error_string.3
index 60f9132859..a1df20fe70 100644
--- a/src/lib/libcrypto/man/ERR_error_string.3
+++ b/src/lib/libcrypto/man/ERR_error_string.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_error_string.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: ERR_error_string.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt ERR_ERROR_STRING 3 52.Dt ERR_ERROR_STRING 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm ERR_reason_error_string 59.Nm ERR_reason_error_string
60.Nd obtain human-readable OpenSSL error messages 60.Nd obtain human-readable OpenSSL error messages
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/err.h 63.In openssl/err.h
63.Ft char * 64.Ft char *
64.Fo ERR_error_string 65.Fo ERR_error_string
diff --git a/src/lib/libcrypto/man/ERR_get_error.3 b/src/lib/libcrypto/man/ERR_get_error.3
index f3bcc09cbc..c592c34528 100644
--- a/src/lib/libcrypto/man/ERR_get_error.3
+++ b/src/lib/libcrypto/man/ERR_get_error.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_get_error.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: ERR_get_error.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt ERR_GET_ERROR 3 52.Dt ERR_GET_ERROR 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -63,6 +63,7 @@
63.Nm ERR_peek_last_error_line_data 63.Nm ERR_peek_last_error_line_data
64.Nd obtain OpenSSL error code and data 64.Nd obtain OpenSSL error code and data
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libcrypto
66.In openssl/err.h 67.In openssl/err.h
67.Ft unsigned long 68.Ft unsigned long
68.Fn ERR_get_error void 69.Fn ERR_get_error void
diff --git a/src/lib/libcrypto/man/ERR_load_crypto_strings.3 b/src/lib/libcrypto/man/ERR_load_crypto_strings.3
index 2bca8af60f..13da93e22d 100644
--- a/src/lib/libcrypto/man/ERR_load_crypto_strings.3
+++ b/src/lib/libcrypto/man/ERR_load_crypto_strings.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_load_crypto_strings.3,v 1.12 2024/03/05 19:21:31 tb Exp $ 1.\" $OpenBSD: ERR_load_crypto_strings.3,v 1.14 2025/06/08 22:58:09 schwarze Exp $
2.\" full merge up to: OpenSSL f672aee4 Feb 9 11:52:40 2016 -0500 2.\" full merge up to: OpenSSL f672aee4 Feb 9 11:52:40 2016 -0500
3.\" selective merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400 3.\" selective merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: March 5 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt ERR_LOAD_CRYPTO_STRINGS 3 70.Dt ERR_LOAD_CRYPTO_STRINGS 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -101,11 +101,14 @@
101.\" ERR_load_X509_strings() 101.\" ERR_load_X509_strings()
102.\" ERR_load_X509V3_strings() 102.\" ERR_load_X509V3_strings()
103.Sh SYNOPSIS 103.Sh SYNOPSIS
104.Lb libcrypto
104.In openssl/err.h 105.In openssl/err.h
105.Ft void 106.Ft void
106.Fn ERR_load_crypto_strings void 107.Fn ERR_load_crypto_strings void
107.Ft void 108.Ft void
108.Fn ERR_free_strings void 109.Fn ERR_free_strings void
110.Pp
111.Lb libssl libcrypto
109.In openssl/ssl.h 112.In openssl/ssl.h
110.Ft void 113.Ft void
111.Fn SSL_load_error_strings void 114.Fn SSL_load_error_strings void
diff --git a/src/lib/libcrypto/man/ERR_load_strings.3 b/src/lib/libcrypto/man/ERR_load_strings.3
index 1020743954..9697742404 100644
--- a/src/lib/libcrypto/man/ERR_load_strings.3
+++ b/src/lib/libcrypto/man/ERR_load_strings.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_load_strings.3,v 1.8 2024/07/26 03:40:43 tb Exp $ 1.\" $OpenBSD: ERR_load_strings.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 26 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt ERR_LOAD_STRINGS 3 52.Dt ERR_LOAD_STRINGS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm ERR_get_next_error_library 57.Nm ERR_get_next_error_library
58.Nd load arbitrary OpenSSL error strings 58.Nd load arbitrary OpenSSL error strings
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/err.h 61.In openssl/err.h
61.Ft void 62.Ft void
62.Fo ERR_load_strings 63.Fo ERR_load_strings
diff --git a/src/lib/libcrypto/man/ERR_print_errors.3 b/src/lib/libcrypto/man/ERR_print_errors.3
index a5c7c03287..4d6f8d3717 100644
--- a/src/lib/libcrypto/man/ERR_print_errors.3
+++ b/src/lib/libcrypto/man/ERR_print_errors.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_print_errors.3,v 1.8 2020/03/28 22:40:58 schwarze Exp $ 1.\" $OpenBSD: ERR_print_errors.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>, 4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 28 2020 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt ERR_PRINT_ERRORS 3 53.Dt ERR_PRINT_ERRORS 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -58,6 +58,7 @@
58.Nm ERR_print_errors_cb 58.Nm ERR_print_errors_cb
59.Nd print OpenSSL error messages 59.Nd print OpenSSL error messages
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/err.h 62.In openssl/err.h
62.Ft void 63.Ft void
63.Fo ERR_print_errors 64.Fo ERR_print_errors
diff --git a/src/lib/libcrypto/man/ERR_put_error.3 b/src/lib/libcrypto/man/ERR_put_error.3
index 37e1b4d1ab..1af0e37826 100644
--- a/src/lib/libcrypto/man/ERR_put_error.3
+++ b/src/lib/libcrypto/man/ERR_put_error.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_put_error.3,v 1.11 2024/08/29 20:23:21 tb Exp $ 1.\" $OpenBSD: ERR_put_error.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 29 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt ERR_PUT_ERROR 3 52.Dt ERR_PUT_ERROR 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm ERR_put_error 55.Nm ERR_put_error
56.Nd record an OpenSSL error 56.Nd record an OpenSSL error
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/err.h 59.In openssl/err.h
59.Ft void 60.Ft void
60.Fo ERR_put_error 61.Fo ERR_put_error
diff --git a/src/lib/libcrypto/man/ERR_remove_state.3 b/src/lib/libcrypto/man/ERR_remove_state.3
index bc28f15dea..c05810d778 100644
--- a/src/lib/libcrypto/man/ERR_remove_state.3
+++ b/src/lib/libcrypto/man/ERR_remove_state.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_remove_state.3,v 1.7 2020/03/28 22:40:58 schwarze Exp $ 1.\" $OpenBSD: ERR_remove_state.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 28 2020 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt ERR_REMOVE_STATE 3 53.Dt ERR_REMOVE_STATE 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm ERR_remove_state 57.Nm ERR_remove_state
58.Nd free a thread's OpenSSL error queue 58.Nd free a thread's OpenSSL error queue
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/err.h 61.In openssl/err.h
61.Ft void 62.Ft void
62.Fo ERR_remove_thread_state 63.Fo ERR_remove_thread_state
diff --git a/src/lib/libcrypto/man/ERR_set_mark.3 b/src/lib/libcrypto/man/ERR_set_mark.3
index 2f3486d8c0..88b1be88b5 100644
--- a/src/lib/libcrypto/man/ERR_set_mark.3
+++ b/src/lib/libcrypto/man/ERR_set_mark.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ERR_set_mark.3,v 1.4 2018/03/23 00:09:11 schwarze Exp $ 1.\" $OpenBSD: ERR_set_mark.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>. 4.\" This file was written by Richard Levitte <levitte@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 23 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt ERR_SET_MARK 3 52.Dt ERR_SET_MARK 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm ERR_pop_to_mark 56.Nm ERR_pop_to_mark
57.Nd set marks and pop OpenSSL errors until mark 57.Nd set marks and pop OpenSSL errors until mark
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/err.h 60.In openssl/err.h
60.Ft int 61.Ft int
61.Fn ERR_set_mark void 62.Fn ERR_set_mark void
diff --git a/src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3 b/src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3
index 4baabbcd99..7014d008af 100644
--- a/src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3
+++ b/src/lib/libcrypto/man/ESS_SIGNING_CERT_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ESS_SIGNING_CERT_new.3,v 1.5 2019/06/06 01:06:58 schwarze Exp $ 1.\" $OpenBSD: ESS_SIGNING_CERT_new.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt ESS_SIGNING_CERT_NEW 3 18.Dt ESS_SIGNING_CERT_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm ESS_ISSUER_SERIAL_free 26.Nm ESS_ISSUER_SERIAL_free
27.Nd signing certificates for S/MIME 27.Nd signing certificates for S/MIME
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/ts.h 30.In openssl/ts.h
30.Ft ESS_SIGNING_CERT * 31.Ft ESS_SIGNING_CERT *
31.Fn ESS_SIGNING_CERT_new void 32.Fn ESS_SIGNING_CERT_new void
diff --git a/src/lib/libcrypto/man/EVP_AEAD_CTX_init.3 b/src/lib/libcrypto/man/EVP_AEAD_CTX_init.3
index 8b3b8adb0f..41a829c675 100644
--- a/src/lib/libcrypto/man/EVP_AEAD_CTX_init.3
+++ b/src/lib/libcrypto/man/EVP_AEAD_CTX_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_AEAD_CTX_init.3,v 1.16 2024/07/21 08:36:43 tb Exp $ 1.\" $OpenBSD: EVP_AEAD_CTX_init.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014, Google Inc. 3.\" Copyright (c) 2014, Google Inc.
4.\" Parts of the text were written by Adam Langley and David Benjamin. 4.\" Parts of the text were written by Adam Langley and David Benjamin.
@@ -17,7 +17,7 @@
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\" 19.\"
20.Dd $Mdocdate: July 21 2024 $ 20.Dd $Mdocdate: June 8 2025 $
21.Dt EVP_AEAD_CTX_INIT 3 21.Dt EVP_AEAD_CTX_INIT 3
22.Os 22.Os
23.Sh NAME 23.Sh NAME
@@ -37,6 +37,7 @@
37.Nm EVP_aead_xchacha20_poly1305 37.Nm EVP_aead_xchacha20_poly1305
38.Nd authenticated encryption with additional data 38.Nd authenticated encryption with additional data
39.Sh SYNOPSIS 39.Sh SYNOPSIS
40.Lb libcrypto
40.In openssl/evp.h 41.In openssl/evp.h
41.Ft EVP_AEAD_CTX * 42.Ft EVP_AEAD_CTX *
42.Fn EVP_AEAD_CTX_new void 43.Fn EVP_AEAD_CTX_new void
diff --git a/src/lib/libcrypto/man/EVP_BytesToKey.3 b/src/lib/libcrypto/man/EVP_BytesToKey.3
index 1f78b4de06..060335744e 100644
--- a/src/lib/libcrypto/man/EVP_BytesToKey.3
+++ b/src/lib/libcrypto/man/EVP_BytesToKey.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_BytesToKey.3,v 1.9 2024/12/05 15:12:37 schwarze Exp $ 1.\" $OpenBSD: EVP_BytesToKey.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: December 5 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_BYTESTOKEY 3 53.Dt EVP_BYTESTOKEY 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm EVP_BytesToKey 56.Nm EVP_BytesToKey
57.Nd password based encryption routine 57.Nd password based encryption routine
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/evp.h 60.In openssl/evp.h
60.Ft int 61.Ft int
61.Fo EVP_BytesToKey 62.Fo EVP_BytesToKey
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
index d7ab36e711..8aaf2cc385 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_ctrl.3,v 1.4 2025/03/25 11:54:34 tb Exp $ 1.\" $OpenBSD: EVP_CIPHER_CTX_ctrl.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800 2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: March 25 2025 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt EVP_CIPHER_CTX_CTRL 3 71.Dt EVP_CIPHER_CTX_CTRL 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -82,6 +82,7 @@
82.Nm EVP_CIPHER_CTX_get_iv 82.Nm EVP_CIPHER_CTX_get_iv
83.Nd configure EVP cipher contexts 83.Nd configure EVP cipher contexts
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/evp.h 86.In openssl/evp.h
86.Ft int 87.Ft int
87.Fo EVP_CIPHER_CTX_ctrl 88.Fo EVP_CIPHER_CTX_ctrl
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3
index 4f75c8b008..a549ea25f6 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_get_cipher_data.3,v 1.3 2023/08/26 15:12:04 schwarze Exp $ 1.\" $OpenBSD: EVP_CIPHER_CTX_get_cipher_data.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: August 26 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt EVP_CIPHER_CTX_GET_CIPHER_DATA 3 69.Dt EVP_CIPHER_CTX_GET_CIPHER_DATA 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -74,6 +74,7 @@
74.Nm EVP_CIPHER_CTX_buf_noconst 74.Nm EVP_CIPHER_CTX_buf_noconst
75.Nd inspect and modify EVP_CIPHER_CTX objects 75.Nd inspect and modify EVP_CIPHER_CTX objects
76.Sh SYNOPSIS 76.Sh SYNOPSIS
77.Lb libcrypto
77.In openssl/evp.h 78.In openssl/evp.h
78.Ft void * 79.Ft void *
79.Fo EVP_CIPHER_CTX_get_cipher_data 80.Fo EVP_CIPHER_CTX_get_cipher_data
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
index 79a8e540af..7b1d81bafa 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_init.3,v 1.4 2024/12/06 15:01:01 schwarze Exp $ 1.\" $OpenBSD: EVP_CIPHER_CTX_init.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100 3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\" 4.\"
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: December 6 2024 $ 71.Dd $Mdocdate: June 8 2025 $
72.Dt EVP_CIPHER_CTX_INIT 3 72.Dt EVP_CIPHER_CTX_INIT 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -77,6 +77,7 @@
77.Nm EVP_Cipher 77.Nm EVP_Cipher
78.Nd obsolete EVP cipher functions 78.Nd obsolete EVP cipher functions
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libcrypto
80.In openssl/evp.h 81.In openssl/evp.h
81.Ft int 82.Ft int
82.Fo EVP_CIPHER_CTX_init 83.Fo EVP_CIPHER_CTX_init
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3
index 67ef8679bc..0d86050ae6 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_CTX_set_flags.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_set_flags.3,v 1.2 2023/09/06 16:26:49 schwarze Exp $ 1.\" $OpenBSD: EVP_CIPHER_CTX_set_flags.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800 2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: September 6 2023 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt EVP_CIPHER_CTX_SET_FLAGS 3 71.Dt EVP_CIPHER_CTX_SET_FLAGS 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -86,6 +86,7 @@
86.Nm EVP_CIPHER_CTX_set_app_data 86.Nm EVP_CIPHER_CTX_set_app_data
87.Nd unusual EVP cipher context configuration 87.Nd unusual EVP cipher context configuration
88.Sh SYNOPSIS 88.Sh SYNOPSIS
89.Lb libcrypto
89.In openssl/evp.h 90.In openssl/evp.h
90.Ft void 91.Ft void
91.Fo EVP_CIPHER_CTX_set_flags 92.Fo EVP_CIPHER_CTX_set_flags
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_do_all.3 b/src/lib/libcrypto/man/EVP_CIPHER_do_all.3
index e912044978..342cf372df 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_do_all.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_do_all.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_CIPHER_do_all.3,v 1.3 2024/03/14 23:54:55 tb Exp $ 1.\" $OpenBSD: EVP_CIPHER_do_all.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023,2024 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023,2024 Theo Buehler <tb@openbsd.org>
4.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 14 2024 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt EVP_CIPHER_DO_ALL 3 19.Dt EVP_CIPHER_DO_ALL 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -27,6 +27,7 @@
27.Nm OBJ_NAME_do_all_sorted 27.Nm OBJ_NAME_do_all_sorted
28.Nd iterate over lookup tables for ciphers and digests 28.Nd iterate over lookup tables for ciphers and digests
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/evp.h 31.In openssl/evp.h
31.Ft void 32.Ft void
32.Fo EVP_CIPHER_do_all 33.Fo EVP_CIPHER_do_all
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_meth_new.3 b/src/lib/libcrypto/man/EVP_CIPHER_meth_new.3
index 187dab6d8a..f831b20c3d 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_meth_new.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_meth_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_CIPHER_meth_new.3,v 1.6 2024/03/04 09:49:07 tb Exp $ 1.\" $OpenBSD: EVP_CIPHER_meth_new.3,v 1.7 2025/06/08 22:40:29 schwarze Exp $
2.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000 2.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: March 4 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt EVP_CIPHER_METH_NEW 3 70.Dt EVP_CIPHER_METH_NEW 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -84,6 +84,7 @@
84.Nm EVP_CIPHER_meth_set_ctrl 84.Nm EVP_CIPHER_meth_set_ctrl
85.Nd Routines to build up EVP_CIPHER methods 85.Nd Routines to build up EVP_CIPHER methods
86.Sh SYNOPSIS 86.Sh SYNOPSIS
87.Lb libcrypto
87.In openssl/evp.h 88.In openssl/evp.h
88.Ft EVP_CIPHER * 89.Ft EVP_CIPHER *
89.Fo EVP_CIPHER_meth_new 90.Fo EVP_CIPHER_meth_new
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_nid.3 b/src/lib/libcrypto/man/EVP_CIPHER_nid.3
index 1feff4f34e..6152c389c8 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_nid.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_nid.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_CIPHER_nid.3,v 1.3 2023/09/05 14:54:21 schwarze Exp $ 1.\" $OpenBSD: EVP_CIPHER_nid.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL man3/EVP_EncryptInit.pod 2.\" full merge up to: OpenSSL man3/EVP_EncryptInit.pod
3.\" 0874d7f2 Oct 11 13:13:47 2022 +0100 3.\" 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: September 5 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt EVP_CIPHER_NID 3 70.Dt EVP_CIPHER_NID 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -83,6 +83,7 @@
83.Nm EVP_CIPHER_CTX_mode 83.Nm EVP_CIPHER_CTX_mode
84.Nd inspect EVP_CIPHER objects 84.Nd inspect EVP_CIPHER objects
85.Sh SYNOPSIS 85.Sh SYNOPSIS
86.Lb libcrypto
86.In openssl/evp.h 87.In openssl/evp.h
87.Ft int 88.Ft int
88.Fo EVP_CIPHER_nid 89.Fo EVP_CIPHER_nid
diff --git a/src/lib/libcrypto/man/EVP_DigestInit.3 b/src/lib/libcrypto/man/EVP_DigestInit.3
index 2a634540c7..1457d65e40 100644
--- a/src/lib/libcrypto/man/EVP_DigestInit.3
+++ b/src/lib/libcrypto/man/EVP_DigestInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_DigestInit.3,v 1.38 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: EVP_DigestInit.3,v 1.39 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000 2.\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -70,7 +70,7 @@
70.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 70.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
71.\" OF THE POSSIBILITY OF SUCH DAMAGE. 71.\" OF THE POSSIBILITY OF SUCH DAMAGE.
72.\" 72.\"
73.Dd $Mdocdate: April 17 2025 $ 73.Dd $Mdocdate: June 8 2025 $
74.Dt EVP_DIGESTINIT 3 74.Dt EVP_DIGESTINIT 3
75.Os 75.Os
76.Sh NAME 76.Sh NAME
@@ -103,6 +103,7 @@
103.Nm EVP_get_digestbyobj 103.Nm EVP_get_digestbyobj
104.Nd EVP digest routines 104.Nd EVP digest routines
105.Sh SYNOPSIS 105.Sh SYNOPSIS
106.Lb libcrypto
106.In openssl/evp.h 107.In openssl/evp.h
107.Ft EVP_MD_CTX * 108.Ft EVP_MD_CTX *
108.Fn EVP_MD_CTX_new void 109.Fn EVP_MD_CTX_new void
diff --git a/src/lib/libcrypto/man/EVP_DigestSignInit.3 b/src/lib/libcrypto/man/EVP_DigestSignInit.3
index caf519e28c..46b8acbd3c 100644
--- a/src/lib/libcrypto/man/EVP_DigestSignInit.3
+++ b/src/lib/libcrypto/man/EVP_DigestSignInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_DigestSignInit.3,v 1.15 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: EVP_DigestSignInit.3,v 1.16 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 28428130 Apr 17 15:18:40 2018 +0200 2.\" full merge up to: OpenSSL 28428130 Apr 17 15:18:40 2018 +0200
3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200 3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: December 6 2024 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt EVP_DIGESTSIGNINIT 3 54.Dt EVP_DIGESTSIGNINIT 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -60,6 +60,7 @@
60.Nm EVP_DigestSign 60.Nm EVP_DigestSign
61.Nd EVP signing functions 61.Nd EVP signing functions
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/evp.h 64.In openssl/evp.h
64.Ft int 65.Ft int
65.Fo EVP_DigestSignInit 66.Fo EVP_DigestSignInit
diff --git a/src/lib/libcrypto/man/EVP_DigestVerifyInit.3 b/src/lib/libcrypto/man/EVP_DigestVerifyInit.3
index fa62f5a0a5..3d40f8e916 100644
--- a/src/lib/libcrypto/man/EVP_DigestVerifyInit.3
+++ b/src/lib/libcrypto/man/EVP_DigestVerifyInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_DigestVerifyInit.3,v 1.17 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: EVP_DigestVerifyInit.3,v 1.18 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to OpenSSL f097e875 Aug 23 11:37:22 2018 +0100 2.\" full merge up to OpenSSL f097e875 Aug 23 11:37:22 2018 +0100
3.\" selective merge up to 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: December 6 2024 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt EVP_DIGESTVERIFYINIT 3 54.Dt EVP_DIGESTVERIFYINIT 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -60,6 +60,7 @@
60.Nm EVP_DigestVerify 60.Nm EVP_DigestVerify
61.Nd EVP signature verification functions 61.Nd EVP signature verification functions
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/evp.h 64.In openssl/evp.h
64.Ft int 65.Ft int
65.Fo EVP_DigestVerifyInit 66.Fo EVP_DigestVerifyInit
diff --git a/src/lib/libcrypto/man/EVP_EncodeInit.3 b/src/lib/libcrypto/man/EVP_EncodeInit.3
index da79af84cf..82f5687c8b 100644
--- a/src/lib/libcrypto/man/EVP_EncodeInit.3
+++ b/src/lib/libcrypto/man/EVP_EncodeInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_EncodeInit.3,v 1.7 2019/06/06 01:06:58 schwarze Exp $ 1.\" $OpenBSD: EVP_EncodeInit.3,v 1.8 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL f430ba31 Jun 19 19:39:01 2016 +0200 2.\" full merge up to: OpenSSL f430ba31 Jun 19 19:39:01 2016 +0200
3.\" selective merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 3.\" selective merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 6 2019 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_ENCODEINIT 3 53.Dt EVP_ENCODEINIT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -65,6 +65,7 @@
65.Nm EVP_DecodeBlock 65.Nm EVP_DecodeBlock
66.Nd EVP base64 encode/decode routines 66.Nd EVP base64 encode/decode routines
67.Sh SYNOPSIS 67.Sh SYNOPSIS
68.Lb libcrypto
68.In openssl/evp.h 69.In openssl/evp.h
69.Ft EVP_ENCODE_CTX * 70.Ft EVP_ENCODE_CTX *
70.Fn EVP_ENCODE_CTX_new void 71.Fn EVP_ENCODE_CTX_new void
diff --git a/src/lib/libcrypto/man/EVP_EncryptInit.3 b/src/lib/libcrypto/man/EVP_EncryptInit.3
index 7765be2ca6..382c0e2b06 100644
--- a/src/lib/libcrypto/man/EVP_EncryptInit.3
+++ b/src/lib/libcrypto/man/EVP_EncryptInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_EncryptInit.3,v 1.56 2024/12/20 01:54:03 schwarze Exp $ 1.\" $OpenBSD: EVP_EncryptInit.3,v 1.57 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800 2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
3.\" EVP_bf_cbc.pod EVP_cast5_cbc.pod EVP_idea_cbc.pod EVP_rc2_cbc.pod 3.\" EVP_bf_cbc.pod EVP_cast5_cbc.pod EVP_idea_cbc.pod EVP_rc2_cbc.pod
4.\" 7c6d372a Nov 20 13:20:01 2018 +0000 4.\" 7c6d372a Nov 20 13:20:01 2018 +0000
@@ -69,7 +69,7 @@
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE. 70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\" 71.\"
72.Dd $Mdocdate: December 20 2024 $ 72.Dd $Mdocdate: June 8 2025 $
73.Dt EVP_ENCRYPTINIT 3 73.Dt EVP_ENCRYPTINIT 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
@@ -115,6 +115,7 @@
115.Nm EVP_cast5_ofb 115.Nm EVP_cast5_ofb
116.Nd EVP cipher routines 116.Nd EVP cipher routines
117.Sh SYNOPSIS 117.Sh SYNOPSIS
118.Lb libcrypto
118.In openssl/evp.h 119.In openssl/evp.h
119.Ft EVP_CIPHER_CTX * 120.Ft EVP_CIPHER_CTX *
120.Fn EVP_CIPHER_CTX_new void 121.Fn EVP_CIPHER_CTX_new void
diff --git a/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3
index c8c148faf0..a16bba9bf8 100644
--- a/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3
+++ b/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_MD_CTX_ctrl.3,v 1.3 2024/03/05 17:21:40 tb Exp $ 1.\" $OpenBSD: EVP_MD_CTX_ctrl.3,v 1.5 2025/06/11 13:48:54 schwarze Exp $
2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod 2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod
3.\" 24a535ea Sep 22 13:14:20 2020 +0100 3.\" 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -69,7 +69,7 @@
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE. 70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\" 71.\"
72.Dd $Mdocdate: March 5 2024 $ 72.Dd $Mdocdate: June 11 2025 $
73.Dt EVP_MD_CTX_CTRL 3 73.Dt EVP_MD_CTX_CTRL 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
@@ -82,6 +82,7 @@
82.Nm EVP_MD_CTX_md_data 82.Nm EVP_MD_CTX_md_data
83.Nd configure EVP message digest contexts 83.Nd configure EVP message digest contexts
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/evp.h 86.In openssl/evp.h
86.Ft int 87.Ft int
87.Fo EVP_MD_CTX_ctrl 88.Fo EVP_MD_CTX_ctrl
@@ -154,7 +155,9 @@ when it is no longer needed.
154This 155This
155.Fa command 156.Fa command
156is used by 157is used by
157.Xr SMIME_write_ASN1 3 158.Xr SMIME_write_CMS 3
159and
160.Xr SMIME_write_PKCS7 3
158when creating S/MIME multipart/signed messages as specified in RFC 3851. 161when creating S/MIME multipart/signed messages as specified in RFC 3851.
159.Pp 162.Pp
160.Fn EVP_MD_CTX_set_flags 163.Fn EVP_MD_CTX_set_flags
diff --git a/src/lib/libcrypto/man/EVP_MD_nid.3 b/src/lib/libcrypto/man/EVP_MD_nid.3
index 15806091de..384c043149 100644
--- a/src/lib/libcrypto/man/EVP_MD_nid.3
+++ b/src/lib/libcrypto/man/EVP_MD_nid.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_MD_nid.3,v 1.4 2024/03/05 17:21:40 tb Exp $ 1.\" $OpenBSD: EVP_MD_nid.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod 2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod
3.\" 24a535ea Sep 22 13:14:20 2020 +0100 3.\" 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: March 5 2024 $ 71.Dd $Mdocdate: June 8 2025 $
72.Dt EVP_MD_NID 3 72.Dt EVP_MD_NID 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -84,6 +84,7 @@
84.Nm EVP_MD_pkey_type 84.Nm EVP_MD_pkey_type
85.Nd inspect EVP_MD objects 85.Nd inspect EVP_MD objects
86.Sh SYNOPSIS 86.Sh SYNOPSIS
87.Lb libcrypto
87.In openssl/evp.h 88.In openssl/evp.h
88.Ft int 89.Ft int
89.Fo EVP_MD_nid 90.Fo EVP_MD_nid
diff --git a/src/lib/libcrypto/man/EVP_OpenInit.3 b/src/lib/libcrypto/man/EVP_OpenInit.3
index fbd0e75571..8cdcbda0e9 100644
--- a/src/lib/libcrypto/man/EVP_OpenInit.3
+++ b/src/lib/libcrypto/man/EVP_OpenInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_OpenInit.3,v 1.9 2023/11/16 20:27:43 schwarze Exp $ 1.\" $OpenBSD: EVP_OpenInit.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 16 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EVP_OPENINIT 3 52.Dt EVP_OPENINIT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_OpenFinal 57.Nm EVP_OpenFinal
58.Nd EVP envelope decryption 58.Nd EVP envelope decryption
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft int 62.Ft int
62.Fo EVP_OpenInit 63.Fo EVP_OpenInit
diff --git a/src/lib/libcrypto/man/EVP_PKCS82PKEY.3 b/src/lib/libcrypto/man/EVP_PKCS82PKEY.3
index 30a43b8dca..a8b7d86808 100644
--- a/src/lib/libcrypto/man/EVP_PKCS82PKEY.3
+++ b/src/lib/libcrypto/man/EVP_PKCS82PKEY.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKCS82PKEY.3,v 1.3 2024/03/05 19:21:31 tb Exp $ 1.\" $OpenBSD: EVP_PKCS82PKEY.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 5 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt EVP_PKCS82PKEY 3 18.Dt EVP_PKCS82PKEY 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm EVP_PKEY2PKCS8 22.Nm EVP_PKEY2PKCS8
23.Nd convert between EVP_PKEY and PKCS#8 PrivateKeyInfo 23.Nd convert between EVP_PKEY and PKCS#8 PrivateKeyInfo
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509.h 26.In openssl/x509.h
26.Ft EVP_PKEY * 27.Ft EVP_PKEY *
27.Fn EVP_PKCS82PKEY "const PKCS8_PRIV_KEY_INFO *keyinfo" 28.Fn EVP_PKCS82PKEY "const PKCS8_PRIV_KEY_INFO *keyinfo"
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3
index 41c5a9ab9a..db65f132bb 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_CTX_ctrl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_CTX_ctrl.3,v 1.29 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: EVP_PKEY_CTX_ctrl.3,v 1.30 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" Parts were split out into RSA_pkey_ctx_ctrl(3). 4.\" Parts were split out into RSA_pkey_ctx_ctrl(3).
@@ -69,7 +69,7 @@
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE. 70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\" 71.\"
72.Dd $Mdocdate: April 17 2025 $ 72.Dd $Mdocdate: June 8 2025 $
73.Dt EVP_PKEY_CTX_CTRL 3 73.Dt EVP_PKEY_CTX_CTRL 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
@@ -97,6 +97,7 @@
97.Nm EVP_PKEY_CTX_get1_id_len 97.Nm EVP_PKEY_CTX_get1_id_len
98.Nd algorithm specific control operations 98.Nd algorithm specific control operations
99.Sh SYNOPSIS 99.Sh SYNOPSIS
100.Lb libcrypto
100.In openssl/evp.h 101.In openssl/evp.h
101.Ft int 102.Ft int
102.Fo EVP_PKEY_CTX_ctrl 103.Fo EVP_PKEY_CTX_ctrl
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3
index 2482c746d4..ce234337bb 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_CTX_get_operation.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_CTX_get_operation.3,v 1.3 2023/09/12 16:15:23 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_CTX_get_operation.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 12 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt EVP_PKEY_CTX_GET_OPERATION 3 18.Dt EVP_PKEY_CTX_GET_OPERATION 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm EVP_PKEY_CTX_get0_pkey 22.Nm EVP_PKEY_CTX_get0_pkey
23.Nd inspect EVP_PKEY_CTX objects 23.Nd inspect EVP_PKEY_CTX objects
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/evp.h 26.In openssl/evp.h
26.Ft int 27.Ft int
27.Fo EVP_PKEY_CTX_get_operation 28.Fo EVP_PKEY_CTX_get_operation
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_new.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_new.3
index e74bce9dfb..d0f514d5ea 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_new.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_CTX_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_CTX_new.3,v 1.16 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_CTX_new.3,v 1.17 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 6 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt EVP_PKEY_CTX_NEW 3 69.Dt EVP_PKEY_CTX_NEW 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -75,6 +75,7 @@
75.Nm EVP_PKEY_CTX_free 75.Nm EVP_PKEY_CTX_free
76.Nd public key algorithm context functions 76.Nd public key algorithm context functions
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/evp.h 79.In openssl/evp.h
79.Ft EVP_PKEY_CTX * 80.Ft EVP_PKEY_CTX *
80.Fo EVP_PKEY_CTX_new 81.Fo EVP_PKEY_CTX_new
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3
index 973ae95974..a63744097a 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_CTX_set_hkdf_md.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_CTX_set_hkdf_md.3,v 1.4 2024/07/10 07:57:37 tb Exp $ 1.\" $OpenBSD: EVP_PKEY_CTX_set_hkdf_md.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100 2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
3.\" 3.\"
4.\" This file was written by Alessandro Ghedini <alessandro@ghedini.me>, 4.\" This file was written by Alessandro Ghedini <alessandro@ghedini.me>,
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: July 10 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_PKEY_CTX_SET_HKDF_MD 3 53.Dt EVP_PKEY_CTX_SET_HKDF_MD 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -60,6 +60,7 @@
60.Nm EVP_PKEY_CTX_hkdf_mode 60.Nm EVP_PKEY_CTX_hkdf_mode
61.Nd HMAC-based Extract-and-Expand key derivation algorithm 61.Nd HMAC-based Extract-and-Expand key derivation algorithm
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/evp.h 64.In openssl/evp.h
64.In openssl/kdf.h 65.In openssl/kdf.h
65.Ft int 66.Ft int
diff --git a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3 b/src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3
index bdb1a208a2..57a85a78d9 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_CTX_set_tls1_prf_md.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_CTX_set_tls1_prf_md.3,v 1.3 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: EVP_PKEY_CTX_set_tls1_prf_md.3,v 1.4 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100 2.\" full merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
3.\" 3.\"
4.\" This file was written by Dr Stephen Henson <steve@openssl.org>, 4.\" This file was written by Dr Stephen Henson <steve@openssl.org>,
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 17 2025 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EVP_PKEY_CTX_SET_TLS1_PRF_MD 3 52.Dt EVP_PKEY_CTX_SET_TLS1_PRF_MD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_PKEY_CTX_add1_tls1_prf_seed 57.Nm EVP_PKEY_CTX_add1_tls1_prf_seed
58.Nd TLS PRF key derivation algorithm 58.Nd TLS PRF key derivation algorithm
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.In openssl/kdf.h 62.In openssl/kdf.h
62.Ft int 63.Ft int
diff --git a/src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 b/src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3
index f7810789b6..098a5565b2 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.10 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000 2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 6 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt EVP_PKEY_ASN1_GET_COUNT 3 69.Dt EVP_PKEY_ASN1_GET_COUNT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -77,6 +77,7 @@
77.Nm EVP_PKEY_asn1_get0_info 77.Nm EVP_PKEY_asn1_get0_info
78.Nd enumerate public key ASN.1 methods 78.Nd enumerate public key ASN.1 methods
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libcrypto
80.In openssl/evp.h 81.In openssl/evp.h
81.Ft int 82.Ft int
82.Fn EVP_PKEY_asn1_get_count void 83.Fn EVP_PKEY_asn1_get_count void
diff --git a/src/lib/libcrypto/man/EVP_PKEY_cmp.3 b/src/lib/libcrypto/man/EVP_PKEY_cmp.3
index c12843854d..bcd0152dc8 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_cmp.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_cmp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_cmp.3,v 1.15 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_cmp.3,v 1.16 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 6 2024 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt EVP_PKEY_CMP 3 71.Dt EVP_PKEY_CMP 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -81,6 +81,7 @@
81.\" resulting in incomplete output without the public key parameters. 81.\" resulting in incomplete output without the public key parameters.
82.Nd public key parameter and comparison functions 82.Nd public key parameter and comparison functions
83.Sh SYNOPSIS 83.Sh SYNOPSIS
84.Lb libcrypto
84.In openssl/evp.h 85.In openssl/evp.h
85.Ft int 86.Ft int
86.Fo EVP_PKEY_missing_parameters 87.Fo EVP_PKEY_missing_parameters
diff --git a/src/lib/libcrypto/man/EVP_PKEY_decrypt.3 b/src/lib/libcrypto/man/EVP_PKEY_decrypt.3
index c063847b10..abac0e6a2e 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_decrypt.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_decrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_decrypt.3,v 1.10 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_decrypt.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: December 6 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_PKEY_DECRYPT 3 53.Dt EVP_PKEY_DECRYPT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_PKEY_decrypt 57.Nm EVP_PKEY_decrypt
58.Nd decrypt using a public key algorithm 58.Nd decrypt using a public key algorithm
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft int 62.Ft int
62.Fo EVP_PKEY_decrypt_init 63.Fo EVP_PKEY_decrypt_init
diff --git a/src/lib/libcrypto/man/EVP_PKEY_derive.3 b/src/lib/libcrypto/man/EVP_PKEY_derive.3
index 47f467fea1..d02ef0e9e4 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_derive.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_derive.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_derive.3,v 1.12 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_derive.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: December 6 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt EVP_PKEY_DERIVE 3 70.Dt EVP_PKEY_DERIVE 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -76,6 +76,7 @@
76.Nm EVP_PKEY_derive 76.Nm EVP_PKEY_derive
77.Nd derive public key algorithm shared secret 77.Nd derive public key algorithm shared secret
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/evp.h 80.In openssl/evp.h
80.Ft int 81.Ft int
81.Fo EVP_PKEY_derive_init 82.Fo EVP_PKEY_derive_init
diff --git a/src/lib/libcrypto/man/EVP_PKEY_encrypt.3 b/src/lib/libcrypto/man/EVP_PKEY_encrypt.3
index c2e70cb31f..f32d411283 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_encrypt.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_encrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_encrypt.3,v 1.10 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_encrypt.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: December 6 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_PKEY_ENCRYPT 3 53.Dt EVP_PKEY_ENCRYPT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_PKEY_encrypt 57.Nm EVP_PKEY_encrypt
58.Nd encrypt using a public key algorithm 58.Nd encrypt using a public key algorithm
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft int 62.Ft int
62.Fo EVP_PKEY_encrypt_init 63.Fo EVP_PKEY_encrypt_init
diff --git a/src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3 b/src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3
index e9ff7c4609..5c5b07bd3c 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_get_default_digest_nid.3,v 1.10 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_get_default_digest_nid.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,13 +66,14 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: December 6 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt EVP_PKEY_GET_DEFAULT_DIGEST_NID 3 70.Dt EVP_PKEY_GET_DEFAULT_DIGEST_NID 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
73.Nm EVP_PKEY_get_default_digest_nid 73.Nm EVP_PKEY_get_default_digest_nid
74.Nd get default signature digest 74.Nd get default signature digest
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libcrypto
76.In openssl/evp.h 77.In openssl/evp.h
77.Ft int 78.Ft int
78.Fo EVP_PKEY_get_default_digest_nid 79.Fo EVP_PKEY_get_default_digest_nid
diff --git a/src/lib/libcrypto/man/EVP_PKEY_keygen.3 b/src/lib/libcrypto/man/EVP_PKEY_keygen.3
index e75859b486..3c000f8cd2 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_keygen.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_keygen.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_keygen.3,v 1.15 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_keygen.3,v 1.16 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: December 6 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt EVP_PKEY_KEYGEN 3 70.Dt EVP_PKEY_KEYGEN 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -85,6 +85,7 @@
85.Nm EVP_PKEY_CTX_get_data 85.Nm EVP_PKEY_CTX_get_data
86.Nd key and parameter generation functions 86.Nd key and parameter generation functions
87.Sh SYNOPSIS 87.Sh SYNOPSIS
88.Lb libcrypto
88.In openssl/evp.h 89.In openssl/evp.h
89.Ft int 90.Ft int
90.Fo EVP_PKEY_keygen_init 91.Fo EVP_PKEY_keygen_init
diff --git a/src/lib/libcrypto/man/EVP_PKEY_new.3 b/src/lib/libcrypto/man/EVP_PKEY_new.3
index 3b1ef029c3..7c13f625bc 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_new.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_new.3,v 1.26 2024/12/10 15:10:26 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_new.3,v 1.27 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 4dcfdfce May 27 11:50:05 2020 +0100 2.\" full merge up to: OpenSSL 4dcfdfce May 27 11:50:05 2020 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: December 10 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt EVP_PKEY_NEW 3 70.Dt EVP_PKEY_NEW 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -80,6 +80,7 @@
80.Nm EVP_PKEY_get_raw_public_key 80.Nm EVP_PKEY_get_raw_public_key
81.Nd public and private key allocation and raw key handling functions 81.Nd public and private key allocation and raw key handling functions
82.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
83.In openssl/evp.h 84.In openssl/evp.h
84.Ft EVP_PKEY * 85.Ft EVP_PKEY *
85.Fn EVP_PKEY_new void 86.Fn EVP_PKEY_new void
diff --git a/src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3 b/src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3
index d09af3a012..e4202fab67 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_new_CMAC_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_new_CMAC_key.3,v 1.1 2024/11/12 20:00:36 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_new_CMAC_key.3,v 1.2 2025/06/08 22:40:29 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 12 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt EVP_PKEY_NEW_CMAC_KEY 3 18.Dt EVP_PKEY_NEW_CMAC_KEY 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm EVP_PKEY_new_CMAC_key 21.Nm EVP_PKEY_new_CMAC_key
22.Nd CMAC in the EVP framework 22.Nd CMAC in the EVP framework
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/evp.h 25.In openssl/evp.h
25.Ft EVP_PKEY * 26.Ft EVP_PKEY *
26.Fo EVP_PKEY_new_CMAC_key 27.Fo EVP_PKEY_new_CMAC_key
diff --git a/src/lib/libcrypto/man/EVP_PKEY_print_private.3 b/src/lib/libcrypto/man/EVP_PKEY_print_private.3
index a4b51a4bbb..877385d15b 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_print_private.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_print_private.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_print_private.3,v 1.8 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_print_private.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 6 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EVP_PKEY_PRINT_PRIVATE 3 52.Dt EVP_PKEY_PRINT_PRIVATE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_PKEY_print_params 57.Nm EVP_PKEY_print_params
58.Nd public key algorithm printing routines 58.Nd public key algorithm printing routines
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft int 62.Ft int
62.Fo EVP_PKEY_print_public 63.Fo EVP_PKEY_print_public
diff --git a/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 b/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3
index 39404f5286..5e17894bea 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_set1_RSA.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.24 2024/12/09 11:25:25 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.27 2025/07/02 06:40:28 tb Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 9 2024 $ 68.Dd $Mdocdate: July 2 2025 $
69.Dt EVP_PKEY_SET1_RSA 3 69.Dt EVP_PKEY_SET1_RSA 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -103,6 +103,7 @@
103.\" EVP_PKT_ENC EVP_PKT_EXCH EVP_PKT_EXP EVP_PKT_SIGN 103.\" EVP_PKT_ENC EVP_PKT_EXCH EVP_PKT_EXP EVP_PKT_SIGN
104.Nd EVP_PKEY assignment functions 104.Nd EVP_PKEY assignment functions
105.Sh SYNOPSIS 105.Sh SYNOPSIS
106.Lb libcrypto
106.In openssl/evp.h 107.In openssl/evp.h
107.Ft int 108.Ft int
108.Fo EVP_PKEY_set1_RSA 109.Fo EVP_PKEY_set1_RSA
@@ -126,35 +127,35 @@
126.Fc 127.Fc
127.Ft RSA * 128.Ft RSA *
128.Fo EVP_PKEY_get1_RSA 129.Fo EVP_PKEY_get1_RSA
129.Fa "EVP_PKEY *pkey" 130.Fa "const EVP_PKEY *pkey"
130.Fc 131.Fc
131.Ft DSA * 132.Ft DSA *
132.Fo EVP_PKEY_get1_DSA 133.Fo EVP_PKEY_get1_DSA
133.Fa "EVP_PKEY *pkey" 134.Fa "const EVP_PKEY *pkey"
134.Fc 135.Fc
135.Ft DH * 136.Ft DH *
136.Fo EVP_PKEY_get1_DH 137.Fo EVP_PKEY_get1_DH
137.Fa "EVP_PKEY *pkey" 138.Fa "const EVP_PKEY *pkey"
138.Fc 139.Fc
139.Ft EC_KEY * 140.Ft EC_KEY *
140.Fo EVP_PKEY_get1_EC_KEY 141.Fo EVP_PKEY_get1_EC_KEY
141.Fa "EVP_PKEY *pkey" 142.Fa "const EVP_PKEY *pkey"
142.Fc 143.Fc
143.Ft RSA * 144.Ft RSA *
144.Fo EVP_PKEY_get0_RSA 145.Fo EVP_PKEY_get0_RSA
145.Fa "EVP_PKEY *pkey" 146.Fa "const EVP_PKEY *pkey"
146.Fc 147.Fc
147.Ft DSA * 148.Ft DSA *
148.Fo EVP_PKEY_get0_DSA 149.Fo EVP_PKEY_get0_DSA
149.Fa "EVP_PKEY *pkey" 150.Fa "const EVP_PKEY *pkey"
150.Fc 151.Fc
151.Ft DH * 152.Ft DH *
152.Fo EVP_PKEY_get0_DH 153.Fo EVP_PKEY_get0_DH
153.Fa "EVP_PKEY *pkey" 154.Fa "const EVP_PKEY *pkey"
154.Fc 155.Fc
155.Ft EC_KEY * 156.Ft EC_KEY *
156.Fo EVP_PKEY_get0_EC_KEY 157.Fo EVP_PKEY_get0_EC_KEY
157.Fa "EVP_PKEY *pkey" 158.Fa "const EVP_PKEY *pkey"
158.Fc 159.Fc
159.Ft const unsigned char * 160.Ft const unsigned char *
160.Fo EVP_PKEY_get0_hmac 161.Fo EVP_PKEY_get0_hmac
@@ -193,11 +194,11 @@
193.Fc 194.Fc
194.Ft int 195.Ft int
195.Fo EVP_PKEY_base_id 196.Fo EVP_PKEY_base_id
196.Fa "EVP_PKEY *pkey" 197.Fa "const EVP_PKEY *pkey"
197.Fc 198.Fc
198.Ft int 199.Ft int
199.Fo EVP_PKEY_id 200.Fo EVP_PKEY_id
200.Fa "EVP_PKEY *pkey" 201.Fa "const EVP_PKEY *pkey"
201.Fc 202.Fc
202.Ft int 203.Ft int
203.Fo EVP_PKEY_type 204.Fo EVP_PKEY_type
diff --git a/src/lib/libcrypto/man/EVP_PKEY_sign.3 b/src/lib/libcrypto/man/EVP_PKEY_sign.3
index afd9177596..58d7e34cb6 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_sign.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_sign.3,v 1.10 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: EVP_PKEY_sign.3,v 1.11 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 17 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_PKEY_SIGN 3 53.Dt EVP_PKEY_SIGN 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_PKEY_sign 57.Nm EVP_PKEY_sign
58.Nd sign using a public key algorithm 58.Nd sign using a public key algorithm
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft int 62.Ft int
62.Fo EVP_PKEY_sign_init 63.Fo EVP_PKEY_sign_init
diff --git a/src/lib/libcrypto/man/EVP_PKEY_size.3 b/src/lib/libcrypto/man/EVP_PKEY_size.3
index cd25eec9c2..dc53de1268 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_size.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_size.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_size.3,v 1.4 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: EVP_PKEY_size.3,v 1.5 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL eed9d03b Jan 8 11:04:15 2020 +0100 2.\" full merge up to: OpenSSL eed9d03b Jan 8 11:04:15 2020 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 6 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt EVP_PKEY_SIZE 3 69.Dt EVP_PKEY_SIZE 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -74,6 +74,7 @@
74.Nm EVP_PKEY_security_bits 74.Nm EVP_PKEY_security_bits
75.Nd EVP_PKEY information functions 75.Nd EVP_PKEY information functions
76.Sh SYNOPSIS 76.Sh SYNOPSIS
77.Lb libcrypto
77.In openssl/evp.h 78.In openssl/evp.h
78.Ft int 79.Ft int
79.Fo EVP_PKEY_size 80.Fo EVP_PKEY_size
diff --git a/src/lib/libcrypto/man/EVP_PKEY_verify.3 b/src/lib/libcrypto/man/EVP_PKEY_verify.3
index c297e9669a..1a1d19a552 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_verify.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_verify.3,v 1.9 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: EVP_PKEY_verify.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 17 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_PKEY_VERIFY 3 53.Dt EVP_PKEY_VERIFY 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_PKEY_verify 57.Nm EVP_PKEY_verify
58.Nd signature verification using a public key algorithm 58.Nd signature verification using a public key algorithm
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft int 62.Ft int
62.Fo EVP_PKEY_verify_init 63.Fo EVP_PKEY_verify_init
diff --git a/src/lib/libcrypto/man/EVP_PKEY_verify_recover.3 b/src/lib/libcrypto/man/EVP_PKEY_verify_recover.3
index 2e863f35b4..840307b41e 100644
--- a/src/lib/libcrypto/man/EVP_PKEY_verify_recover.3
+++ b/src/lib/libcrypto/man/EVP_PKEY_verify_recover.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_PKEY_verify_recover.3,v 1.11 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: EVP_PKEY_verify_recover.3,v 1.12 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 2.\" full merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 17 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_PKEY_VERIFY_RECOVER 3 53.Dt EVP_PKEY_VERIFY_RECOVER 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_PKEY_verify_recover 57.Nm EVP_PKEY_verify_recover
58.Nd recover signature using a public key algorithm 58.Nd recover signature using a public key algorithm
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft int 62.Ft int
62.Fo EVP_PKEY_verify_recover_init 63.Fo EVP_PKEY_verify_recover_init
diff --git a/src/lib/libcrypto/man/EVP_SealInit.3 b/src/lib/libcrypto/man/EVP_SealInit.3
index da53535274..f211702ba6 100644
--- a/src/lib/libcrypto/man/EVP_SealInit.3
+++ b/src/lib/libcrypto/man/EVP_SealInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_SealInit.3,v 1.9 2023/11/16 20:27:43 schwarze Exp $ 1.\" $OpenBSD: EVP_SealInit.3,v 1.10 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: November 16 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_SEALINIT 3 53.Dt EVP_SEALINIT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -58,6 +58,7 @@
58.Nm EVP_SealFinal 58.Nm EVP_SealFinal
59.Nd EVP envelope encryption 59.Nd EVP envelope encryption
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/evp.h 62.In openssl/evp.h
62.Ft int 63.Ft int
63.Fo EVP_SealInit 64.Fo EVP_SealInit
diff --git a/src/lib/libcrypto/man/EVP_SignInit.3 b/src/lib/libcrypto/man/EVP_SignInit.3
index 8158b21dbf..d3964abd41 100644
--- a/src/lib/libcrypto/man/EVP_SignInit.3
+++ b/src/lib/libcrypto/man/EVP_SignInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_SignInit.3,v 1.21 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: EVP_SignInit.3,v 1.22 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200 2.\" full merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: December 6 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_SIGNINIT 3 53.Dt EVP_SIGNINIT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -59,6 +59,7 @@
59.Nm EVP_SignInit 59.Nm EVP_SignInit
60.Nd EVP signing functions 60.Nd EVP signing functions
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/evp.h 63.In openssl/evp.h
63.Ft int 64.Ft int
64.Fo EVP_SignInit_ex 65.Fo EVP_SignInit_ex
diff --git a/src/lib/libcrypto/man/EVP_VerifyInit.3 b/src/lib/libcrypto/man/EVP_VerifyInit.3
index 0baadfb9fb..9bf1f1e163 100644
--- a/src/lib/libcrypto/man/EVP_VerifyInit.3
+++ b/src/lib/libcrypto/man/EVP_VerifyInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_VerifyInit.3,v 1.13 2024/11/08 22:23:35 schwarze Exp $ 1.\" $OpenBSD: EVP_VerifyInit.3,v 1.14 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: November 8 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt EVP_VERIFYINIT 3 53.Dt EVP_VERIFYINIT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -59,6 +59,7 @@
59.Nm EVP_VerifyInit 59.Nm EVP_VerifyInit
60.Nd EVP signature verification functions 60.Nd EVP signature verification functions
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/evp.h 63.In openssl/evp.h
63.Ft int 64.Ft int
64.Fo EVP_VerifyInit_ex 65.Fo EVP_VerifyInit_ex
diff --git a/src/lib/libcrypto/man/EVP_aes_128_cbc.3 b/src/lib/libcrypto/man/EVP_aes_128_cbc.3
index 46e3ef0bdc..72f654b73d 100644
--- a/src/lib/libcrypto/man/EVP_aes_128_cbc.3
+++ b/src/lib/libcrypto/man/EVP_aes_128_cbc.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_aes_128_cbc.3,v 1.8 2024/12/20 01:54:03 schwarze Exp $ 1.\" $OpenBSD: EVP_aes_128_cbc.3,v 1.9 2025/06/08 22:40:29 schwarze Exp $
2.\" selective merge up to: OpenSSL 7c6d372a Nov 20 13:20:01 2018 +0000 2.\" selective merge up to: OpenSSL 7c6d372a Nov 20 13:20:01 2018 +0000
3.\" 3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com> 4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 20 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EVP_AES_128_CBC 3 52.Dt EVP_AES_128_CBC 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -85,6 +85,7 @@
85.Nm EVP_aes_256_xts 85.Nm EVP_aes_256_xts
86.Nd EVP AES cipher 86.Nd EVP AES cipher
87.Sh SYNOPSIS 87.Sh SYNOPSIS
88.Lb libcrypto
88.In openssl/evp.h 89.In openssl/evp.h
89.Ft const EVP_CIPHER * 90.Ft const EVP_CIPHER *
90.Fn EVP_aes_128_cbc void 91.Fn EVP_aes_128_cbc void
diff --git a/src/lib/libcrypto/man/EVP_aes_128_ccm.3 b/src/lib/libcrypto/man/EVP_aes_128_ccm.3
index e9023a5b67..eaba95c936 100644
--- a/src/lib/libcrypto/man/EVP_aes_128_ccm.3
+++ b/src/lib/libcrypto/man/EVP_aes_128_ccm.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_aes_128_ccm.3,v 1.5 2024/12/29 12:27:28 schwarze Exp $ 1.\" $OpenBSD: EVP_aes_128_ccm.3,v 1.6 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100 3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\" OpenSSL EVP_aes.pod a1ec85c1 Apr 21 10:49:12 2020 +0100 4.\" OpenSSL EVP_aes.pod a1ec85c1 Apr 21 10:49:12 2020 +0100
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 29 2024 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt EVP_AES_128_CCM 3 71.Dt EVP_AES_128_CCM 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -76,6 +76,7 @@
76.Nm EVP_aes_256_ccm 76.Nm EVP_aes_256_ccm
77.Nd EVP AES cipher in Counter with CBC-MAC mode 77.Nd EVP AES cipher in Counter with CBC-MAC mode
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/evp.h 80.In openssl/evp.h
80.Ft const EVP_CIPHER * 81.Ft const EVP_CIPHER *
81.Fn EVP_aes_128_ccm void 82.Fn EVP_aes_128_ccm void
diff --git a/src/lib/libcrypto/man/EVP_aes_128_gcm.3 b/src/lib/libcrypto/man/EVP_aes_128_gcm.3
index 53c41ea162..fa4a88619a 100644
--- a/src/lib/libcrypto/man/EVP_aes_128_gcm.3
+++ b/src/lib/libcrypto/man/EVP_aes_128_gcm.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_aes_128_gcm.3,v 1.2 2024/12/29 12:27:28 schwarze Exp $ 1.\" $OpenBSD: EVP_aes_128_gcm.3,v 1.3 2025/06/08 22:40:29 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100 3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\" OpenSSL EVP_aes.pod a1ec85c1 Apr 21 10:49:12 2020 +0100 4.\" OpenSSL EVP_aes.pod a1ec85c1 Apr 21 10:49:12 2020 +0100
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 29 2024 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt EVP_AES_128_GCM 3 71.Dt EVP_AES_128_GCM 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -76,6 +76,7 @@
76.Nm EVP_aes_256_gcm 76.Nm EVP_aes_256_gcm
77.Nd EVP AES cipher in Galois Counter Mode 77.Nd EVP AES cipher in Galois Counter Mode
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/evp.h 80.In openssl/evp.h
80.Ft const EVP_CIPHER * 81.Ft const EVP_CIPHER *
81.Fn EVP_aes_128_gcm void 82.Fn EVP_aes_128_gcm void
diff --git a/src/lib/libcrypto/man/EVP_camellia_128_cbc.3 b/src/lib/libcrypto/man/EVP_camellia_128_cbc.3
index 6f15a85f7f..3ff5d5a0e0 100644
--- a/src/lib/libcrypto/man/EVP_camellia_128_cbc.3
+++ b/src/lib/libcrypto/man/EVP_camellia_128_cbc.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_camellia_128_cbc.3,v 1.3 2024/11/09 22:03:49 schwarze Exp $ 1.\" $OpenBSD: EVP_camellia_128_cbc.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" selective merge up to: OpenSSL 7c6d372a Nov 20 13:20:01 2018 +0000 2.\" selective merge up to: OpenSSL 7c6d372a Nov 20 13:20:01 2018 +0000
3.\" 3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com> 4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: November 9 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EVP_CAMELLIA_128_CBC 3 52.Dt EVP_CAMELLIA_128_CBC 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -75,6 +75,7 @@
75.Nm EVP_camellia_256_ofb 75.Nm EVP_camellia_256_ofb
76.Nd EVP Camellia cipher 76.Nd EVP Camellia cipher
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/evp.h 79.In openssl/evp.h
79.Ft const EVP_CIPHER * 80.Ft const EVP_CIPHER *
80.Fn EVP_camellia_128_cbc void 81.Fn EVP_camellia_128_cbc void
diff --git a/src/lib/libcrypto/man/EVP_chacha20.3 b/src/lib/libcrypto/man/EVP_chacha20.3
index 8fc79dbf2b..45584f3e86 100644
--- a/src/lib/libcrypto/man/EVP_chacha20.3
+++ b/src/lib/libcrypto/man/EVP_chacha20.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_chacha20.3,v 1.8 2024/12/09 11:55:52 schwarze Exp $ 1.\" $OpenBSD: EVP_chacha20.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200 2.\" full merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 9 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt EVP_CHACHA20 3 69.Dt EVP_CHACHA20 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -73,6 +73,7 @@
73.Nm EVP_chacha20_poly1305 73.Nm EVP_chacha20_poly1305
74.Nd ChaCha20 stream cipher for EVP 74.Nd ChaCha20 stream cipher for EVP
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libcrypto
76.In openssl/evp.h 77.In openssl/evp.h
77.Ft const EVP_CIPHER * 78.Ft const EVP_CIPHER *
78.Fn EVP_chacha20 void 79.Fn EVP_chacha20 void
diff --git a/src/lib/libcrypto/man/EVP_des_cbc.3 b/src/lib/libcrypto/man/EVP_des_cbc.3
index 7c8a08c7db..84ee9aaa61 100644
--- a/src/lib/libcrypto/man/EVP_des_cbc.3
+++ b/src/lib/libcrypto/man/EVP_des_cbc.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_des_cbc.3,v 1.2 2024/11/09 22:03:49 schwarze Exp $ 1.\" $OpenBSD: EVP_des_cbc.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL EVP_desx_cbc.pod 8fa4d95e Oct 21 11:59:09 2017 +0900 3.\" OpenSSL EVP_desx_cbc.pod 8fa4d95e Oct 21 11:59:09 2017 +0900
4.\" selective merge up to: 4.\" selective merge up to:
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: November 9 2024 $ 54.Dd $Mdocdate: June 8 2025 $
55.Dt EVP_DES_CBC 3 55.Dt EVP_DES_CBC 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -79,6 +79,7 @@
79.Nm EVP_desx_cbc 79.Nm EVP_desx_cbc
80.Nd EVP DES cipher 80.Nd EVP DES cipher
81.Sh SYNOPSIS 81.Sh SYNOPSIS
82.Lb libcrypto
82.In openssl/evp.h 83.In openssl/evp.h
83.Ft const EVP_CIPHER * 84.Ft const EVP_CIPHER *
84.Fn EVP_des_cbc void 85.Fn EVP_des_cbc void
diff --git a/src/lib/libcrypto/man/EVP_rc2_cbc.3 b/src/lib/libcrypto/man/EVP_rc2_cbc.3
index 38c8184260..9a3bc29304 100644
--- a/src/lib/libcrypto/man/EVP_rc2_cbc.3
+++ b/src/lib/libcrypto/man/EVP_rc2_cbc.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_rc2_cbc.3,v 1.1 2024/12/08 17:41:23 schwarze Exp $ 1.\" $OpenBSD: EVP_rc2_cbc.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 8 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt EVP_RC2_CBC 3 18.Dt EVP_RC2_CBC 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.Nm EVP_rc2_64_cbc 27.Nm EVP_rc2_64_cbc
28.Nd Rivest Cipher 2 in the EVP framework 28.Nd Rivest Cipher 2 in the EVP framework
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/evp.h 31.In openssl/evp.h
31.Ft const EVP_CIPHER * 32.Ft const EVP_CIPHER *
32.Fn EVP_rc2_cbc void 33.Fn EVP_rc2_cbc void
diff --git a/src/lib/libcrypto/man/EVP_rc4.3 b/src/lib/libcrypto/man/EVP_rc4.3
index fda041113c..40dd27e49f 100644
--- a/src/lib/libcrypto/man/EVP_rc4.3
+++ b/src/lib/libcrypto/man/EVP_rc4.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_rc4.3,v 1.1 2019/03/21 13:37:25 schwarze Exp $ 1.\" $OpenBSD: EVP_rc4.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 8fa4d95e Oct 21 11:59:09 2017 +0900 2.\" full merge up to: OpenSSL 8fa4d95e Oct 21 11:59:09 2017 +0900
3.\" 3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com> 4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 21 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EVP_RC4 3 52.Dt EVP_RC4 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm EVP_rc4_hmac_md5 57.Nm EVP_rc4_hmac_md5
58.Nd EVP RC4 stream cipher 58.Nd EVP RC4 stream cipher
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft const EVP_CIPHER * 62.Ft const EVP_CIPHER *
62.Fn EVP_rc4 void 63.Fn EVP_rc4 void
diff --git a/src/lib/libcrypto/man/EVP_sha1.3 b/src/lib/libcrypto/man/EVP_sha1.3
index b28c9f54c3..d1e336cc42 100644
--- a/src/lib/libcrypto/man/EVP_sha1.3
+++ b/src/lib/libcrypto/man/EVP_sha1.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_sha1.3,v 1.2 2024/03/05 17:21:40 tb Exp $ 1.\" $OpenBSD: EVP_sha1.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 5 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt EVP_SHA1 3 18.Dt EVP_SHA1 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm EVP_md4 24.Nm EVP_md4
25.Nd legacy message digest algorithms 25.Nd legacy message digest algorithms
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/evp.h 28.In openssl/evp.h
28.Ft const EVP_MD * 29.Ft const EVP_MD *
29.Fn EVP_sha1 void 30.Fn EVP_sha1 void
diff --git a/src/lib/libcrypto/man/EVP_sha3_224.3 b/src/lib/libcrypto/man/EVP_sha3_224.3
index 3c21ae1a09..19a9114885 100644
--- a/src/lib/libcrypto/man/EVP_sha3_224.3
+++ b/src/lib/libcrypto/man/EVP_sha3_224.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_sha3_224.3,v 1.3 2024/03/05 17:21:40 tb Exp $ 1.\" $OpenBSD: EVP_sha3_224.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" selective merge up to: OpenSSL bbda8ce9 Oct 31 15:43:01 2017 +0800 2.\" selective merge up to: OpenSSL bbda8ce9 Oct 31 15:43:01 2017 +0800
3.\" 3.\"
4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>. 4.\" This file was written by Ronald Tse <ronald.tse@ribose.com>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 5 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt EVP_SHA3_224 3 52.Dt EVP_SHA3_224 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm EVP_sha3_512 58.Nm EVP_sha3_512
59.Nd Secure Hash Algorithm 3 for EVP 59.Nd Secure Hash Algorithm 3 for EVP
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/evp.h 62.In openssl/evp.h
62.Ft const EVP_MD * 63.Ft const EVP_MD *
63.Fn EVP_sha3_224 void 64.Fn EVP_sha3_224 void
diff --git a/src/lib/libcrypto/man/EVP_sm3.3 b/src/lib/libcrypto/man/EVP_sm3.3
index aa6789f249..33621bef81 100644
--- a/src/lib/libcrypto/man/EVP_sm3.3
+++ b/src/lib/libcrypto/man/EVP_sm3.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_sm3.3,v 1.1 2019/08/25 17:08:20 schwarze Exp $ 1.\" $OpenBSD: EVP_sm3.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 21ebd2fc Aug 24 20:38:04 2018 +0800 2.\" full merge up to: OpenSSL 21ebd2fc Aug 24 20:38:04 2018 +0800
3.\" 3.\"
4.\" This file was written by Jack Lloyd <jack.lloyd@ribose.com> 4.\" This file was written by Jack Lloyd <jack.lloyd@ribose.com>
@@ -50,13 +50,14 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: August 25 2019 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt EVP_SM3 3 54.Dt EVP_SM3 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
57.Nm EVP_sm3 57.Nm EVP_sm3
58.Nd SM3 hash function for EVP 58.Nd SM3 hash function for EVP
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/evp.h 61.In openssl/evp.h
61.Ft const EVP_MD * 62.Ft const EVP_MD *
62.Fn EVP_sm3 void 63.Fn EVP_sm3 void
diff --git a/src/lib/libcrypto/man/EVP_sm4_cbc.3 b/src/lib/libcrypto/man/EVP_sm4_cbc.3
index 0605a52faa..eba31afff3 100644
--- a/src/lib/libcrypto/man/EVP_sm4_cbc.3
+++ b/src/lib/libcrypto/man/EVP_sm4_cbc.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_sm4_cbc.3,v 1.2 2023/11/16 20:27:43 schwarze Exp $ 1.\" $OpenBSD: EVP_sm4_cbc.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 87103969 Oct 1 14:11:57 2018 -0700 2.\" full merge up to: OpenSSL 87103969 Oct 1 14:11:57 2018 -0700
3.\" 3.\"
4.\" Copyright (c) 2017 Ribose Inc 4.\" Copyright (c) 2017 Ribose Inc
@@ -18,7 +18,7 @@
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\" 20.\"
21.Dd $Mdocdate: November 16 2023 $ 21.Dd $Mdocdate: June 8 2025 $
22.Dt EVP_SM4_CBC 3 22.Dt EVP_SM4_CBC 3
23.Os 23.Os
24.Sh NAME 24.Sh NAME
@@ -30,6 +30,7 @@
30.Nm EVP_sm4_ctr 30.Nm EVP_sm4_ctr
31.Nd EVP SM4 cipher 31.Nd EVP SM4 cipher
32.Sh SYNOPSIS 32.Sh SYNOPSIS
33.Lb libcrypto
33.In openssl/evp.h 34.In openssl/evp.h
34.Ft const EVP_CIPHER * 35.Ft const EVP_CIPHER *
35.Fn EVP_sm4_cbc void 36.Fn EVP_sm4_cbc void
diff --git a/src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.3 b/src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.3
index 3d1ed17ff3..3258c9793d 100644
--- a/src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.3
+++ b/src/lib/libcrypto/man/EXTENDED_KEY_USAGE_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EXTENDED_KEY_USAGE_new.3,v 1.6 2021/10/27 11:24:47 schwarze Exp $ 1.\" $OpenBSD: EXTENDED_KEY_USAGE_new.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 27 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt EXTENDED_KEY_USAGE_NEW 3 18.Dt EXTENDED_KEY_USAGE_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm EXTENDED_KEY_USAGE_free 22.Nm EXTENDED_KEY_USAGE_free
23.Nd X.509 key usage restrictions 23.Nd X.509 key usage restrictions
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft EXTENDED_KEY_USAGE 27.Ft EXTENDED_KEY_USAGE
27.Fn EXTENDED_KEY_USAGE_new void 28.Fn EXTENDED_KEY_USAGE_new void
diff --git a/src/lib/libcrypto/man/GENERAL_NAME_new.3 b/src/lib/libcrypto/man/GENERAL_NAME_new.3
index a6b7ee56da..84ad2edb3b 100644
--- a/src/lib/libcrypto/man/GENERAL_NAME_new.3
+++ b/src/lib/libcrypto/man/GENERAL_NAME_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: GENERAL_NAME_new.3,v 1.6 2019/06/06 01:06:58 schwarze Exp $ 1.\" $OpenBSD: GENERAL_NAME_new.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt GENERAL_NAME_NEW 3 18.Dt GENERAL_NAME_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.Nm OTHERNAME_free 28.Nm OTHERNAME_free
29.Nd names for use in X.509 extensions 29.Nd names for use in X.509 extensions
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/x509v3.h 32.In openssl/x509v3.h
32.Ft GENERAL_NAME * 33.Ft GENERAL_NAME *
33.Fn GENERAL_NAME_new void 34.Fn GENERAL_NAME_new void
diff --git a/src/lib/libcrypto/man/HMAC.3 b/src/lib/libcrypto/man/HMAC.3
index a515014fca..0b9e24a7bd 100644
--- a/src/lib/libcrypto/man/HMAC.3
+++ b/src/lib/libcrypto/man/HMAC.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: HMAC.3,v 1.23 2024/08/29 20:21:53 tb Exp $ 1.\" $OpenBSD: HMAC.3,v 1.24 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL crypto/hmac a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" full merge up to: OpenSSL crypto/hmac a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" selective merge up to: OpenSSL man3/HMAC b3696a55 Sep 2 09:35:50 2017 -0400 3.\" selective merge up to: OpenSSL man3/HMAC b3696a55 Sep 2 09:35:50 2017 -0400
4.\" 4.\"
@@ -52,7 +52,7 @@
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE. 53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\" 54.\"
55.Dd $Mdocdate: August 29 2024 $ 55.Dd $Mdocdate: June 8 2025 $
56.Dt HMAC 3 56.Dt HMAC 3
57.Os 57.Os
58.Sh NAME 58.Sh NAME
@@ -69,6 +69,7 @@
69.Nm HMAC_size 69.Nm HMAC_size
70.Nd HMAC message authentication code 70.Nd HMAC message authentication code
71.Sh SYNOPSIS 71.Sh SYNOPSIS
72.Lb libcrypto
72.In openssl/hmac.h 73.In openssl/hmac.h
73.Ft unsigned char * 74.Ft unsigned char *
74.Fo HMAC 75.Fo HMAC
diff --git a/src/lib/libcrypto/man/IPAddressRange_new.3 b/src/lib/libcrypto/man/IPAddressRange_new.3
index a812107cdf..79e3751b4e 100644
--- a/src/lib/libcrypto/man/IPAddressRange_new.3
+++ b/src/lib/libcrypto/man/IPAddressRange_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: IPAddressRange_new.3,v 1.9 2023/10/03 09:58:06 tb Exp $ 1.\" $OpenBSD: IPAddressRange_new.3,v 1.11 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 3 2023 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt IPADDRESSRANGE_NEW 3 18.Dt IPADDRESSRANGE_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -36,8 +36,9 @@
36.Nm i2d_IPAddressFamily 36.Nm i2d_IPAddressFamily
37.Nd RFC 3779 IP address prefixes and ranges 37.Nd RFC 3779 IP address prefixes and ranges
38.Sh SYNOPSIS 38.Sh SYNOPSIS
39.Lb libcrypto
39.In openssl/x509v3.h 40.In openssl/x509v3.h
40.Ft "IPAddressRange *" 41.Ft IPAddressRange *
41.Fn IPAddressRange_new void 42.Fn IPAddressRange_new void
42.Ft void 43.Ft void
43.Fn IPAddressRange_free "IPAddressRange *range" 44.Fn IPAddressRange_free "IPAddressRange *range"
@@ -52,7 +53,7 @@
52.Fa "IPAddressRange *range" 53.Fa "IPAddressRange *range"
53.Fa "unsigned char **der_out" 54.Fa "unsigned char **der_out"
54.Fc 55.Fc
55.Ft "IPAddressOrRange *" 56.Ft IPAddressOrRange *
56.Fn IPAddressOrRange_new void 57.Fn IPAddressOrRange_new void
57.Ft void 58.Ft void
58.Fn IPAddressOrRange_free "IPAddressOrRange *aor" 59.Fn IPAddressOrRange_free "IPAddressOrRange *aor"
@@ -67,7 +68,7 @@
67.Fa "IPAddressOrRange *aor" 68.Fa "IPAddressOrRange *aor"
68.Fa "unsigned char **der_out" 69.Fa "unsigned char **der_out"
69.Fc 70.Fc
70.Ft "IPAddressChoice *" 71.Ft IPAddressChoice *
71.Fn IPAddressChoice_new void 72.Fn IPAddressChoice_new void
72.Ft void 73.Ft void
73.Fn IPAddressChoice_free "IPAddressChoice *ac" 74.Fn IPAddressChoice_free "IPAddressChoice *ac"
@@ -82,7 +83,7 @@
82.Fa "IPAddressChoice *ac" 83.Fa "IPAddressChoice *ac"
83.Fa "unsigned char **der_out" 84.Fa "unsigned char **der_out"
84.Fc 85.Fc
85.Ft "IPAddressFamily *" 86.Ft IPAddressFamily *
86.Fn IPAddressFamily_new void 87.Fn IPAddressFamily_new void
87.Ft void 88.Ft void
88.Fn IPAddressFamily_free "IPAddressFamily *af" 89.Fn IPAddressFamily_free "IPAddressFamily *af"
diff --git a/src/lib/libcrypto/man/MD5.3 b/src/lib/libcrypto/man/MD5.3
index 01e715f406..c9c89c33af 100644
--- a/src/lib/libcrypto/man/MD5.3
+++ b/src/lib/libcrypto/man/MD5.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: MD5.3,v 1.9 2024/05/26 09:54:16 tb Exp $ 1.\" $OpenBSD: MD5.3,v 1.10 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: May 26 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt MD5 3 53.Dt MD5 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -63,6 +63,7 @@
63.Nm MD5_Final 63.Nm MD5_Final
64.Nd MD4 and MD5 hash functions 64.Nd MD4 and MD5 hash functions
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libcrypto
66.In openssl/md4.h 67.In openssl/md4.h
67.Ft unsigned char * 68.Ft unsigned char *
68.Fo MD4 69.Fo MD4
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index b8dfe86d49..aea939dc2b 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.308 2025/04/25 19:57:12 tb Exp $ 1# $OpenBSD: Makefile,v 1.312 2025/07/17 10:31:50 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -216,7 +216,6 @@ MAN= \
216 IPAddressRange_new.3 \ 216 IPAddressRange_new.3 \
217 MD5.3 \ 217 MD5.3 \
218 NAME_CONSTRAINTS_new.3 \ 218 NAME_CONSTRAINTS_new.3 \
219 OBJ_NAME_add.3 \
220 OBJ_create.3 \ 219 OBJ_create.3 \
221 OBJ_find_sigid_algs.3 \ 220 OBJ_find_sigid_algs.3 \
222 OBJ_nid2obj.3 \ 221 OBJ_nid2obj.3 \
@@ -232,12 +231,11 @@ MAN= \
232 OPENSSL_cleanse.3 \ 231 OPENSSL_cleanse.3 \
233 OPENSSL_config.3 \ 232 OPENSSL_config.3 \
234 OPENSSL_init_crypto.3 \ 233 OPENSSL_init_crypto.3 \
235 OPENSSL_load_builtin_modules.3 \
236 OPENSSL_malloc.3 \ 234 OPENSSL_malloc.3 \
237 OPENSSL_sk_new.3 \ 235 OPENSSL_sk_new.3 \
238 OpenSSL_add_all_algorithms.3 \ 236 OpenSSL_add_all_algorithms.3 \
239 PEM_ASN1_read.3 \ 237 PEM_ASN1_read.3 \
240 PEM_X509_INFO_read.3 \ 238 PEM_X509_INFO_read_bio.3 \
241 PEM_bytes_read_bio.3 \ 239 PEM_bytes_read_bio.3 \
242 PEM_read.3 \ 240 PEM_read.3 \
243 PEM_read_bio_PrivateKey.3 \ 241 PEM_read_bio_PrivateKey.3 \
@@ -293,11 +291,9 @@ MAN= \
293 RSA_size.3 \ 291 RSA_size.3 \
294 SHA1.3 \ 292 SHA1.3 \
295 SMIME_crlf_copy.3 \ 293 SMIME_crlf_copy.3 \
296 SMIME_read_ASN1.3 \
297 SMIME_read_CMS.3 \ 294 SMIME_read_CMS.3 \
298 SMIME_read_PKCS7.3 \ 295 SMIME_read_PKCS7.3 \
299 SMIME_text.3 \ 296 SMIME_text.3 \
300 SMIME_write_ASN1.3 \
301 SMIME_write_CMS.3 \ 297 SMIME_write_CMS.3 \
302 SMIME_write_PKCS7.3 \ 298 SMIME_write_PKCS7.3 \
303 STACK_OF.3 \ 299 STACK_OF.3 \
@@ -330,7 +326,6 @@ MAN= \
330 X509_NAME_new.3 \ 326 X509_NAME_new.3 \
331 X509_NAME_print_ex.3 \ 327 X509_NAME_print_ex.3 \
332 X509_OBJECT_get0_X509.3 \ 328 X509_OBJECT_get0_X509.3 \
333 X509_PKEY_new.3 \
334 X509_PUBKEY_new.3 \ 329 X509_PUBKEY_new.3 \
335 X509_PURPOSE_set.3 \ 330 X509_PURPOSE_set.3 \
336 X509_REQ_add1_attr.3 \ 331 X509_REQ_add1_attr.3 \
diff --git a/src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3 b/src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3
index fec3aba7f7..7d39754858 100644
--- a/src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3
+++ b/src/lib/libcrypto/man/NAME_CONSTRAINTS_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: NAME_CONSTRAINTS_new.3,v 1.4 2020/09/17 08:50:05 schwarze Exp $ 1.\" $OpenBSD: NAME_CONSTRAINTS_new.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 17 2020 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt NAME_CONSTRAINTS_NEW 3 18.Dt NAME_CONSTRAINTS_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.\" We probably need to deprecate it thoughtfully. 27.\" We probably need to deprecate it thoughtfully.
28.Nd X.509 CA name constraints extension 28.Nd X.509 CA name constraints extension
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/x509v3.h 31.In openssl/x509v3.h
31.Ft NAME_CONSTRAINTS * 32.Ft NAME_CONSTRAINTS *
32.Fn NAME_CONSTRAINTS_new void 33.Fn NAME_CONSTRAINTS_new void
diff --git a/src/lib/libcrypto/man/OBJ_NAME_add.3 b/src/lib/libcrypto/man/OBJ_NAME_add.3
deleted file mode 100644
index 0b46010c49..0000000000
--- a/src/lib/libcrypto/man/OBJ_NAME_add.3
+++ /dev/null
@@ -1,307 +0,0 @@
1.\" $OpenBSD: OBJ_NAME_add.3,v 1.6 2024/01/31 08:02:53 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: January 31 2024 $
18.Dt OBJ_NAME_ADD 3
19.Os
20.Sh NAME
21.Nm OBJ_NAME_add ,
22.Nm OBJ_NAME_remove ,
23.Nm OBJ_NAME_get ,
24.Nm OBJ_NAME_new_index ,
25.Nm OBJ_NAME_init ,
26.Nm OBJ_NAME_cleanup
27.Nd global associative array
28.Sh SYNOPSIS
29.In openssl/objects.h
30.Ft int
31.Fo OBJ_NAME_add
32.Fa "const char *name"
33.Fa "int type"
34.Fa "const char *value"
35.Fc
36.Ft int
37.Fo OBJ_NAME_remove
38.Fa "const char *name"
39.Fa "int type"
40.Fc
41.Ft const char *
42.Fo OBJ_NAME_get
43.Fa "const char *name"
44.Fa "int type"
45.Fc
46.Ft int
47.Fo OBJ_NAME_new_index
48.Fa "unsigned long (*hash_func)(const char *name)"
49.Fa "int (*cmp_func)(const char *name1, const char *name2)"
50.Fa "void (*free_func)(const char *name, int type, const char *value)"
51.Fc
52.Ft int
53.Fn OBJ_NAME_init void
54.Ft void
55.Fn OBJ_NAME_cleanup "int type"
56.Bd -literal
57typedef struct {
58 int type;
59 int alias;
60 const char *name;
61 const char *data;
62} OBJ_NAME;
63.Ed
64.Sh DESCRIPTION
65These functions implement a single, static associative array
66with the following properties:
67.Bl -bullet
68.It
69The keys are ordered pairs consisting of a NUL-terminated string
70.Pq called the Fa name
71and an
72.Vt int
73number
74.Pq called the Fa type .
75Two types are predefined and used internally by the library:
76.Dv OBJ_NAME_TYPE_MD_METH
77and
78.Dv OBJ_NAME_TYPE_CIPHER_METH .
79Two additional types are predefined but not used internally:
80.Dv OBJ_NAME_TYPE_PKEY_METH
81and
82.Dv OBJ_NAME_TYPE_COMP_METH .
83All predefined types are greater than
84.Dv OBJ_NAME_TYPE_UNDEF
85and smaller than
86.Dv OBJ_NAME_TYPE_NUM .
87.It
88The values are pointers.
89Formally, they are of the type
90.Vt const char * ,
91but in practice, pointers of other types, for example
92.Vt EVP_CIPHER *
93or
94.Vt EVP_MD * ,
95are often stored as values
96and cast back to the correct type on retrieval.
97.It
98The array supports type-specific aliases for names.
99.El
100.Pp
101.Fn OBJ_NAME_add
102removes the key-value pair or alias with the key
103.Pq Fa name , type
104in the same way as
105.Fn OBJ_NAME_remove
106and inserts a key-value pair with the specified
107.Fa name ,
108.Fa type ,
109and
110.Fa value .
111If the bit
112.Dv OBJ_NAME_ALIAS
113is set in the
114.Fa type
115argument, that bit is cleared before using the
116.Fa type
117and the key
118.Pq Fa name , type
119becomes an alias for the key
120.Pq Fa value , type
121instead of setting a value.
122It is not checked whether the key
123.Pq Fa value , type
124already exists.
125Consequently, it is possible to define an alias
126before setting the associated value.
127.Pp
128.Fn OBJ_NAME_remove
129removes the key-value pair or alias with the key
130.Pq Fa name , type
131from the array, if it exists.
132Otherwise, it has no effect.
133If the bit
134.Dv OBJ_NAME_ALIAS
135is set in the
136.Fa type
137argument, it is ignored and cleared before using the
138.Fa type .
139If the
140.Fa type
141is an application-defined type added with
142.Fn OBJ_NAME_new_index
143and the
144.Fa free_func
145associated with the
146.Fa type
147is not a
148.Dv NULL
149pointer, it is called with the
150.Fa name ,
151.Fa type ,
152and
153.Fa value
154of the key-value pair being removed or with the
155.Fa name ,
156.Fa type ,
157and alias target name of the alias being removed.
158In typical usage, this function might free the
159.Fa name ,
160and it might free the
161.Fa value
162in a type-specific way.
163.Pp
164.Fn OBJ_NAME_get
165looks up the key
166.Pq Fa name , type ,
167recursively resolving up to ten aliases if needed.
168If the bit
169.Dv OBJ_NAME_ALIAS
170is set in the
171.Fa type
172argument, it is cleared before using the
173.Fa type ,
174processing of aliases is disabled, and if
175.Pq Fa name , type
176is an alias, the target name of the alias is returned instead of a value.
177.Pp
178.Fn OBJ_NAME_new_index
179assigns the smallest unassigned positive integer number
180to represent a new, application-defined
181.Fa type .
182The three function pointers will be used, respectively,
183to hash a name for this type, to compare two names for this type,
184and to free the contents of a key-value pair holding the given
185.Fa name ,
186.Fa type ,
187and
188.Fa value .
189If the
190.Fa hash_func
191argument is a
192.Dv NULL
193pointer,
194.Xr lh_strhash 3
195is used instead.
196If the
197.Fa cmp_func
198argument is a
199.Dv NULL
200pointer,
201.Xr strcmp 3
202is used instead.
203If the
204.Fa free_func
205argument is a
206.Dv NULL
207pointer, the
208.Fa name
209and
210.Fa value
211pointers contained in the key-value pair are not freed,
212only the structure representing the pair itself is.
213This default behaviour is also used for the built-in types.
214.Pp
215.Fn OBJ_NAME_init
216initializes the array.
217After initialization, the array is empty.
218Calling
219.Fn OBJ_NAME_init
220when the array is already initialized has no effect.
221Application programs do not need to call this function because
222.Fn OBJ_NAME_add
223and
224.Fn OBJ_NAME_get
225automatically call it whenever needed.
226.Pp
227.Fn OBJ_NAME_cleanup
228removes all key-value pairs and aliases of the given
229.Fa type
230from the array by calling
231.Fn OBJ_NAME_remove
232on every such pair and alias.
233If the
234.Fa type
235argument is negative, it removes all key-value pairs and aliases
236of any type and also reverses all effects of
237.Fn OBJ_NAME_new_index
238and
239.Fn OBJ_NAME_init ,
240in particular resetting the list of types to the predefined types
241and releasing all memory reserved by these functions.
242.Pp
243The
244.Vt OBJ_NAME
245structure represents one key-value pair or one alias with the key
246.Pq Fa name , type .
247If the
248.Fa alias
249field is 0, the
250.Fa data
251field contains the value; otherwise, it contains the alias target name.
252.Sh RETURN VALUES
253.Fn OBJ_NAME_add
254and
255.Fn OBJ_NAME_init
256return 1 on success or 0 if memory allocation fails.
257.Pp
258.Fn OBJ_NAME_remove
259returns 1 if one key-value pair or alias was removed or 0 otherwise.
260.Pp
261.Fn OBJ_NAME_get
262returns the
263.Fa value
264associated with the key
265.Pq Fa name , type
266or
267.Dv NULL
268if
269.Fa name
270is
271.Dv NULL ,
272if the array does not contain a value for this key,
273or if more than ten aliases are encountered before finding a value.
274.Pp
275.Fn OBJ_NAME_new_index
276returns a positive integer greater than or equal to
277.Dv OBJ_NAME_TYPE_NUM
278representing the new type or 0 if memory allocation fails.
279.Sh SEE ALSO
280.Xr EVP_cleanup 3 ,
281.Xr EVP_get_cipherbyname 3 ,
282.Xr EVP_get_digestbyname 3 ,
283.Xr lh_new 3 ,
284.Xr OBJ_create 3 ,
285.Xr OBJ_nid2obj 3
286.Sh BUGS
287Calling
288.Fn OBJ_NAME_get
289with the bit
290.Dv OBJ_NAME_ALIAS
291is not very useful because there is no way to tell
292whether the returned pointer points to a value or to a name,
293short of calling the function again without setting the bit
294and comparing the two returned pointers.
295.Pp
296The
297.Fa free_func
298has no way to tell whether its
299.Fa value
300argument is indeed of the given
301.Fa type
302or whether it is merely the target name of an alias.
303Consequently, to use values of a type
304that requires more cleanup than merely calling
305.Xr free 3
306on it, instances of the type need to begin with a magic number or string
307that cannot occur at the beginning of a name.
diff --git a/src/lib/libcrypto/man/OBJ_create.3 b/src/lib/libcrypto/man/OBJ_create.3
index fa5bde3dd3..75d51f4bb8 100644
--- a/src/lib/libcrypto/man/OBJ_create.3
+++ b/src/lib/libcrypto/man/OBJ_create.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OBJ_create.3,v 1.10 2024/01/31 08:02:53 tb Exp $ 1.\" $OpenBSD: OBJ_create.3,v 1.11 2025/06/08 22:37:23 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL OBJ_nid2obj.pod 9b86974e Aug 17 15:21:33 2015 -0400 3.\" OpenSSL OBJ_nid2obj.pod 9b86974e Aug 17 15:21:33 2015 -0400
4.\" selective merge up to: 4.\" selective merge up to:
@@ -69,18 +69,18 @@
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE. 70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\" 71.\"
72.Dd $Mdocdate: January 31 2024 $ 72.Dd $Mdocdate: June 8 2025 $
73.Dt OBJ_CREATE 3 73.Dt OBJ_CREATE 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
76.Nm OBJ_new_nid , 76.Nm OBJ_new_nid ,
77.Nm OBJ_add_object , 77.Nm OBJ_add_object ,
78.Nm OBJ_create , 78.Nm OBJ_create ,
79.\" OBJ_create_and_add_object is a deprecated, unused alias for OBJ_create(3).
80.Nm OBJ_create_objects , 79.Nm OBJ_create_objects ,
81.Nm OBJ_cleanup 80.Nm OBJ_cleanup
82.Nd modify the table of ASN.1 object identifiers 81.Nd modify the table of ASN.1 object identifiers
83.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
84.In openssl/objects.h 84.In openssl/objects.h
85.Ft int 85.Ft int
86.Fn OBJ_new_nid "int increment" 86.Fn OBJ_new_nid "int increment"
diff --git a/src/lib/libcrypto/man/OBJ_find_sigid_algs.3 b/src/lib/libcrypto/man/OBJ_find_sigid_algs.3
index 1d7a2b649b..4c071c6c76 100644
--- a/src/lib/libcrypto/man/OBJ_find_sigid_algs.3
+++ b/src/lib/libcrypto/man/OBJ_find_sigid_algs.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OBJ_find_sigid_algs.3,v 1.2 2024/01/31 08:02:53 tb Exp $ 1.\" $OpenBSD: OBJ_find_sigid_algs.3,v 1.4 2025/06/09 12:42:46 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 31 2024 $ 17.Dd $Mdocdate: June 9 2025 $
18.Dt OBJ_FIND_SIGID_ALGS 3 18.Dt OBJ_FIND_SIGID_ALGS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm OBJ_find_sigid_by_algs 22.Nm OBJ_find_sigid_by_algs
23.Nd signature algorithm mappings 23.Nd signature algorithm mappings
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/objects.h 26.In openssl/objects.h
26.Ft int 27.Ft int
27.Fo OBJ_find_sigid_algs 28.Fo OBJ_find_sigid_algs
@@ -80,7 +81,6 @@ and
80algorithms is defined or 0 if the definition of such an algorithm 81algorithms is defined or 0 if the definition of such an algorithm
81is not built into the library. 82is not built into the library.
82.Sh SEE ALSO 83.Sh SEE ALSO
83.Xr EVP_cleanup 3 ,
84.Xr OBJ_create 3 , 84.Xr OBJ_create 3 ,
85.Xr OBJ_nid2obj 3 85.Xr OBJ_nid2obj 3
86.Sh HISTORY 86.Sh HISTORY
diff --git a/src/lib/libcrypto/man/OBJ_nid2obj.3 b/src/lib/libcrypto/man/OBJ_nid2obj.3
index ccab1ed30c..9261ac9a7d 100644
--- a/src/lib/libcrypto/man/OBJ_nid2obj.3
+++ b/src/lib/libcrypto/man/OBJ_nid2obj.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OBJ_nid2obj.3,v 1.22 2024/01/31 08:02:53 tb Exp $ 1.\" $OpenBSD: OBJ_nid2obj.3,v 1.23 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL c264592d May 14 11:28:00 2006 +0000 2.\" full merge up to: OpenSSL c264592d May 14 11:28:00 2006 +0000
3.\" selective merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200 3.\" selective merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: January 31 2024 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt OBJ_NID2OBJ 3 71.Dt OBJ_NID2OBJ 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -86,6 +86,7 @@
86.Nm i2a_ASN1_OBJECT 86.Nm i2a_ASN1_OBJECT
87.Nd inspect and create ASN.1 object identifiers 87.Nd inspect and create ASN.1 object identifiers
88.Sh SYNOPSIS 88.Sh SYNOPSIS
89.Lb libcrypto
89.In openssl/objects.h 90.In openssl/objects.h
90.Ft ASN1_OBJECT * 91.Ft ASN1_OBJECT *
91.Fo OBJ_nid2obj 92.Fo OBJ_nid2obj
diff --git a/src/lib/libcrypto/man/OCSP_CRLID_new.3 b/src/lib/libcrypto/man/OCSP_CRLID_new.3
index 6feb608654..9b0126fe91 100644
--- a/src/lib/libcrypto/man/OCSP_CRLID_new.3
+++ b/src/lib/libcrypto/man/OCSP_CRLID_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_CRLID_new.3,v 1.8 2022/01/15 23:38:50 jsg Exp $ 1.\" $OpenBSD: OCSP_CRLID_new.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 15 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt OCSP_CRLID_NEW 3 18.Dt OCSP_CRLID_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm OCSP_crlID_new 23.Nm OCSP_crlID_new
24.Nd OCSP CRL extension 24.Nd OCSP CRL extension
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/ocsp.h 27.In openssl/ocsp.h
27.Ft OCSP_CRLID * 28.Ft OCSP_CRLID *
28.Fn OCSP_CRLID_new void 29.Fn OCSP_CRLID_new void
diff --git a/src/lib/libcrypto/man/OCSP_REQUEST_new.3 b/src/lib/libcrypto/man/OCSP_REQUEST_new.3
index a304f60160..0e4e0ffb38 100644
--- a/src/lib/libcrypto/man/OCSP_REQUEST_new.3
+++ b/src/lib/libcrypto/man/OCSP_REQUEST_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_REQUEST_new.3,v 1.12 2022/02/19 13:09:36 jsg Exp $ 1.\" $OpenBSD: OCSP_REQUEST_new.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: February 19 2022 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt OCSP_REQUEST_NEW 3 69.Dt OCSP_REQUEST_NEW 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -84,6 +84,7 @@
84.Nm OCSP_request_onereq_get0 84.Nm OCSP_request_onereq_get0
85.Nd OCSP request functions 85.Nd OCSP request functions
86.Sh SYNOPSIS 86.Sh SYNOPSIS
87.Lb libcrypto
87.In openssl/ocsp.h 88.In openssl/ocsp.h
88.Ft OCSP_REQUEST * 89.Ft OCSP_REQUEST *
89.Fn OCSP_REQUEST_new void 90.Fn OCSP_REQUEST_new void
diff --git a/src/lib/libcrypto/man/OCSP_SERVICELOC_new.3 b/src/lib/libcrypto/man/OCSP_SERVICELOC_new.3
index 62eb8c320f..42288321a3 100644
--- a/src/lib/libcrypto/man/OCSP_SERVICELOC_new.3
+++ b/src/lib/libcrypto/man/OCSP_SERVICELOC_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_SERVICELOC_new.3,v 1.8 2019/08/23 12:23:39 schwarze Exp $ 1.\" $OpenBSD: OCSP_SERVICELOC_new.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 23 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt OCSP_SERVICELOC_NEW 3 18.Dt OCSP_SERVICELOC_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm OCSP_url_svcloc_new 23.Nm OCSP_url_svcloc_new
24.Nd OCSP service locator extension 24.Nd OCSP service locator extension
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/ocsp.h 27.In openssl/ocsp.h
27.Ft OCSP_SERVICELOC * 28.Ft OCSP_SERVICELOC *
28.Fn OCSP_SERVICELOC_new void 29.Fn OCSP_SERVICELOC_new void
diff --git a/src/lib/libcrypto/man/OCSP_cert_to_id.3 b/src/lib/libcrypto/man/OCSP_cert_to_id.3
index 032e87515e..d0c04fcbb1 100644
--- a/src/lib/libcrypto/man/OCSP_cert_to_id.3
+++ b/src/lib/libcrypto/man/OCSP_cert_to_id.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_cert_to_id.3,v 1.14 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: OCSP_cert_to_id.3,v 1.15 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: April 17 2025 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt OCSP_CERT_TO_ID 3 69.Dt OCSP_CERT_TO_ID 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -78,6 +78,7 @@
78.Nm OCSP_id_get0_info 78.Nm OCSP_id_get0_info
79.Nd OCSP certificate ID utility functions 79.Nd OCSP certificate ID utility functions
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/ocsp.h 82.In openssl/ocsp.h
82.Ft OCSP_CERTID * 83.Ft OCSP_CERTID *
83.Fn OCSP_CERTID_new void 84.Fn OCSP_CERTID_new void
diff --git a/src/lib/libcrypto/man/OCSP_request_add1_nonce.3 b/src/lib/libcrypto/man/OCSP_request_add1_nonce.3
index 036c937c61..304d686ba7 100644
--- a/src/lib/libcrypto/man/OCSP_request_add1_nonce.3
+++ b/src/lib/libcrypto/man/OCSP_request_add1_nonce.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_request_add1_nonce.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $ 1.\" $OpenBSD: OCSP_request_add1_nonce.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 22 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt OCSP_REQUEST_ADD1_NONCE 3 52.Dt OCSP_REQUEST_ADD1_NONCE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm OCSP_copy_nonce 58.Nm OCSP_copy_nonce
59.Nd OCSP nonce functions 59.Nd OCSP nonce functions
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/ocsp.h 62.In openssl/ocsp.h
62.Ft int 63.Ft int
63.Fo OCSP_request_add1_nonce 64.Fo OCSP_request_add1_nonce
diff --git a/src/lib/libcrypto/man/OCSP_resp_find_status.3 b/src/lib/libcrypto/man/OCSP_resp_find_status.3
index 06d0354bd6..5e9ce02fd5 100644
--- a/src/lib/libcrypto/man/OCSP_resp_find_status.3
+++ b/src/lib/libcrypto/man/OCSP_resp_find_status.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_resp_find_status.3,v 1.11 2022/03/31 17:27:17 naddy Exp $ 1.\" $OpenBSD: OCSP_resp_find_status.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL c952780c Jun 21 07:03:34 2016 -0400 2.\" full merge up to: OpenSSL c952780c Jun 21 07:03:34 2016 -0400
3.\" selective merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100 3.\" selective merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: March 31 2022 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt OCSP_RESP_FIND_STATUS 3 71.Dt OCSP_RESP_FIND_STATUS 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -88,6 +88,7 @@
88.Nm OCSP_basic_verify 88.Nm OCSP_basic_verify
89.Nd OCSP response utility functions 89.Nd OCSP response utility functions
90.Sh SYNOPSIS 90.Sh SYNOPSIS
91.Lb libcrypto
91.In openssl/ocsp.h 92.In openssl/ocsp.h
92.Ft OCSP_SINGLERESP * 93.Ft OCSP_SINGLERESP *
93.Fn OCSP_SINGLERESP_new void 94.Fn OCSP_SINGLERESP_new void
diff --git a/src/lib/libcrypto/man/OCSP_response_status.3 b/src/lib/libcrypto/man/OCSP_response_status.3
index 4e85384fb0..7fd8267d9f 100644
--- a/src/lib/libcrypto/man/OCSP_response_status.3
+++ b/src/lib/libcrypto/man/OCSP_response_status.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_response_status.3,v 1.8 2019/08/27 09:40:29 schwarze Exp $ 1.\" $OpenBSD: OCSP_response_status.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 2.\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\" selective merge up to: OpenSSL 6738bf14 Feb 13 12:51:29 2018 +0000 3.\" selective merge up to: OpenSSL 6738bf14 Feb 13 12:51:29 2018 +0000
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: August 27 2019 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt OCSP_RESPONSE_STATUS 3 70.Dt OCSP_RESPONSE_STATUS 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -87,6 +87,7 @@
87.Nm OCSP_basic_sign 87.Nm OCSP_basic_sign
88.Nd OCSP response functions 88.Nd OCSP response functions
89.Sh SYNOPSIS 89.Sh SYNOPSIS
90.Lb libcrypto
90.In openssl/ocsp.h 91.In openssl/ocsp.h
91.Ft OCSP_RESPONSE * 92.Ft OCSP_RESPONSE *
92.Fn OCSP_RESPONSE_new void 93.Fn OCSP_RESPONSE_new void
diff --git a/src/lib/libcrypto/man/OCSP_sendreq_new.3 b/src/lib/libcrypto/man/OCSP_sendreq_new.3
index 300f719525..c6608ecce7 100644
--- a/src/lib/libcrypto/man/OCSP_sendreq_new.3
+++ b/src/lib/libcrypto/man/OCSP_sendreq_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OCSP_sendreq_new.3,v 1.10 2022/03/31 17:27:17 naddy Exp $ 1.\" $OpenBSD: OCSP_sendreq_new.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: March 31 2022 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt OCSP_SENDREQ_NEW 3 69.Dt OCSP_SENDREQ_NEW 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -78,6 +78,7 @@
78.Nm OCSP_sendreq_bio 78.Nm OCSP_sendreq_bio
79.Nd OCSP responder query functions 79.Nd OCSP responder query functions
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/ocsp.h 82.In openssl/ocsp.h
82.Ft OCSP_REQ_CTX * 83.Ft OCSP_REQ_CTX *
83.Fo OCSP_sendreq_new 84.Fo OCSP_sendreq_new
diff --git a/src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3 b/src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3
index 76427a864b..929658c28d 100644
--- a/src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3
+++ b/src/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OPENSSL_VERSION_NUMBER.3,v 1.13 2023/11/16 20:17:04 schwarze Exp $ 1.\" $OpenBSD: OPENSSL_VERSION_NUMBER.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 1f13ad31 Dec 25 17:50:39 2017 +0800 2.\" full merge up to: OpenSSL 1f13ad31 Dec 25 17:50:39 2017 +0800
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: November 16 2023 $ 71.Dd $Mdocdate: June 8 2025 $
72.Dt OPENSSL_VERSION_NUMBER 3 72.Dt OPENSSL_VERSION_NUMBER 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -82,6 +82,7 @@
82.Nm SSLeay_version 82.Nm SSLeay_version
83.Nd get OpenSSL version number 83.Nd get OpenSSL version number
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/opensslv.h 86.In openssl/opensslv.h
86.Fd #define OPENSSL_VERSION_NUMBER 0x020000000L 87.Fd #define OPENSSL_VERSION_NUMBER 0x020000000L
87.Fd #define LIBRESSL_VERSION_NUMBER 0x02nnnn00fL 88.Fd #define LIBRESSL_VERSION_NUMBER 0x02nnnn00fL
diff --git a/src/lib/libcrypto/man/OPENSSL_cleanse.3 b/src/lib/libcrypto/man/OPENSSL_cleanse.3
index 95fe6b86fd..cf16405db9 100644
--- a/src/lib/libcrypto/man/OPENSSL_cleanse.3
+++ b/src/lib/libcrypto/man/OPENSSL_cleanse.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OPENSSL_cleanse.3,v 1.4 2019/06/10 09:49:48 schwarze Exp $ 1.\" $OpenBSD: OPENSSL_cleanse.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 10 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt OPENSSL_CLEANSE 3 18.Dt OPENSSL_CLEANSE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm OPENSSL_cleanse 21.Nm OPENSSL_cleanse
22.Nd OpenSSL memory cleaning operation 22.Nd OpenSSL memory cleaning operation
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/crypto.h 25.In openssl/crypto.h
25.Ft void 26.Ft void
26.Fo OPENSSL_cleanse 27.Fo OPENSSL_cleanse
diff --git a/src/lib/libcrypto/man/OPENSSL_config.3 b/src/lib/libcrypto/man/OPENSSL_config.3
index f5f31571a1..e21b9817de 100644
--- a/src/lib/libcrypto/man/OPENSSL_config.3
+++ b/src/lib/libcrypto/man/OPENSSL_config.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OPENSSL_config.3,v 1.16 2023/11/19 21:01:27 tb Exp $ 1.\" $OpenBSD: OPENSSL_config.3,v 1.18 2025/06/09 12:43:53 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: November 19 2023 $ 68.Dd $Mdocdate: June 9 2025 $
69.Dt OPENSSL_CONFIG 3 69.Dt OPENSSL_CONFIG 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -73,6 +73,7 @@
73.Nm OPENSSL_no_config 73.Nm OPENSSL_no_config
74.Nd simple crypto and ssl library configuration 74.Nd simple crypto and ssl library configuration
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libcrypto
76.In openssl/conf.h 77.In openssl/conf.h
77.Ft void 78.Ft void
78.Fo OPENSSL_config 79.Fo OPENSSL_config
@@ -117,13 +118,11 @@ To use a non-standard configuration file, refer to
117Internally, 118Internally,
118.Fn OPENSSL_config 119.Fn OPENSSL_config
119calls 120calls
120.Xr OPENSSL_init_crypto 3 121.Xr OPENSSL_init_crypto 3 .
121and
122.Xr OPENSSL_load_builtin_modules 3 .
123.Pp 122.Pp
124If an application is compiled with the preprocessor symbol 123If an application is compiled with the preprocessor symbol
125.Dv OPENSSL_LOAD_CONF 124.Dv OPENSSL_LOAD_CONF
126#define'd, 125defined,
127.Xr OpenSSL_add_all_algorithms 3 126.Xr OpenSSL_add_all_algorithms 3
128automatically calls 127automatically calls
129.Fn OPENSSL_config . 128.Fn OPENSSL_config .
@@ -140,7 +139,6 @@ standard configuration file
140.Xr CONF_modules_free 3 , 139.Xr CONF_modules_free 3 ,
141.Xr CONF_modules_load_file 3 , 140.Xr CONF_modules_load_file 3 ,
142.Xr crypto 3 , 141.Xr crypto 3 ,
143.Xr OPENSSL_load_builtin_modules 3 ,
144.Xr OPENSSL_VERSION_NUMBER 3 , 142.Xr OPENSSL_VERSION_NUMBER 3 ,
145.Xr openssl.cnf 5 , 143.Xr openssl.cnf 5 ,
146.Xr x509v3.cnf 5 144.Xr x509v3.cnf 5
diff --git a/src/lib/libcrypto/man/OPENSSL_init_crypto.3 b/src/lib/libcrypto/man/OPENSSL_init_crypto.3
index 6f38c7bda2..5c29d55aa9 100644
--- a/src/lib/libcrypto/man/OPENSSL_init_crypto.3
+++ b/src/lib/libcrypto/man/OPENSSL_init_crypto.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OPENSSL_init_crypto.3,v 1.5 2020/05/24 12:21:31 schwarze Exp $ 1.\" $OpenBSD: OPENSSL_init_crypto.3,v 1.7 2025/06/09 12:43:53 schwarze Exp $
2.\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: May 24 2020 $ 16.Dd $Mdocdate: June 9 2025 $
17.Dt OPENSSL_INIT_CRYPTO 3 17.Dt OPENSSL_INIT_CRYPTO 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
@@ -21,6 +21,7 @@
21.Nm OPENSSL_init 21.Nm OPENSSL_init
22.Nd initialise the crypto library 22.Nd initialise the crypto library
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/crypto.h 25.In openssl/crypto.h
25.Ft int 26.Ft int
26.Fo OPENSSL_init_crypto 27.Fo OPENSSL_init_crypto
@@ -54,10 +55,7 @@ If
54is called before any other crypto or ssl functions, the crypto 55is called before any other crypto or ssl functions, the crypto
55library is initialised by allocating various internal resources, 56library is initialised by allocating various internal resources,
56in particular calling 57in particular calling
57.Xr ERR_load_crypto_strings 3 , 58.Xr ERR_load_crypto_strings 3 .
58.Xr OpenSSL_add_all_ciphers 3 ,
59and
60.Xr OpenSSL_add_all_digests 3 .
61.Pp 59.Pp
62The following 60The following
63.Fa options 61.Fa options
@@ -92,7 +90,6 @@ is intended to return 1 on success or 0 on error.
92.Sh SEE ALSO 90.Sh SEE ALSO
93.Xr CONF_modules_load_file 3 , 91.Xr CONF_modules_load_file 3 ,
94.Xr OPENSSL_config 3 , 92.Xr OPENSSL_config 3 ,
95.Xr OPENSSL_load_builtin_modules 3 ,
96.Xr openssl.cnf 5 93.Xr openssl.cnf 5
97.Sh HISTORY 94.Sh HISTORY
98.Fn OPENSSL_init 95.Fn OPENSSL_init
diff --git a/src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3 b/src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3
deleted file mode 100644
index 2b20efaf0e..0000000000
--- a/src/lib/libcrypto/man/OPENSSL_load_builtin_modules.3
+++ /dev/null
@@ -1,101 +0,0 @@
1.\" $OpenBSD: OPENSSL_load_builtin_modules.3,v 1.8 2023/12/05 02:41:13 jsg Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2004, 2013 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 5 2023 $
52.Dt OPENSSL_LOAD_BUILTIN_MODULES 3
53.Os
54.Sh NAME
55.Nm OPENSSL_load_builtin_modules ,
56.Nm ASN1_add_oid_module
57.Nd add standard configuration modules
58.Sh SYNOPSIS
59.In openssl/conf.h
60.Ft void
61.Fn OPENSSL_load_builtin_modules void
62.Ft void
63.Fn ASN1_add_oid_module void
64.Sh DESCRIPTION
65The function
66.Fn OPENSSL_load_builtin_modules
67adds all the standard OpenSSL configuration modules to the internal
68list.
69They can then be used by the OpenSSL configuration code.
70.Pp
71.Fn ASN1_add_oid_module
72adds just the ASN.1 OBJECT module.
73.Pp
74If the simple configuration function
75.Xr OPENSSL_config 3
76is called then
77.Fn OPENSSL_load_builtin_modules
78is called automatically.
79.Pp
80Applications which use configuration functions like
81.Xr CONF_modules_load_file 3
82directly need to call
83.Fn OPENSSL_load_builtin_modules
84themselves
85.Em before
86any other configuration code.
87.Pp
88Applications should call
89.Xr OPENSSL_config 3
90or
91.Fn OPENSSL_load_builtin_modules
92to load all configuration modules instead of adding modules selectively:
93otherwise functionality may be missing from the application when
94new modules are added.
95.Sh SEE ALSO
96.Xr CONF_modules_load_file 3 ,
97.Xr OPENSSL_config 3
98.Sh HISTORY
99These functions first appeared in OpenSSL 0.9.7
100and have been available since
101.Ox 3.2 .
diff --git a/src/lib/libcrypto/man/OPENSSL_malloc.3 b/src/lib/libcrypto/man/OPENSSL_malloc.3
index a43dc56923..6e87d030d8 100644
--- a/src/lib/libcrypto/man/OPENSSL_malloc.3
+++ b/src/lib/libcrypto/man/OPENSSL_malloc.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OPENSSL_malloc.3,v 1.13 2024/04/04 09:30:43 tb Exp $ 1.\" $OpenBSD: OPENSSL_malloc.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 4 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt OPENSSL_MALLOC 3 18.Dt OPENSSL_MALLOC 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm CRYPTO_strdup 26.Nm CRYPTO_strdup
27.Nd legacy OpenSSL memory allocation wrappers 27.Nd legacy OpenSSL memory allocation wrappers
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/crypto.h 30.In openssl/crypto.h
30.Ft void * 31.Ft void *
31.Fo OPENSSL_malloc 32.Fo OPENSSL_malloc
diff --git a/src/lib/libcrypto/man/OPENSSL_sk_new.3 b/src/lib/libcrypto/man/OPENSSL_sk_new.3
index 8f06bb4212..632bc9d39f 100644
--- a/src/lib/libcrypto/man/OPENSSL_sk_new.3
+++ b/src/lib/libcrypto/man/OPENSSL_sk_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OPENSSL_sk_new.3,v 1.13 2024/03/04 09:47:34 tb Exp $ 1.\" $OpenBSD: OPENSSL_sk_new.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 4 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt OPENSSL_SK_NEW 3 18.Dt OPENSSL_SK_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -40,6 +40,7 @@
40.Nm sk_zero 40.Nm sk_zero
41.Nd variable-sized arrays of void pointers, called OpenSSL stacks 41.Nd variable-sized arrays of void pointers, called OpenSSL stacks
42.Sh SYNOPSIS 42.Sh SYNOPSIS
43.Lb libcrypto
43.In openssl/stack.h 44.In openssl/stack.h
44.Ft _STACK * 45.Ft _STACK *
45.Fn sk_new_null void 46.Fn sk_new_null void
diff --git a/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3 b/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
index 88ecef9768..68d8799bd4 100644
--- a/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
+++ b/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
@@ -1,7 +1,24 @@
1.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.16 2024/03/04 19:04:47 tb Exp $ 1.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.19 2025/06/12 15:59:30 schwarze Exp $
2.\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400 2.\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2019, 2023, 2025 Ingo Schwarze <schwarze@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.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000, 2003, 2013 The OpenSSL Project. All rights reserved. 22.\" Copyright (c) 2000, 2003, 2013 The OpenSSL Project. All rights reserved.
6.\" 23.\"
7.\" Redistribution and use in source and binary forms, with or without 24.\" Redistribution and use in source and binary forms, with or without
@@ -48,7 +65,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 67.\"
51.Dd $Mdocdate: March 4 2024 $ 68.Dd $Mdocdate: June 12 2025 $
52.Dt OPENSSL_ADD_ALL_ALGORITHMS 3 69.Dt OPENSSL_ADD_ALL_ALGORITHMS 3
53.Os 70.Os
54.Sh NAME 71.Sh NAME
@@ -64,6 +81,7 @@
64.\" because they are unused aliases. 81.\" because they are unused aliases.
65.Nd add algorithms to internal table 82.Nd add algorithms to internal table
66.Sh SYNOPSIS 83.Sh SYNOPSIS
84.Lb libcrypto
67.In openssl/evp.h 85.In openssl/evp.h
68.Ft void 86.Ft void
69.Fn OpenSSL_add_all_algorithms void 87.Fn OpenSSL_add_all_algorithms void
@@ -79,40 +97,43 @@
79These functions are deprecated. 97These functions are deprecated.
80It is never useful for any application program 98It is never useful for any application program
81to call any of them explicitly. 99to call any of them explicitly.
82The library automatically calls them internally whenever needed. 100Most of them have no effect except that they may or may not call
101.Xr OPENSSL_init_crypto 3 .
83.Pp 102.Pp
84OpenSSL keeps an internal table of digest algorithms and ciphers. 103The library contains internal tables of digest algorithms and ciphers.
85It uses this table to look up ciphers via functions such as 104It uses these tables to look up digests and ciphers via
86.Xr EVP_get_cipherbyname 3 . 105.Xr EVP_get_digestbyname 3
106and
107.Xr EVP_get_cipherbyname 3 ,
108respectively.
109In LibreSSL, these tables are static constants and do not require
110initialization.
87.Pp 111.Pp
88.Fn OpenSSL_add_all_algorithms 112.Fn OpenSSL_add_all_algorithms
89adds all algorithms to the table (digests and ciphers). 113used to add all digests and ciphers to the tables.
90If an application is compiled with the preprocessor symbol 114If an application is compiled with the preprocessor symbol
91.Dv OPENSSL_LOAD_CONF 115.Dv OPENSSL_LOAD_CONF
92#define'd, it also calls 116defined, it also calls
93.Xr OPENSSL_config 3 117.Xr OPENSSL_config 3
94with a 118with a
95.Dv NULL 119.Dv NULL
96argument, loading the default configuration file. 120argument, loading the default configuration file.
121Relying on this behaviour is not recommended.
122If loading a configuration file is desired, call
123.Xr OPENSSL_config 3
124or
125.Xr CONF_modules_load_file 3
126directly.
97.Pp 127.Pp
98.Fn OpenSSL_add_all_digests 128.Fn OpenSSL_add_all_digests
99adds all digest algorithms to the table. 129used to add all digest algorithms to the table.
100.Pp 130.Pp
101.Fn OpenSSL_add_all_ciphers 131.Fn OpenSSL_add_all_ciphers
102adds all encryption algorithms to the table including password based 132used to add all encryption algorithms to the table.
103encryption algorithms.
104.Pp
105If any of the above functions is called more than once,
106only the first call has an effect.
107.Pp 133.Pp
108.Fn EVP_cleanup 134.Fn EVP_cleanup
109removes all ciphers and digests from the table and also calls 135has no effect; it used to remove various kinds of application-supplied
110.Xr OBJ_NAME_cleanup 3 136data that is no longer supported in the first place.
111with an argument of \-1 ,
112thus resetting the global associative array of names
113and all signature algorithm definitions to their default states,
114removing all application-defined types, key-value pairs, and aliases,
115including any that are unrelated to the EVP library.
116.Pp 137.Pp
117.Fn SSLeay_add_all_algorithms 138.Fn SSLeay_add_all_algorithms
118is a deprecated alias for 139is a deprecated alias for
@@ -126,8 +147,6 @@ are implemented as macros.
126.Xr evp 3 , 147.Xr evp 3 ,
127.Xr EVP_DigestInit 3 , 148.Xr EVP_DigestInit 3 ,
128.Xr EVP_EncryptInit 3 , 149.Xr EVP_EncryptInit 3 ,
129.Xr OBJ_cleanup 3 ,
130.Xr OBJ_NAME_add 3 ,
131.Xr OPENSSL_config 3 150.Xr OPENSSL_config 3
132.Sh HISTORY 151.Sh HISTORY
133.Fn EVP_cleanup , 152.Fn EVP_cleanup ,
@@ -148,5 +167,3 @@ first appeared in OpenSSL 0.9.5 and have been available since
148.Sh BUGS 167.Sh BUGS
149Although the functions do not return error codes, it is possible for them 168Although the functions do not return error codes, it is possible for them
150to fail. 169to fail.
151This will only happen as a result of a memory allocation failure so this
152is not too much of a problem in practice.
diff --git a/src/lib/libcrypto/man/PEM_ASN1_read.3 b/src/lib/libcrypto/man/PEM_ASN1_read.3
index 53ebe5ada4..016007d405 100644
--- a/src/lib/libcrypto/man/PEM_ASN1_read.3
+++ b/src/lib/libcrypto/man/PEM_ASN1_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_ASN1_read.3,v 1.2 2020/07/23 17:34:53 schwarze Exp $ 1.\" $OpenBSD: PEM_ASN1_read.3,v 1.4 2025/07/16 17:59:10 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 23 2020 $ 17.Dd $Mdocdate: July 16 2025 $
18.Dt PEM_ASN1_READ 3 18.Dt PEM_ASN1_READ 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm PEM_ASN1_read_bio 23.Nm PEM_ASN1_read_bio
24.Nd PEM and DER decode an arbitrary ASN.1 value 24.Nd PEM and DER decode an arbitrary ASN.1 value
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/pem.h 27.In openssl/pem.h
27.Ft typedef void * 28.Ft typedef void *
28.Fo d2i_of_void 29.Fo d2i_of_void
@@ -165,7 +166,7 @@ Additional types of errors can result from
165.Xr PEM_read 3 , 166.Xr PEM_read 3 ,
166.Xr PEM_read_bio_PrivateKey 3 , 167.Xr PEM_read_bio_PrivateKey 3 ,
167.Xr PEM_read_SSL_SESSION 3 , 168.Xr PEM_read_SSL_SESSION 3 ,
168.Xr PEM_X509_INFO_read 3 169.Xr PEM_X509_INFO_read_bio 3
169.Sh HISTORY 170.Sh HISTORY
170These functions first appeared in SSLeay 0.5.1 171These functions first appeared in SSLeay 0.5.1
171and have been available since 172and have been available since
diff --git a/src/lib/libcrypto/man/PEM_X509_INFO_read.3 b/src/lib/libcrypto/man/PEM_X509_INFO_read_bio.3
index b3216a89b6..7d34951df0 100644
--- a/src/lib/libcrypto/man/PEM_X509_INFO_read.3
+++ b/src/lib/libcrypto/man/PEM_X509_INFO_read_bio.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_X509_INFO_read.3,v 1.4 2021/10/19 10:39:33 schwarze Exp $ 1.\" $OpenBSD: PEM_X509_INFO_read_bio.3,v 1.1 2025/07/17 10:31:50 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,23 +14,16 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 19 2021 $ 17.Dd $Mdocdate: July 17 2025 $
18.Dt PEM_X509_INFO_READ 3 18.Dt PEM_X509_INFO_READ_BIO 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm PEM_X509_INFO_read ,
22.Nm PEM_X509_INFO_read_bio 21.Nm PEM_X509_INFO_read_bio
23.Nd PEM and DER decode X.509 certificates, private keys, and revocation lists 22.Nd PEM and DER decode X.509 certificates, private keys, and revocation lists
24.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
25.In openssl/pem.h 25.In openssl/pem.h
26.Ft STACK_OF(X509_INFO) * 26.Ft STACK_OF(X509_INFO) *
27.Fo PEM_X509_INFO_read
28.Fa "FILE *in_fp"
29.Fa "STACK_OF(X509_INFO) *sk"
30.Fa "pem_password_cb *cb"
31.Fa "void *u"
32.Fc
33.Ft STACK_OF(X509_INFO) *
34.Fo PEM_X509_INFO_read_bio 27.Fo PEM_X509_INFO_read_bio
35.Fa "BIO *in_bp" 28.Fa "BIO *in_bp"
36.Fa "STACK_OF(X509_INFO) *sk" 29.Fa "STACK_OF(X509_INFO) *sk"
@@ -38,13 +31,11 @@
38.Fa "void *u" 31.Fa "void *u"
39.Fc 32.Fc
40.Sh DESCRIPTION 33.Sh DESCRIPTION
41These functions read zero or more objects 34This function reads zero or more objects
42related to X.509 certificates from 35related to X.509 certificates from
43.Fa in_fp
44or
45.Fa in_bp , 36.Fa in_bp ,
46perform both PEM and DER decoding, 37performs both PEM and DER decoding,
47and wrap the resulting objects in newly allocated 38and wraps the resulting objects in newly allocated
48.Vt X509_INFO 39.Vt X509_INFO
49containers. 40containers.
50.Pp 41.Pp
@@ -109,11 +100,11 @@ during the same call are deleted again and
109.Fa sk 100.Fa sk
110is left unchanged. 101is left unchanged.
111.Sh RETURN VALUES 102.Sh RETURN VALUES
112These functions return a pointer to the stack 103This function returns a pointer to the stack
113the objects read were pushed onto or 104the objects read were pushed onto or
114.Dv NULL 105.Dv NULL
115if an error occurs. 106if an error occurs.
116They fail if 107It fails if
117.Xr PEM_read_bio 3 , 108.Xr PEM_read_bio 3 ,
118.Xr PEM_get_EVP_CIPHER_INFO 3 , 109.Xr PEM_get_EVP_CIPHER_INFO 3 ,
119.Xr PEM_do_header 3 , 110.Xr PEM_do_header 3 ,
@@ -128,9 +119,6 @@ include:
128.Bl -tag -width Ds 119.Bl -tag -width Ds
129.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib" 120.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib"
130DER decoding of a PEM object failed. 121DER decoding of a PEM object failed.
131.It Dv ERR_R_BUF_LIB Qq BUF lib
132.Fn PEM_X509_INFO_read
133failed to set up a temporary BIO, for example because memory was exhausted.
134.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure" 122.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
135.Fn PEM_X509_INFO_read_bio 123.Fn PEM_X509_INFO_read_bio
136failed to allocate a new 124failed to allocate a new
@@ -147,7 +135,7 @@ Additional types of errors can result from
147and 135and
148.Xr PEM_do_header 3 . 136.Xr PEM_do_header 3 .
149.Pp 137.Pp
150After these functions failed due to memory exhaustion, 138After this function failed due to memory exhaustion,
151.Xr ERR_get_error 3 139.Xr ERR_get_error 3
152may sometimes return 0 anyway. 140may sometimes return 0 anyway.
153.Sh SEE ALSO 141.Sh SEE ALSO
@@ -162,14 +150,10 @@ may sometimes return 0 anyway.
162.Xr X509_CRL_new 3 , 150.Xr X509_CRL_new 3 ,
163.Xr X509_INFO_new 3 , 151.Xr X509_INFO_new 3 ,
164.Xr X509_LOOKUP_new 3 , 152.Xr X509_LOOKUP_new 3 ,
165.Xr X509_new 3 , 153.Xr X509_new 3
166.Xr X509_PKEY_new 3
167.Sh HISTORY 154.Sh HISTORY
168.Fn PEM_X509_INFO_read
169first appeared in SSLeay 0.5.1 and
170.Fn PEM_X509_INFO_read_bio 155.Fn PEM_X509_INFO_read_bio
171in SSLeay 0.6.0. 156first appeared in SSLeay 0.6.0 and has been available since
172Both functions have been available since
173.Ox 2.4 . 157.Ox 2.4 .
174.Sh CAVEATS 158.Sh CAVEATS
175It is not an error 159It is not an error
@@ -184,6 +168,6 @@ a newly allocated, empty stack is returned.
184The only way to detect this situation is by comparing 168The only way to detect this situation is by comparing
185the number of objects on the stack before and after the call. 169the number of objects on the stack before and after the call.
186.Sh BUGS 170.Sh BUGS
187When reaching the end of the input, these functions call 171When reaching the end of the input, this function calls
188.Xr ERR_clear_error 3 , 172.Xr ERR_clear_error 3 ,
189which may hide errors that occurred before calling these functions. 173which may hide errors that occurred before calling it.
diff --git a/src/lib/libcrypto/man/PEM_bytes_read_bio.3 b/src/lib/libcrypto/man/PEM_bytes_read_bio.3
index 20ad6b8a4d..69cb26ce8d 100644
--- a/src/lib/libcrypto/man/PEM_bytes_read_bio.3
+++ b/src/lib/libcrypto/man/PEM_bytes_read_bio.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_bytes_read_bio.3,v 1.6 2020/07/23 17:34:53 schwarze Exp $ 1.\" $OpenBSD: PEM_bytes_read_bio.3,v 1.8 2025/07/16 17:59:10 schwarze Exp $
2.\" selective merge up to: 2.\" selective merge up to:
3.\" OpenSSL PEM_bytes_read_bio.pod 7671342e Feb 29 15:47:12 2016 -0600 3.\" OpenSSL PEM_bytes_read_bio.pod 7671342e Feb 29 15:47:12 2016 -0600
4.\" 4.\"
@@ -65,13 +65,14 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: July 23 2020 $ 68.Dd $Mdocdate: July 16 2025 $
69.Dt PEM_BYTES_READ_BIO 3 69.Dt PEM_BYTES_READ_BIO 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
72.Nm PEM_bytes_read_bio 72.Nm PEM_bytes_read_bio
73.Nd read a PEM-encoded data structure from a BIO 73.Nd read a PEM-encoded data structure from a BIO
74.Sh SYNOPSIS 74.Sh SYNOPSIS
75.Lb libcrypto
75.In openssl/pem.h 76.In openssl/pem.h
76.Ft int 77.Ft int
77.Fo PEM_bytes_read_bio 78.Fo PEM_bytes_read_bio
@@ -175,7 +176,7 @@ Additional types of errors can result from
175.Xr PEM_ASN1_read 3 , 176.Xr PEM_ASN1_read 3 ,
176.Xr PEM_read 3 , 177.Xr PEM_read 3 ,
177.Xr PEM_read_bio_PrivateKey 3 , 178.Xr PEM_read_bio_PrivateKey 3 ,
178.Xr PEM_X509_INFO_read 3 179.Xr PEM_X509_INFO_read_bio 3
179.Sh STANDARDS 180.Sh STANDARDS
180RFC 1421: Privacy Enhancement for Internet Electronic Mail (PEM), Part I 181RFC 1421: Privacy Enhancement for Internet Electronic Mail (PEM), Part I
181.Sh HISTORY 182.Sh HISTORY
diff --git a/src/lib/libcrypto/man/PEM_read.3 b/src/lib/libcrypto/man/PEM_read.3
index 1493d54fc4..de93b3e903 100644
--- a/src/lib/libcrypto/man/PEM_read.3
+++ b/src/lib/libcrypto/man/PEM_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_read.3,v 1.15 2023/09/18 15:26:46 schwarze Exp $ 1.\" $OpenBSD: PEM_read.3,v 1.17 2025/07/16 17:59:10 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: September 18 2023 $ 69.Dd $Mdocdate: July 16 2025 $
70.Dt PEM_READ 3 70.Dt PEM_READ 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -80,6 +80,7 @@
80.Nm pem_password_cb 80.Nm pem_password_cb
81.Nd PEM encoding routines 81.Nd PEM encoding routines
82.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
83.In openssl/pem.h 84.In openssl/pem.h
84.Ft int 85.Ft int
85.Fo PEM_write 86.Fo PEM_write
@@ -395,7 +396,7 @@ to fail may differ.
395.Xr PEM_read_SSL_SESSION 3 , 396.Xr PEM_read_SSL_SESSION 3 ,
396.Xr PEM_write_bio_CMS_stream 3 , 397.Xr PEM_write_bio_CMS_stream 3 ,
397.Xr PEM_write_bio_PKCS7_stream 3 , 398.Xr PEM_write_bio_PKCS7_stream 3 ,
398.Xr PEM_X509_INFO_read 3 399.Xr PEM_X509_INFO_read_bio 3
399.Sh HISTORY 400.Sh HISTORY
400.Fn PEM_write , 401.Fn PEM_write ,
401.Fn PEM_read , 402.Fn PEM_read ,
diff --git a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
index 9f45261725..9ef136de7e 100644
--- a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
+++ b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.23 2024/09/02 08:04:32 tb Exp $ 1.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.25 2025/07/16 17:59:10 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/PEM_read_bio_PrivateKey.pod 18bad535 Apr 9 15:13:55 2019 +0100 3.\" OpenSSL man3/PEM_read_bio_PrivateKey.pod 18bad535 Apr 9 15:13:55 2019 +0100
4.\" OpenSSL man3/PEM_read_CMS.pod 83cf7abf May 29 13:07:08 2018 +0100 4.\" OpenSSL man3/PEM_read_CMS.pod 83cf7abf May 29 13:07:08 2018 +0100
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: September 2 2024 $ 54.Dd $Mdocdate: July 16 2025 $
55.Dt PEM_READ_BIO_PRIVATEKEY 3 55.Dt PEM_READ_BIO_PRIVATEKEY 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -143,6 +143,7 @@
143.Nm PEM_write_bio_CMS 143.Nm PEM_write_bio_CMS
144.Nd PEM routines 144.Nd PEM routines
145.Sh SYNOPSIS 145.Sh SYNOPSIS
146.Lb libcrypto
146.In openssl/pem.h 147.In openssl/pem.h
147.Ft EVP_PKEY * 148.Ft EVP_PKEY *
148.Fo PEM_read_bio_PrivateKey 149.Fo PEM_read_bio_PrivateKey
@@ -1183,7 +1184,7 @@ pass_cb(char *buf, int size, int rwflag, void *u)
1183.Xr PEM_read_SSL_SESSION 3 , 1184.Xr PEM_read_SSL_SESSION 3 ,
1184.Xr PEM_write_bio_CMS_stream 3 , 1185.Xr PEM_write_bio_CMS_stream 3 ,
1185.Xr PEM_write_bio_PKCS7_stream 3 , 1186.Xr PEM_write_bio_PKCS7_stream 3 ,
1186.Xr PEM_X509_INFO_read 3 , 1187.Xr PEM_X509_INFO_read_bio 3 ,
1187.Xr RSA_new 3 , 1188.Xr RSA_new 3 ,
1188.Xr X509_CRL_new 3 , 1189.Xr X509_CRL_new 3 ,
1189.Xr X509_REQ_new 3 , 1190.Xr X509_REQ_new 3 ,
diff --git a/src/lib/libcrypto/man/PEM_write_bio_CMS_stream.3 b/src/lib/libcrypto/man/PEM_write_bio_CMS_stream.3
index 88adbba74f..a858874bab 100644
--- a/src/lib/libcrypto/man/PEM_write_bio_CMS_stream.3
+++ b/src/lib/libcrypto/man/PEM_write_bio_CMS_stream.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_write_bio_CMS_stream.3,v 1.6 2023/05/01 07:28:11 tb Exp $ 1.\" $OpenBSD: PEM_write_bio_CMS_stream.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 1 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PEM_WRITE_BIO_CMS_STREAM 3 52.Dt PEM_WRITE_BIO_CMS_STREAM 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm PEM_write_bio_CMS_stream 55.Nm PEM_write_bio_CMS_stream
56.Nd output CMS_ContentInfo structure in PEM format 56.Nd output CMS_ContentInfo structure in PEM format
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft int 60.Ft int
60.Fo PEM_write_bio_CMS_stream 61.Fo PEM_write_bio_CMS_stream
diff --git a/src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.3 b/src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.3
index 9050b8562f..a731767049 100644
--- a/src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.3
+++ b/src/lib/libcrypto/man/PEM_write_bio_PKCS7_stream.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_write_bio_PKCS7_stream.3,v 1.12 2023/05/01 07:28:11 tb Exp $ 1.\" $OpenBSD: PEM_write_bio_PKCS7_stream.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 1 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PEM_WRITE_BIO_PKCS7_STREAM 3 52.Dt PEM_WRITE_BIO_PKCS7_STREAM 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm PEM_write_bio_PKCS7_stream 55.Nm PEM_write_bio_PKCS7_stream
56.Nd output PKCS7 structure in PEM format 56.Nd output PKCS7 structure in PEM format
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/pkcs7.h 59.In openssl/pkcs7.h
59.Ft int 60.Ft int
60.Fo PEM_write_bio_PKCS7_stream 61.Fo PEM_write_bio_PKCS7_stream
diff --git a/src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3 b/src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3
index e7d20ea7f6..45bdc20bc9 100644
--- a/src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3
+++ b/src/lib/libcrypto/man/PKCS12_SAFEBAG_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS12_SAFEBAG_new.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $ 1.\" $OpenBSD: PKCS12_SAFEBAG_new.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS12_SAFEBAG_NEW 3 18.Dt PKCS12_SAFEBAG_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm PKCS12_BAGS_free 24.Nm PKCS12_BAGS_free
25.Nd PKCS#12 container for one piece of information 25.Nd PKCS#12 container for one piece of information
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/pkcs12.h 28.In openssl/pkcs12.h
28.Ft PKCS12_SAFEBAG * 29.Ft PKCS12_SAFEBAG *
29.Fn PKCS12_SAFEBAG_new void 30.Fn PKCS12_SAFEBAG_new void
diff --git a/src/lib/libcrypto/man/PKCS12_create.3 b/src/lib/libcrypto/man/PKCS12_create.3
index 904166da73..80471ca88a 100644
--- a/src/lib/libcrypto/man/PKCS12_create.3
+++ b/src/lib/libcrypto/man/PKCS12_create.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS12_create.3,v 1.13 2024/08/22 12:26:01 tb Exp $ 1.\" $OpenBSD: PKCS12_create.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: August 22 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt PKCS12_CREATE 3 53.Dt PKCS12_CREATE 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm PKCS12_create 56.Nm PKCS12_create
57.Nd create a PKCS#12 structure 57.Nd create a PKCS#12 structure
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/pkcs12.h 60.In openssl/pkcs12.h
60.Ft PKCS12 * 61.Ft PKCS12 *
61.Fo PKCS12_create 62.Fo PKCS12_create
diff --git a/src/lib/libcrypto/man/PKCS12_new.3 b/src/lib/libcrypto/man/PKCS12_new.3
index c7ccdb4911..1506eaade3 100644
--- a/src/lib/libcrypto/man/PKCS12_new.3
+++ b/src/lib/libcrypto/man/PKCS12_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS12_new.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $ 1.\" $OpenBSD: PKCS12_new.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS12_NEW 3 18.Dt PKCS12_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm PKCS12_MAC_DATA_free 24.Nm PKCS12_MAC_DATA_free
25.Nd PKCS#12 personal information exchange (PFX) 25.Nd PKCS#12 personal information exchange (PFX)
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/pkcs12.h 28.In openssl/pkcs12.h
28.Ft PKCS12 * 29.Ft PKCS12 *
29.Fn PKCS12_new void 30.Fn PKCS12_new void
diff --git a/src/lib/libcrypto/man/PKCS12_newpass.3 b/src/lib/libcrypto/man/PKCS12_newpass.3
index b5642c96ea..b4d088e0e8 100644
--- a/src/lib/libcrypto/man/PKCS12_newpass.3
+++ b/src/lib/libcrypto/man/PKCS12_newpass.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS12_newpass.3,v 1.4 2019/06/14 13:59:32 schwarze Exp $ 1.\" $OpenBSD: PKCS12_newpass.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL c95a8b4e May 5 14:26:26 2016 +0100 2.\" OpenSSL c95a8b4e May 5 14:26:26 2016 +0100
3.\" 3.\"
4.\" This file was written by Jeffrey Walton <noloader@gmail.com>. 4.\" This file was written by Jeffrey Walton <noloader@gmail.com>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 14 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PKCS12_NEWPASS 3 52.Dt PKCS12_NEWPASS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm PKCS12_newpass 55.Nm PKCS12_newpass
56.Nd change the password of a PKCS#12 structure 56.Nd change the password of a PKCS#12 structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/pkcs12.h 59.In openssl/pkcs12.h
59.Ft int 60.Ft int
60.Fo PKCS12_newpass 61.Fo PKCS12_newpass
diff --git a/src/lib/libcrypto/man/PKCS12_parse.3 b/src/lib/libcrypto/man/PKCS12_parse.3
index 4e92d303c7..333d86b672 100644
--- a/src/lib/libcrypto/man/PKCS12_parse.3
+++ b/src/lib/libcrypto/man/PKCS12_parse.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS12_parse.3,v 1.7 2021/07/09 12:07:27 schwarze Exp $ 1.\" $OpenBSD: PKCS12_parse.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 9 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PKCS12_PARSE 3 52.Dt PKCS12_PARSE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm PKCS12_parse 55.Nm PKCS12_parse
56.Nd parse a PKCS#12 structure 56.Nd parse a PKCS#12 structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/pkcs12.h 59.In openssl/pkcs12.h
59.Ft int 60.Ft int
60.Fo PKCS12_parse 61.Fo PKCS12_parse
diff --git a/src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3 b/src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3
index 3a448b92a7..7c113029ee 100644
--- a/src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3
+++ b/src/lib/libcrypto/man/PKCS5_PBKDF2_HMAC.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS5_PBKDF2_HMAC.3,v 1.9 2019/06/07 20:46:25 schwarze Exp $ 1.\" $OpenBSD: PKCS5_PBKDF2_HMAC.3,v 1.10 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Jeffrey Walton <noloader@gmail.com>. 4.\" This file was written by Jeffrey Walton <noloader@gmail.com>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 7 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PKCS5_PBKDF2_HMAC 3 52.Dt PKCS5_PBKDF2_HMAC 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm PKCS5_PBKDF2_HMAC_SHA1 56.Nm PKCS5_PBKDF2_HMAC_SHA1
57.Nd password based derivation routines with salt and iteration count 57.Nd password based derivation routines with salt and iteration count
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/evp.h 60.In openssl/evp.h
60.Ft int 61.Ft int
61.Fo PKCS5_PBKDF2_HMAC 62.Fo PKCS5_PBKDF2_HMAC
diff --git a/src/lib/libcrypto/man/PKCS7_add_attribute.3 b/src/lib/libcrypto/man/PKCS7_add_attribute.3
index 4a1c350f98..e7c8c734c4 100644
--- a/src/lib/libcrypto/man/PKCS7_add_attribute.3
+++ b/src/lib/libcrypto/man/PKCS7_add_attribute.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_add_attribute.3,v 1.3 2020/06/10 11:39:12 schwarze Exp $ 1.\" $OpenBSD: PKCS7_add_attribute.3,v 1.6 2025/07/27 19:31:20 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 10 2020 $ 17.Dd $Mdocdate: July 27 2025 $
18.Dt PKCS7_ADD_ATTRIBUTE 3 18.Dt PKCS7_ADD_ATTRIBUTE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -30,6 +30,7 @@
30.Nm PKCS7_add_attrib_smimecap 30.Nm PKCS7_add_attrib_smimecap
31.Nd attributes of SignerInfo objects 31.Nd attributes of SignerInfo objects
32.Sh SYNOPSIS 32.Sh SYNOPSIS
33.Lb libcrypto
33.In openssl/pkcs7.h 34.In openssl/pkcs7.h
34.Ft int 35.Ft int
35.Fo PKCS7_add_attribute 36.Fo PKCS7_add_attribute
@@ -306,6 +307,10 @@ RFC 2985: PKCS #9: Selected Object Classes and Attribute Types Version 2.0,
306section 5.3: Attribute types for use in PKCS #7 data 307section 5.3: Attribute types for use in PKCS #7 data
307and section 5.6: Attributes defined in S/MIME 308and section 5.6: Attributes defined in S/MIME
308.Pp 309.Pp
310RFC 5652: Cryptographic Message Syntax (CMS),
311section 5.3: SignerInfo Type
312and section 11: Useful Attributes
313.Pp
309RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME) 314RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME)
310Version 4.0 Message Specification, 315Version 4.0 Message Specification,
311section 2.5.2: SMIMECapabilities Attribute 316section 2.5.2: SMIMECapabilities Attribute
@@ -345,7 +350,7 @@ in a state that violates the standard.
345.Fn PKCS7_add0_attrib_signing_time 350.Fn PKCS7_add0_attrib_signing_time
346does not validate 351does not validate
347.Fa t 352.Fa t
348in any way. 353beyond checking that it is well-formed per RFC 5652, section 11.3.
349In particular, it may set the signing time to the future 354In particular, it may set the signing time to the future
350or to the remote past. 355or to the remote past.
351.Sh BUGS 356.Sh BUGS
diff --git a/src/lib/libcrypto/man/PKCS7_dataFinal.3 b/src/lib/libcrypto/man/PKCS7_dataFinal.3
index 1a01b2ff61..fdc9da7f9e 100644
--- a/src/lib/libcrypto/man/PKCS7_dataFinal.3
+++ b/src/lib/libcrypto/man/PKCS7_dataFinal.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_dataFinal.3,v 1.3 2022/12/26 07:18:52 jmc Exp $ 1.\" $OpenBSD: PKCS7_dataFinal.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 26 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS7_DATAFINAL 3 18.Dt PKCS7_DATAFINAL 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm PKCS7_dataFinal 21.Nm PKCS7_dataFinal
22.Nd move data from a BIO chain to a ContentInfo object 22.Nd move data from a BIO chain to a ContentInfo object
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/pkcs7.h 25.In openssl/pkcs7.h
25.Ft int 26.Ft int
26.Fo PKCS7_dataFinal 27.Fo PKCS7_dataFinal
diff --git a/src/lib/libcrypto/man/PKCS7_dataInit.3 b/src/lib/libcrypto/man/PKCS7_dataInit.3
index cb54d3f95c..320a227454 100644
--- a/src/lib/libcrypto/man/PKCS7_dataInit.3
+++ b/src/lib/libcrypto/man/PKCS7_dataInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_dataInit.3,v 1.2 2020/06/03 13:41:27 schwarze Exp $ 1.\" $OpenBSD: PKCS7_dataInit.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 3 2020 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS7_DATAINIT 3 18.Dt PKCS7_DATAINIT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm PKCS7_dataInit 21.Nm PKCS7_dataInit
22.Nd construct a BIO chain for adding or retrieving content 22.Nd construct a BIO chain for adding or retrieving content
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/pkcs7.h 25.In openssl/pkcs7.h
25.Ft BIO * 26.Ft BIO *
26.Fo PKCS7_dataInit 27.Fo PKCS7_dataInit
diff --git a/src/lib/libcrypto/man/PKCS7_decrypt.3 b/src/lib/libcrypto/man/PKCS7_decrypt.3
index 8d00499b57..857777bcd6 100644
--- a/src/lib/libcrypto/man/PKCS7_decrypt.3
+++ b/src/lib/libcrypto/man/PKCS7_decrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_decrypt.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: PKCS7_decrypt.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 10 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PKCS7_DECRYPT 3 52.Dt PKCS7_DECRYPT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm PKCS7_decrypt 55.Nm PKCS7_decrypt
56.Nd decrypt content from a PKCS#7 envelopedData structure 56.Nd decrypt content from a PKCS#7 envelopedData structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/pkcs7.h 59.In openssl/pkcs7.h
59.Ft int 60.Ft int
60.Fo PKCS7_decrypt 61.Fo PKCS7_decrypt
diff --git a/src/lib/libcrypto/man/PKCS7_encrypt.3 b/src/lib/libcrypto/man/PKCS7_encrypt.3
index 700498a1de..3e7283839d 100644
--- a/src/lib/libcrypto/man/PKCS7_encrypt.3
+++ b/src/lib/libcrypto/man/PKCS7_encrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_encrypt.3,v 1.11 2020/06/03 13:41:27 schwarze Exp $ 1.\" $OpenBSD: PKCS7_encrypt.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 3 2020 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt PKCS7_ENCRYPT 3 53.Dt PKCS7_ENCRYPT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm PKCS7_encrypt 56.Nm PKCS7_encrypt
57.Nd create a PKCS#7 envelopedData structure 57.Nd create a PKCS#7 envelopedData structure
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/pkcs7.h 60.In openssl/pkcs7.h
60.Ft PKCS7 * 61.Ft PKCS7 *
61.Fo PKCS7_encrypt 62.Fo PKCS7_encrypt
diff --git a/src/lib/libcrypto/man/PKCS7_final.3 b/src/lib/libcrypto/man/PKCS7_final.3
index 775b84d984..5c2063b1bd 100644
--- a/src/lib/libcrypto/man/PKCS7_final.3
+++ b/src/lib/libcrypto/man/PKCS7_final.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_final.3,v 1.3 2022/12/26 07:18:52 jmc Exp $ 1.\" $OpenBSD: PKCS7_final.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 26 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS7_FINAL 3 18.Dt PKCS7_FINAL 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm PKCS7_final 21.Nm PKCS7_final
22.Nd read data from a BIO into a ContentInfo object 22.Nd read data from a BIO into a ContentInfo object
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/pkcs7.h 25.In openssl/pkcs7.h
25.Ft int 26.Ft int
26.Fo PKCS7_final 27.Fo PKCS7_final
diff --git a/src/lib/libcrypto/man/PKCS7_get_signer_info.3 b/src/lib/libcrypto/man/PKCS7_get_signer_info.3
index 280f373ead..9edf4c63de 100644
--- a/src/lib/libcrypto/man/PKCS7_get_signer_info.3
+++ b/src/lib/libcrypto/man/PKCS7_get_signer_info.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_get_signer_info.3,v 1.1 2020/06/10 11:43:08 schwarze Exp $ 1.\" $OpenBSD: PKCS7_get_signer_info.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 10 2020 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS7_GET_SIGNER_INFO 3 18.Dt PKCS7_GET_SIGNER_INFO 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm PKCS7_get_signer_info 21.Nm PKCS7_get_signer_info
22.Nd retrieve signerInfos from a SignedData object 22.Nd retrieve signerInfos from a SignedData object
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/pkcs7.h 25.In openssl/pkcs7.h
25.Ft STACK_OF(PKCS7_SIGNER_INFO) * 26.Ft STACK_OF(PKCS7_SIGNER_INFO) *
26.Fn PKCS7_get_signer_info "PKCS7 *p7" 27.Fn PKCS7_get_signer_info "PKCS7 *p7"
diff --git a/src/lib/libcrypto/man/PKCS7_new.3 b/src/lib/libcrypto/man/PKCS7_new.3
index 151261a312..19f6f1ac81 100644
--- a/src/lib/libcrypto/man/PKCS7_new.3
+++ b/src/lib/libcrypto/man/PKCS7_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_new.3,v 1.12 2020/06/10 11:43:08 schwarze Exp $ 1.\" $OpenBSD: PKCS7_new.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 10 2020 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS7_NEW 3 18.Dt PKCS7_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -40,6 +40,7 @@
40.Nm PKCS7_ISSUER_AND_SERIAL_free 40.Nm PKCS7_ISSUER_AND_SERIAL_free
41.Nd PKCS#7 data structures 41.Nd PKCS#7 data structures
42.Sh SYNOPSIS 42.Sh SYNOPSIS
43.Lb libcrypto
43.In openssl/pkcs7.h 44.In openssl/pkcs7.h
44.Ft PKCS7 * 45.Ft PKCS7 *
45.Fn PKCS7_new void 46.Fn PKCS7_new void
diff --git a/src/lib/libcrypto/man/PKCS7_set_content.3 b/src/lib/libcrypto/man/PKCS7_set_content.3
index fa057341d5..bf0eb76786 100644
--- a/src/lib/libcrypto/man/PKCS7_set_content.3
+++ b/src/lib/libcrypto/man/PKCS7_set_content.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_set_content.3,v 1.2 2020/05/24 12:37:30 schwarze Exp $ 1.\" $OpenBSD: PKCS7_set_content.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: May 24 2020 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS7_SET_CONTENT 3 18.Dt PKCS7_SET_CONTENT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm PKCS7_content_new 22.Nm PKCS7_content_new
23.Nd set the nested contentInfo in a PKCS#7 structure 23.Nd set the nested contentInfo in a PKCS#7 structure
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/pkcs7.h 26.In openssl/pkcs7.h
26.Ft int 27.Ft int
27.Fo PKCS7_set_content 28.Fo PKCS7_set_content
diff --git a/src/lib/libcrypto/man/PKCS7_set_type.3 b/src/lib/libcrypto/man/PKCS7_set_type.3
index f414b128a2..23eefff972 100644
--- a/src/lib/libcrypto/man/PKCS7_set_type.3
+++ b/src/lib/libcrypto/man/PKCS7_set_type.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_set_type.3,v 1.2 2020/05/20 11:40:26 schwarze Exp $ 1.\" $OpenBSD: PKCS7_set_type.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: May 20 2020 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS7_SET_TYPE 3 18.Dt PKCS7_SET_TYPE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm PKCS7_set0_type_other 22.Nm PKCS7_set0_type_other
23.Nd initialize type of PKCS#7 ContentInfo 23.Nd initialize type of PKCS#7 ContentInfo
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/pkcs7.h 26.In openssl/pkcs7.h
26.Ft int 27.Ft int
27.Fo PKCS7_set_type 28.Fo PKCS7_set_type
diff --git a/src/lib/libcrypto/man/PKCS7_sign.3 b/src/lib/libcrypto/man/PKCS7_sign.3
index 37257e60fd..174b385196 100644
--- a/src/lib/libcrypto/man/PKCS7_sign.3
+++ b/src/lib/libcrypto/man/PKCS7_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_sign.3,v 1.13 2020/06/10 11:43:08 schwarze Exp $ 1.\" $OpenBSD: PKCS7_sign.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 10 2020 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt PKCS7_SIGN 3 53.Dt PKCS7_SIGN 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm PKCS7_sign 56.Nm PKCS7_sign
57.Nd create a PKCS#7 signedData structure 57.Nd create a PKCS#7 signedData structure
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/pkcs7.h 60.In openssl/pkcs7.h
60.Ft PKCS7 * 61.Ft PKCS7 *
61.Fo PKCS7_sign 62.Fo PKCS7_sign
diff --git a/src/lib/libcrypto/man/PKCS7_sign_add_signer.3 b/src/lib/libcrypto/man/PKCS7_sign_add_signer.3
index 195d6388c9..4b88ff72bd 100644
--- a/src/lib/libcrypto/man/PKCS7_sign_add_signer.3
+++ b/src/lib/libcrypto/man/PKCS7_sign_add_signer.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_sign_add_signer.3,v 1.13 2020/06/10 11:43:08 schwarze Exp $ 1.\" $OpenBSD: PKCS7_sign_add_signer.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 10 2020 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt PKCS7_SIGN_ADD_SIGNER 3 53.Dt PKCS7_SIGN_ADD_SIGNER 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm PKCS7_sign_add_signer 56.Nm PKCS7_sign_add_signer
57.Nd add a signer to a SignedData structure 57.Nd add a signer to a SignedData structure
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/pkcs7.h 60.In openssl/pkcs7.h
60.Ft PKCS7_SIGNER_INFO * 61.Ft PKCS7_SIGNER_INFO *
61.Fo PKCS7_sign_add_signer 62.Fo PKCS7_sign_add_signer
diff --git a/src/lib/libcrypto/man/PKCS7_verify.3 b/src/lib/libcrypto/man/PKCS7_verify.3
index d091c03dfd..6bf932b54b 100644
--- a/src/lib/libcrypto/man/PKCS7_verify.3
+++ b/src/lib/libcrypto/man/PKCS7_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_verify.3,v 1.11 2022/03/31 17:27:17 naddy Exp $ 1.\" $OpenBSD: PKCS7_verify.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 31 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PKCS7_VERIFY 3 52.Dt PKCS7_VERIFY 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm PKCS7_get0_signers 56.Nm PKCS7_get0_signers
57.Nd verify a PKCS#7 signedData structure 57.Nd verify a PKCS#7 signedData structure
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/pkcs7.h 60.In openssl/pkcs7.h
60.Ft int 61.Ft int
61.Fo PKCS7_verify 62.Fo PKCS7_verify
diff --git a/src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.3 b/src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.3
index 822968f58d..55eb464a33 100644
--- a/src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.3
+++ b/src/lib/libcrypto/man/PKCS8_PRIV_KEY_INFO_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS8_PRIV_KEY_INFO_new.3,v 1.7 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: PKCS8_PRIV_KEY_INFO_new.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 6 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS8_PRIV_KEY_INFO_NEW 3 18.Dt PKCS8_PRIV_KEY_INFO_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm PKCS8_PRIV_KEY_INFO_free 22.Nm PKCS8_PRIV_KEY_INFO_free
23.Nd PKCS#8 private key information 23.Nd PKCS#8 private key information
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509.h 26.In openssl/x509.h
26.Ft PKCS8_PRIV_KEY_INFO * 27.Ft PKCS8_PRIV_KEY_INFO *
27.Fn PKCS8_PRIV_KEY_INFO_new void 28.Fn PKCS8_PRIV_KEY_INFO_new void
diff --git a/src/lib/libcrypto/man/PKCS8_pkey_set0.3 b/src/lib/libcrypto/man/PKCS8_pkey_set0.3
index f3d5a294c3..a8a160d544 100644
--- a/src/lib/libcrypto/man/PKCS8_pkey_set0.3
+++ b/src/lib/libcrypto/man/PKCS8_pkey_set0.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS8_pkey_set0.3,v 1.3 2024/09/02 07:45:09 tb Exp $ 1.\" $OpenBSD: PKCS8_pkey_set0.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 2 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKCS8_PKEY_SET0 3 18.Dt PKCS8_PKEY_SET0 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm PKCS8_pkey_get0_attrs 24.Nm PKCS8_pkey_get0_attrs
25.Nd change and inspect PKCS#8 PrivateKeyInfo objects 25.Nd change and inspect PKCS#8 PrivateKeyInfo objects
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509.h 28.In openssl/x509.h
28.Ft int 29.Ft int
29.Fo PKCS8_pkey_set0 30.Fo PKCS8_pkey_set0
diff --git a/src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.3 b/src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.3
index 40735c6f86..2d4f010bce 100644
--- a/src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.3
+++ b/src/lib/libcrypto/man/PKEY_USAGE_PERIOD_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKEY_USAGE_PERIOD_new.3,v 1.5 2019/06/06 01:06:59 schwarze Exp $ 1.\" $OpenBSD: PKEY_USAGE_PERIOD_new.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt PKEY_USAGE_PERIOD_NEW 3 18.Dt PKEY_USAGE_PERIOD_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm PKEY_USAGE_PERIOD_free 22.Nm PKEY_USAGE_PERIOD_free
23.Nd X.509 certificate private key usage period extension 23.Nd X.509 certificate private key usage period extension
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft PKEY_USAGE_PERIOD * 27.Ft PKEY_USAGE_PERIOD *
27.Fn PKEY_USAGE_PERIOD_new void 28.Fn PKEY_USAGE_PERIOD_new void
diff --git a/src/lib/libcrypto/man/POLICYINFO_new.3 b/src/lib/libcrypto/man/POLICYINFO_new.3
index 52c004414e..aad2ad3ce5 100644
--- a/src/lib/libcrypto/man/POLICYINFO_new.3
+++ b/src/lib/libcrypto/man/POLICYINFO_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: POLICYINFO_new.3,v 1.11 2023/05/14 08:03:57 tb Exp $ 1.\" $OpenBSD: POLICYINFO_new.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: May 14 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt POLICYINFO_NEW 3 18.Dt POLICYINFO_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -34,6 +34,7 @@
34.Nm POLICY_CONSTRAINTS_free 34.Nm POLICY_CONSTRAINTS_free
35.Nd X.509 certificate policies 35.Nd X.509 certificate policies
36.Sh SYNOPSIS 36.Sh SYNOPSIS
37.Lb libcrypto
37.In openssl/x509v3.h 38.In openssl/x509v3.h
38.Ft POLICYINFO * 39.Ft POLICYINFO *
39.Fn POLICYINFO_new void 40.Fn POLICYINFO_new void
diff --git a/src/lib/libcrypto/man/RAND_add.3 b/src/lib/libcrypto/man/RAND_add.3
index 5404f696a3..b56707a313 100644
--- a/src/lib/libcrypto/man/RAND_add.3
+++ b/src/lib/libcrypto/man/RAND_add.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RAND_add.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: RAND_add.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" content checked up to: OpenSSL c16de9d8 Aug 31 23:16:22 2017 +0200 2.\" content checked up to: OpenSSL c16de9d8 Aug 31 23:16:22 2017 +0200
3.\" 3.\"
4.\" Copyright (c) 2014 Miod Vallat <miod@openbsd.org> 4.\" Copyright (c) 2014 Miod Vallat <miod@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 27 2018 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt RAND_ADD 3 19.Dt RAND_ADD 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -26,6 +26,7 @@
26.Nm RAND_status 26.Nm RAND_status
27.Nd manipulate the PRNG state 27.Nd manipulate the PRNG state
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/rand.h 30.In openssl/rand.h
30.Ft void 31.Ft void
31.Fo RAND_add 32.Fo RAND_add
diff --git a/src/lib/libcrypto/man/RAND_bytes.3 b/src/lib/libcrypto/man/RAND_bytes.3
index 19427a82df..ce0773f448 100644
--- a/src/lib/libcrypto/man/RAND_bytes.3
+++ b/src/lib/libcrypto/man/RAND_bytes.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RAND_bytes.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: RAND_bytes.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RAND_BYTES 3 52.Dt RAND_BYTES 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm RAND_pseudo_bytes 56.Nm RAND_pseudo_bytes
57.Nd generate random data 57.Nd generate random data
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/rand.h 60.In openssl/rand.h
60.Ft int 61.Ft int
61.Fo RAND_bytes 62.Fo RAND_bytes
diff --git a/src/lib/libcrypto/man/RAND_load_file.3 b/src/lib/libcrypto/man/RAND_load_file.3
index 9227e2721b..1c6f7a27fb 100644
--- a/src/lib/libcrypto/man/RAND_load_file.3
+++ b/src/lib/libcrypto/man/RAND_load_file.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RAND_load_file.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: RAND_load_file.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RAND_LOAD_FILE 3 52.Dt RAND_LOAD_FILE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm RAND_write_file 57.Nm RAND_write_file
58.Nd PRNG seed file 58.Nd PRNG seed file
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/rand.h 61.In openssl/rand.h
61.Ft const char * 62.Ft const char *
62.Fo RAND_file_name 63.Fo RAND_file_name
diff --git a/src/lib/libcrypto/man/RAND_set_rand_method.3 b/src/lib/libcrypto/man/RAND_set_rand_method.3
index d94d794daf..2756099c7b 100644
--- a/src/lib/libcrypto/man/RAND_set_rand_method.3
+++ b/src/lib/libcrypto/man/RAND_set_rand_method.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RAND_set_rand_method.3,v 1.4 2018/03/21 09:03:49 schwarze Exp $ 1.\" $OpenBSD: RAND_set_rand_method.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Miod Vallat <miod@openbsd.org> 3.\" Copyright (c) 2014 Miod Vallat <miod@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 21 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt RAND_SET_RAND_METHOD 3 18.Dt RAND_SET_RAND_METHOD 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm RAND_SSLeay 23.Nm RAND_SSLeay
24.Nd select RAND method 24.Nd select RAND method
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/rand.h 27.In openssl/rand.h
27.Ft int 28.Ft int
28.Fo RAND_set_rand_method 29.Fo RAND_set_rand_method
diff --git a/src/lib/libcrypto/man/RC2_encrypt.3 b/src/lib/libcrypto/man/RC2_encrypt.3
index a90e0f574b..735c10cbd7 100644
--- a/src/lib/libcrypto/man/RC2_encrypt.3
+++ b/src/lib/libcrypto/man/RC2_encrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RC2_encrypt.3,v 1.2 2024/12/18 04:15:48 jsg Exp $ 1.\" $OpenBSD: RC2_encrypt.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 18 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt RC2_ENCRYPT 3 18.Dt RC2_ENCRYPT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.Nm RC2_ofb64_encrypt 27.Nm RC2_ofb64_encrypt
28.Nd low-level functions for Rivest Cipher 2 28.Nd low-level functions for Rivest Cipher 2
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/rc2.h 31.In openssl/rc2.h
31.Ft void 32.Ft void
32.Fo RC2_set_key 33.Fo RC2_set_key
diff --git a/src/lib/libcrypto/man/RC4.3 b/src/lib/libcrypto/man/RC4.3
index 8b20a434b7..ff92cffc78 100644
--- a/src/lib/libcrypto/man/RC4.3
+++ b/src/lib/libcrypto/man/RC4.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RC4.3,v 1.8 2020/03/29 17:05:02 schwarze Exp $ 1.\" $OpenBSD: RC4.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 29 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RC4 3 52.Dt RC4 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm RC4 56.Nm RC4
57.Nd RC4 encryption 57.Nd RC4 encryption
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/rc4.h 60.In openssl/rc4.h
60.Ft void 61.Ft void
61.Fo RC4_set_key 62.Fo RC4_set_key
diff --git a/src/lib/libcrypto/man/RIPEMD160.3 b/src/lib/libcrypto/man/RIPEMD160.3
index 43c6694036..e22f4ed841 100644
--- a/src/lib/libcrypto/man/RIPEMD160.3
+++ b/src/lib/libcrypto/man/RIPEMD160.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RIPEMD160.3,v 1.8 2024/05/26 09:54:16 tb Exp $ 1.\" $OpenBSD: RIPEMD160.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000 2.\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 26 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RIPEMD160 3 52.Dt RIPEMD160 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm RIPEMD160_Final 58.Nm RIPEMD160_Final
59.Nd RIPEMD-160 hash function 59.Nd RIPEMD-160 hash function
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/ripemd.h 62.In openssl/ripemd.h
62.Ft unsigned char * 63.Ft unsigned char *
63.Fo RIPEMD160 64.Fo RIPEMD160
diff --git a/src/lib/libcrypto/man/RSA_PSS_PARAMS_new.3 b/src/lib/libcrypto/man/RSA_PSS_PARAMS_new.3
index f69f33dbe5..6532028a57 100644
--- a/src/lib/libcrypto/man/RSA_PSS_PARAMS_new.3
+++ b/src/lib/libcrypto/man/RSA_PSS_PARAMS_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_PSS_PARAMS_new.3,v 1.4 2019/06/06 01:06:59 schwarze Exp $ 1.\" $OpenBSD: RSA_PSS_PARAMS_new.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt RSA_PSS_PARAMS_NEW 3 18.Dt RSA_PSS_PARAMS_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm RSA_PSS_PARAMS_free 22.Nm RSA_PSS_PARAMS_free
23.Nd probabilistic signature scheme with RSA hashing 23.Nd probabilistic signature scheme with RSA hashing
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/rsa.h 26.In openssl/rsa.h
26.Ft RSA_PSS_PARAMS * 27.Ft RSA_PSS_PARAMS *
27.Fn RSA_PSS_PARAMS_new void 28.Fn RSA_PSS_PARAMS_new void
diff --git a/src/lib/libcrypto/man/RSA_blinding_on.3 b/src/lib/libcrypto/man/RSA_blinding_on.3
index bd2a301377..0dfebf3739 100644
--- a/src/lib/libcrypto/man/RSA_blinding_on.3
+++ b/src/lib/libcrypto/man/RSA_blinding_on.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_blinding_on.3,v 1.7 2023/07/26 20:08:59 tb Exp $ 1.\" $OpenBSD: RSA_blinding_on.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 26 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RSA_BLINDING_ON 3 52.Dt RSA_BLINDING_ON 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm RSA_blinding_off 56.Nm RSA_blinding_off
57.Nd protect the RSA operation from timing attacks 57.Nd protect the RSA operation from timing attacks
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/rsa.h 60.In openssl/rsa.h
60.Ft int 61.Ft int
61.Fo RSA_blinding_on 62.Fo RSA_blinding_on
diff --git a/src/lib/libcrypto/man/RSA_check_key.3 b/src/lib/libcrypto/man/RSA_check_key.3
index 36b613b3a5..b6c9bc20a1 100644
--- a/src/lib/libcrypto/man/RSA_check_key.3
+++ b/src/lib/libcrypto/man/RSA_check_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_check_key.3,v 1.10 2023/11/19 21:06:15 tb Exp $ 1.\" $OpenBSD: RSA_check_key.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: November 19 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt RSA_CHECK_KEY 3 53.Dt RSA_CHECK_KEY 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm RSA_check_key 56.Nm RSA_check_key
57.Nd validate private RSA keys 57.Nd validate private RSA keys
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/rsa.h 60.In openssl/rsa.h
60.Ft int 61.Ft int
61.Fo RSA_check_key 62.Fo RSA_check_key
diff --git a/src/lib/libcrypto/man/RSA_generate_key.3 b/src/lib/libcrypto/man/RSA_generate_key.3
index 83703b1eaa..a72168def9 100644
--- a/src/lib/libcrypto/man/RSA_generate_key.3
+++ b/src/lib/libcrypto/man/RSA_generate_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_generate_key.3,v 1.13 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: RSA_generate_key.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL RSA_generate_key.pod bb6c5e7f Feb 5 10:29:22 2017 -0500 2.\" OpenSSL RSA_generate_key.pod bb6c5e7f Feb 5 10:29:22 2017 -0500
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 10 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RSA_GENERATE_KEY 3 52.Dt RSA_GENERATE_KEY 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm RSA_generate_key 56.Nm RSA_generate_key
57.Nd generate RSA key pair 57.Nd generate RSA key pair
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/rsa.h 60.In openssl/rsa.h
60.Ft int 61.Ft int
61.Fo RSA_generate_key_ex 62.Fo RSA_generate_key_ex
diff --git a/src/lib/libcrypto/man/RSA_get0_key.3 b/src/lib/libcrypto/man/RSA_get0_key.3
index f09fb00d2b..cf82b21ce2 100644
--- a/src/lib/libcrypto/man/RSA_get0_key.3
+++ b/src/lib/libcrypto/man/RSA_get0_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_get0_key.3,v 1.8 2025/01/05 15:40:42 tb Exp $ 1.\" $OpenBSD: RSA_get0_key.3,v 1.10 2025/06/13 18:34:00 schwarze Exp $
2.\" selective merge up to: OpenSSL 665d899f Aug 2 02:19:43 2017 +0800 2.\" selective merge up to: OpenSSL 665d899f Aug 2 02:19:43 2017 +0800
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: January 5 2025 $ 68.Dd $Mdocdate: June 13 2025 $
69.Dt RSA_GET0_KEY 3 69.Dt RSA_GET0_KEY 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -88,6 +88,7 @@
88.Nm RSA_set_flags 88.Nm RSA_set_flags
89.Nd get and set data in an RSA object 89.Nd get and set data in an RSA object
90.Sh SYNOPSIS 90.Sh SYNOPSIS
91.Lb libcrypto
91.In openssl/rsa.h 92.In openssl/rsa.h
92.Ft void 93.Ft void
93.Fo RSA_get0_key 94.Fo RSA_get0_key
@@ -96,15 +97,15 @@
96.Fa "const BIGNUM **e" 97.Fa "const BIGNUM **e"
97.Fa "const BIGNUM **d" 98.Fa "const BIGNUM **d"
98.Fc 99.Fc
99.Ft "const BIGNUM *" 100.Ft const BIGNUM *
100.Fo RSA_get0_n 101.Fo RSA_get0_n
101.Fa "const RSA *r" 102.Fa "const RSA *r"
102.Fc 103.Fc
103.Ft "const BIGNUM *" 104.Ft const BIGNUM *
104.Fo RSA_get0_e 105.Fo RSA_get0_e
105.Fa "const RSA *r" 106.Fa "const RSA *r"
106.Fc 107.Fc
107.Ft "const BIGNUM *" 108.Ft const BIGNUM *
108.Fo RSA_get0_d 109.Fo RSA_get0_d
109.Fa "const RSA *r" 110.Fa "const RSA *r"
110.Fc 111.Fc
@@ -121,11 +122,11 @@
121.Fa "const BIGNUM **p" 122.Fa "const BIGNUM **p"
122.Fa "const BIGNUM **q" 123.Fa "const BIGNUM **q"
123.Fc 124.Fc
124.Ft "const BIGNUM *" 125.Ft const BIGNUM *
125.Fo RSA_get0_p 126.Fo RSA_get0_p
126.Fa "const RSA *r" 127.Fa "const RSA *r"
127.Fc 128.Fc
128.Ft "const BIGNUM *" 129.Ft const BIGNUM *
129.Fo RSA_get0_q 130.Fo RSA_get0_q
130.Fa "const RSA *r" 131.Fa "const RSA *r"
131.Fc 132.Fc
@@ -142,15 +143,15 @@
142.Fa "const BIGNUM **dmq1" 143.Fa "const BIGNUM **dmq1"
143.Fa "const BIGNUM **iqmp" 144.Fa "const BIGNUM **iqmp"
144.Fc 145.Fc
145.Ft "const BIGNUM *" 146.Ft const BIGNUM *
146.Fo RSA_get0_dmp1 147.Fo RSA_get0_dmp1
147.Fa "const RSA *r" 148.Fa "const RSA *r"
148.Fc 149.Fc
149.Ft "const BIGNUM *" 150.Ft const BIGNUM *
150.Fo RSA_get0_dmq1 151.Fo RSA_get0_dmq1
151.Fa "const RSA *r" 152.Fa "const RSA *r"
152.Fc 153.Fc
153.Ft "const BIGNUM *" 154.Ft const BIGNUM *
154.Fo RSA_get0_iqmp 155.Fo RSA_get0_iqmp
155.Fa "const RSA *r" 156.Fa "const RSA *r"
156.Fc 157.Fc
diff --git a/src/lib/libcrypto/man/RSA_get_ex_new_index.3 b/src/lib/libcrypto/man/RSA_get_ex_new_index.3
index 5f1fb4335f..1b7096faa1 100644
--- a/src/lib/libcrypto/man/RSA_get_ex_new_index.3
+++ b/src/lib/libcrypto/man/RSA_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_get_ex_new_index.3,v 1.13 2023/11/19 21:08:04 tb Exp $ 1.\" $OpenBSD: RSA_get_ex_new_index.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 19 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt RSA_GET_EX_NEW_INDEX 3 18.Dt RSA_GET_EX_NEW_INDEX 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm RSA_get_ex_data 23.Nm RSA_get_ex_data
24.Nd add application specific data to RSA objects 24.Nd add application specific data to RSA objects
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/rsa.h 27.In openssl/rsa.h
27.Ft int 28.Ft int
28.Fo RSA_get_ex_new_index 29.Fo RSA_get_ex_new_index
diff --git a/src/lib/libcrypto/man/RSA_meth_new.3 b/src/lib/libcrypto/man/RSA_meth_new.3
index a3a5c549e5..9626f1139f 100644
--- a/src/lib/libcrypto/man/RSA_meth_new.3
+++ b/src/lib/libcrypto/man/RSA_meth_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_meth_new.3,v 1.6 2025/01/05 15:40:42 tb Exp $ 1.\" $OpenBSD: RSA_meth_new.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL a970b14f Jul 31 18:58:40 2017 -0400 2.\" full merge up to: OpenSSL a970b14f Jul 31 18:58:40 2017 -0400
3.\" selective merge up to: OpenSSL 24907560 Sep 17 07:47:42 2018 +1000 3.\" selective merge up to: OpenSSL 24907560 Sep 17 07:47:42 2018 +1000
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: January 5 2025 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt RSA_METH_NEW 3 70.Dt RSA_METH_NEW 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -103,6 +103,7 @@
103.Nm RSA_meth_set_keygen 103.Nm RSA_meth_set_keygen
104.Nd build up RSA methods 104.Nd build up RSA methods
105.Sh SYNOPSIS 105.Sh SYNOPSIS
106.Lb libcrypto
106.In openssl/rsa.h 107.In openssl/rsa.h
107.Ft RSA_METHOD * 108.Ft RSA_METHOD *
108.Fo RSA_meth_new 109.Fo RSA_meth_new
diff --git a/src/lib/libcrypto/man/RSA_new.3 b/src/lib/libcrypto/man/RSA_new.3
index f5c7929e77..9c69ce27b1 100644
--- a/src/lib/libcrypto/man/RSA_new.3
+++ b/src/lib/libcrypto/man/RSA_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_new.3,v 1.18 2023/11/19 21:03:22 tb Exp $ 1.\" $OpenBSD: RSA_new.3,v 1.19 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL doc/man3/RSA_new.pod e9b77246 Jan 20 19:58:49 2017 +0100 3.\" OpenSSL doc/man3/RSA_new.pod e9b77246 Jan 20 19:58:49 2017 +0100
4.\" OpenSSL doc/crypto/rsa.pod 35d2e327 Jun 3 16:19:49 2016 -0400 (final) 4.\" OpenSSL doc/crypto/rsa.pod 35d2e327 Jun 3 16:19:49 2016 -0400 (final)
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: November 19 2023 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt RSA_NEW 3 71.Dt RSA_NEW 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -78,6 +78,7 @@
78.Nm RSA_free 78.Nm RSA_free
79.Nd allocate and free RSA objects 79.Nd allocate and free RSA objects
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/rsa.h 82.In openssl/rsa.h
82.Ft RSA * 83.Ft RSA *
83.Fn RSA_new void 84.Fn RSA_new void
diff --git a/src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3 b/src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3
index e7c3a2a624..d8a142f3f9 100644
--- a/src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3
+++ b/src/lib/libcrypto/man/RSA_padding_add_PKCS1_type_1.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_padding_add_PKCS1_type_1.3,v 1.8 2018/03/21 16:09:51 schwarze Exp $ 1.\" $OpenBSD: RSA_padding_add_PKCS1_type_1.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 1e3f62a3 Jul 17 16:47:13 2017 +0200 2.\" OpenSSL 1e3f62a3 Jul 17 16:47:13 2017 +0200
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 21 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RSA_PADDING_ADD_PKCS1_TYPE_1 3 52.Dt RSA_PADDING_ADD_PKCS1_TYPE_1 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -62,6 +62,7 @@
62.Nm RSA_padding_check_none 62.Nm RSA_padding_check_none
63.Nd asymmetric encryption padding 63.Nd asymmetric encryption padding
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libcrypto
65.In openssl/rsa.h 66.In openssl/rsa.h
66.Ft int 67.Ft int
67.Fo RSA_padding_add_PKCS1_type_1 68.Fo RSA_padding_add_PKCS1_type_1
diff --git a/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3 b/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
index 3d4e79cc47..ca805e5191 100644
--- a/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
+++ b/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_pkey_ctx_ctrl.3,v 1.8 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: RSA_pkey_ctx_ctrl.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/EVP_PKEY_CTX_ctrl.pod 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" OpenSSL man3/EVP_PKEY_CTX_ctrl.pod 99d63d46 Oct 26 13:56:48 2016 -0400
4.\" OpenSSL man3/EVP_PKEY_CTX_set_rsa_pss_keygen_md.pod 4.\" OpenSSL man3/EVP_PKEY_CTX_set_rsa_pss_keygen_md.pod
@@ -55,7 +55,7 @@
55.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 55.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
56.\" OF THE POSSIBILITY OF SUCH DAMAGE. 56.\" OF THE POSSIBILITY OF SUCH DAMAGE.
57.\" 57.\"
58.Dd $Mdocdate: December 6 2024 $ 58.Dd $Mdocdate: June 8 2025 $
59.Dt RSA_PKEY_CTX_CTRL 3 59.Dt RSA_PKEY_CTX_CTRL 3
60.Os 60.Os
61.Sh NAME 61.Sh NAME
@@ -77,6 +77,7 @@
77.Nm EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen 77.Nm EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen
78.Nd RSA private key control operations 78.Nd RSA private key control operations
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libcrypto
80.In openssl/rsa.h 81.In openssl/rsa.h
81.Ft int 82.Ft int
82.Fo RSA_pkey_ctx_ctrl 83.Fo RSA_pkey_ctx_ctrl
diff --git a/src/lib/libcrypto/man/RSA_print.3 b/src/lib/libcrypto/man/RSA_print.3
index 767241ce1c..3f5d927b79 100644
--- a/src/lib/libcrypto/man/RSA_print.3
+++ b/src/lib/libcrypto/man/RSA_print.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_print.3,v 1.9 2019/06/06 01:06:59 schwarze Exp $ 1.\" $OpenBSD: RSA_print.3,v 1.10 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 6 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RSA_PRINT 3 52.Dt RSA_PRINT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -62,6 +62,7 @@
62.Nm DHparams_print_fp 62.Nm DHparams_print_fp
63.Nd print cryptographic parameters 63.Nd print cryptographic parameters
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libcrypto
65.In openssl/rsa.h 66.In openssl/rsa.h
66.Ft int 67.Ft int
67.Fo RSA_print 68.Fo RSA_print
diff --git a/src/lib/libcrypto/man/RSA_private_encrypt.3 b/src/lib/libcrypto/man/RSA_private_encrypt.3
index 2bf6c57dba..43e94b1fd2 100644
--- a/src/lib/libcrypto/man/RSA_private_encrypt.3
+++ b/src/lib/libcrypto/man/RSA_private_encrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_private_encrypt.3,v 1.10 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: RSA_private_encrypt.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL RSA_private_encrypt.pod b41f6b64 Mar 10 15:49:04 2017 +0000 2.\" OpenSSL RSA_private_encrypt.pod b41f6b64 Mar 10 15:49:04 2017 +0000
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 10 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RSA_PRIVATE_ENCRYPT 3 52.Dt RSA_PRIVATE_ENCRYPT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm RSA_public_decrypt 56.Nm RSA_public_decrypt
57.Nd low level signature operations 57.Nd low level signature operations
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/rsa.h 60.In openssl/rsa.h
60.Ft int 61.Ft int
61.Fo RSA_private_encrypt 62.Fo RSA_private_encrypt
diff --git a/src/lib/libcrypto/man/RSA_public_encrypt.3 b/src/lib/libcrypto/man/RSA_public_encrypt.3
index be3afdf402..f40118846a 100644
--- a/src/lib/libcrypto/man/RSA_public_encrypt.3
+++ b/src/lib/libcrypto/man/RSA_public_encrypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_public_encrypt.3,v 1.13 2023/09/10 16:04:15 schwarze Exp $ 1.\" $OpenBSD: RSA_public_encrypt.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL RSA_public_encrypt.pod 1e3f62a3 Jul 17 16:47:13 2017 +0200 2.\" OpenSSL RSA_public_encrypt.pod 1e3f62a3 Jul 17 16:47:13 2017 +0200
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: September 10 2023 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt RSA_PUBLIC_ENCRYPT 3 69.Dt RSA_PUBLIC_ENCRYPT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -75,6 +75,7 @@
75.Nm EVP_PKEY_decrypt_old 75.Nm EVP_PKEY_decrypt_old
76.Nd RSA public key cryptography 76.Nd RSA public key cryptography
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/rsa.h 79.In openssl/rsa.h
79.Ft int 80.Ft int
80.Fo RSA_public_encrypt 81.Fo RSA_public_encrypt
diff --git a/src/lib/libcrypto/man/RSA_security_bits.3 b/src/lib/libcrypto/man/RSA_security_bits.3
index f7024a7956..0766ce61b1 100644
--- a/src/lib/libcrypto/man/RSA_security_bits.3
+++ b/src/lib/libcrypto/man/RSA_security_bits.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_security_bits.3,v 1.1 2022/07/13 17:32:16 schwarze Exp $ 1.\" $OpenBSD: RSA_security_bits.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 13 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt RSA_SECURITY_BITS 3 18.Dt RSA_SECURITY_BITS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm BN_security_bits 24.Nm BN_security_bits
25.Nd get security strength 25.Nd get security strength
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/rsa.h 28.In openssl/rsa.h
28.Ft int 29.Ft int
29.Fn RSA_security_bits "const RSA *rsa" 30.Fn RSA_security_bits "const RSA *rsa"
diff --git a/src/lib/libcrypto/man/RSA_set_method.3 b/src/lib/libcrypto/man/RSA_set_method.3
index ffe22c116f..127dc62c60 100644
--- a/src/lib/libcrypto/man/RSA_set_method.3
+++ b/src/lib/libcrypto/man/RSA_set_method.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_set_method.3,v 1.18 2023/11/19 10:34:26 tb Exp $ 1.\" $OpenBSD: RSA_set_method.3,v 1.19 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> 4.\" This file was written by Ulf Moeller <ulf@openssl.org>
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: November 19 2023 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt RSA_SET_METHOD 3 54.Dt RSA_SET_METHOD 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -63,6 +63,7 @@
63.Nm RSA_new_method 63.Nm RSA_new_method
64.Nd select RSA method 64.Nd select RSA method
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libcrypto
66.In openssl/rsa.h 67.In openssl/rsa.h
67.Ft void 68.Ft void
68.Fo RSA_set_default_method 69.Fo RSA_set_default_method
diff --git a/src/lib/libcrypto/man/RSA_sign.3 b/src/lib/libcrypto/man/RSA_sign.3
index 888e36a680..d2a4512302 100644
--- a/src/lib/libcrypto/man/RSA_sign.3
+++ b/src/lib/libcrypto/man/RSA_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_sign.3,v 1.9 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: RSA_sign.3,v 1.10 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL aa90ca11 Aug 20 15:48:56 2016 -0400 2.\" OpenSSL aa90ca11 Aug 20 15:48:56 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 17 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt RSA_SIGN 3 53.Dt RSA_SIGN 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm RSA_verify 57.Nm RSA_verify
58.Nd RSA signatures 58.Nd RSA signatures
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/rsa.h 61.In openssl/rsa.h
61.Ft int 62.Ft int
62.Fo RSA_sign 63.Fo RSA_sign
diff --git a/src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3 b/src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3
index 34aef42c48..bd11a0607a 100644
--- a/src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3
+++ b/src/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_sign_ASN1_OCTET_STRING.3,v 1.7 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: RSA_sign_ASN1_OCTET_STRING.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 10 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt RSA_SIGN_ASN1_OCTET_STRING 3 52.Dt RSA_SIGN_ASN1_OCTET_STRING 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm RSA_verify_ASN1_OCTET_STRING 56.Nm RSA_verify_ASN1_OCTET_STRING
57.Nd RSA signatures 57.Nd RSA signatures
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/rsa.h 60.In openssl/rsa.h
60.Ft int 61.Ft int
61.Fo RSA_sign_ASN1_OCTET_STRING 62.Fo RSA_sign_ASN1_OCTET_STRING
diff --git a/src/lib/libcrypto/man/RSA_size.3 b/src/lib/libcrypto/man/RSA_size.3
index 8a552b4e67..9988903d55 100644
--- a/src/lib/libcrypto/man/RSA_size.3
+++ b/src/lib/libcrypto/man/RSA_size.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: RSA_size.3,v 1.10 2022/07/13 21:51:35 schwarze Exp $ 1.\" $OpenBSD: RSA_size.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: July 13 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt RSA_SIZE 3 53.Dt RSA_SIZE 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm RSA_bits 57.Nm RSA_bits
58.Nd get the RSA modulus size 58.Nd get the RSA modulus size
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/rsa.h 61.In openssl/rsa.h
61.Ft int 62.Ft int
62.Fo RSA_size 63.Fo RSA_size
diff --git a/src/lib/libcrypto/man/SHA1.3 b/src/lib/libcrypto/man/SHA1.3
index 4ccb08157c..74fd388cd8 100644
--- a/src/lib/libcrypto/man/SHA1.3
+++ b/src/lib/libcrypto/man/SHA1.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SHA1.3,v 1.9 2024/06/01 12:35:23 tb Exp $ 1.\" $OpenBSD: SHA1.3,v 1.10 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 1 2024 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SHA1 3 53.Dt SHA1 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -75,6 +75,7 @@
75.Nm SHA512_Final 75.Nm SHA512_Final
76.Nd Secure Hash Algorithm 76.Nd Secure Hash Algorithm
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/sha.h 79.In openssl/sha.h
79.Ft unsigned char * 80.Ft unsigned char *
80.Fo SHA1 81.Fo SHA1
diff --git a/src/lib/libcrypto/man/SMIME_crlf_copy.3 b/src/lib/libcrypto/man/SMIME_crlf_copy.3
index 3b46138473..0991d207a1 100644
--- a/src/lib/libcrypto/man/SMIME_crlf_copy.3
+++ b/src/lib/libcrypto/man/SMIME_crlf_copy.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SMIME_crlf_copy.3,v 1.3 2023/05/01 07:28:11 tb Exp $ 1.\" $OpenBSD: SMIME_crlf_copy.3,v 1.5 2025/06/11 13:48:54 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,15 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: May 1 2023 $ 17.Dd $Mdocdate: June 11 2025 $
18.Dt SMIME_CRLF_COPY 3 18.Dt SMIME_CRLF_COPY 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SMIME_crlf_copy 21.Nm SMIME_crlf_copy
22.Nd buffered copy between BIOs 22.Nd buffered copy between BIOs
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
25.In openssl/asn1.h
24.Ft int 26.Ft int
25.Fo SMIME_crlf_copy 27.Fo SMIME_crlf_copy
26.Fa "BIO *in_bio" 28.Fa "BIO *in_bio"
@@ -79,7 +81,8 @@ is intended to return 1 on success or 0 on failure.
79.Xr BIO_push 3 , 81.Xr BIO_push 3 ,
80.Xr BIO_read 3 , 82.Xr BIO_read 3 ,
81.Xr SMIME_text 3 , 83.Xr SMIME_text 3 ,
82.Xr SMIME_write_ASN1 3 84.Xr SMIME_write_CMS 3 ,
85.Xr SMIME_write_PKCS7 3
83.Sh HISTORY 86.Sh HISTORY
84.Fn SMIME_crlf_copy 87.Fn SMIME_crlf_copy
85first appeared in OpenSSL 1.0.0 and has been available since 88first appeared in OpenSSL 1.0.0 and has been available since
diff --git a/src/lib/libcrypto/man/SMIME_read_ASN1.3 b/src/lib/libcrypto/man/SMIME_read_ASN1.3
deleted file mode 100644
index 320064567c..0000000000
--- a/src/lib/libcrypto/man/SMIME_read_ASN1.3
+++ /dev/null
@@ -1,124 +0,0 @@
1.\" $OpenBSD: SMIME_read_ASN1.3,v 1.2 2021/12/14 15:22:49 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL SMIME_read_PKCS7.pod 83cf7abf May 29 13:07:08 2018 +0100
4.\" OpenSSL SMIME_read_CMS.pod b97fdb57 Nov 11 09:33:09 2016 +0100
5.\"
6.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
7.\" Copyright (c) 2002, 2006, 2008 The OpenSSL Project. All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\" notice, this list of conditions and the following disclaimer in
18.\" the documentation and/or other materials provided with the
19.\" distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\" software must display the following acknowledgment:
23.\" "This product includes software developed by the OpenSSL Project
24.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\" endorse or promote products derived from this software without
28.\" prior written permission. For written permission, please contact
29.\" openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\" nor may "OpenSSL" appear in their names without prior written
33.\" permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\" acknowledgment:
37.\" "This product includes software developed by the OpenSSL Project
38.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: December 14 2021 $
54.Dt SMIME_READ_ASN1 3
55.Os
56.Sh NAME
57.Nm SMIME_read_ASN1
58.Nd generic S/MIME message parser
59.Sh SYNOPSIS
60.In openssl/asn1.h
61.Ft ASN1_VALUE *
62.Fo SMIME_read_ASN1
63.Fa "BIO *in_bio"
64.Fa "BIO **out_bio"
65.Fa "const ASN1_ITEM *it"
66.Fc
67.Sh DESCRIPTION
68.Fn SMIME_read_ASN1
69reads a message in S/MIME format from
70.Fa in_bio .
71.Pp
72If the message uses cleartext signing, the content is saved in a memory
73.Vt BIO
74which is written to
75.Pf * Fa out_bio .
76Otherwise,
77.Pf * Fa out_bio
78is set to
79.Dv NULL .
80.Pp
81To support future functionality, if
82.Fa out_bio
83is not
84.Dv NULL ,
85.Pf * Fa out_bio
86should be initialized to
87.Dv NULL
88before calling
89.Fn SMIME_read_ASN1 .
90.Sh RETURN VALUES
91.Fn SMIME_read_ASN1
92returns a newly allocated object of type
93.Fa it
94or
95.Dv NULL
96if an error occurred.
97The error can be obtained from
98.Xr ERR_get_error 3 .
99.Sh SEE ALSO
100.Xr ASN1_item_d2i_bio 3 ,
101.Xr BIO_f_base64 3 ,
102.Xr BIO_new 3 ,
103.Xr SMIME_read_CMS 3 ,
104.Xr SMIME_read_PKCS7 3 ,
105.Xr SMIME_text 3
106.Sh HISTORY
107.Fn SMIME_read_ASN1
108first appeared in OpenSSL 0.9.8h and has been available since
109.Ox 4.5 .
110.Sh BUGS
111The MIME parser used by
112.Fn SMIME_read_ASN1
113is somewhat primitive.
114While it will handle most S/MIME messages, more complex compound
115formats may not work.
116.Pp
117The parser assumes that the
118structure is always base64 encoded, and it will not handle the case
119where it is in binary format or uses quoted printable format.
120.Pp
121The use of a memory
122to hold the signed content limits the size of the message which can
123be processed due to memory restraints: a streaming single pass
124option should be available.
diff --git a/src/lib/libcrypto/man/SMIME_read_CMS.3 b/src/lib/libcrypto/man/SMIME_read_CMS.3
index e1b1d07499..d37769e5ea 100644
--- a/src/lib/libcrypto/man/SMIME_read_CMS.3
+++ b/src/lib/libcrypto/man/SMIME_read_CMS.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SMIME_read_CMS.3,v 1.7 2021/12/14 14:30:50 schwarze Exp $ 1.\" $OpenBSD: SMIME_read_CMS.3,v 1.9 2025/06/11 13:41:03 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 14 2021 $ 51.Dd $Mdocdate: June 11 2025 $
52.Dt SMIME_READ_CMS 3 52.Dt SMIME_READ_CMS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SMIME_read_CMS 55.Nm SMIME_read_CMS
56.Nd extract CMS ContentInfo from an S/MIME message 56.Nd extract CMS ContentInfo from an S/MIME message
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft CMS_ContentInfo * 60.Ft CMS_ContentInfo *
60.Fo SMIME_read_CMS 61.Fo SMIME_read_CMS
@@ -103,12 +104,15 @@ if an error occurred.
103The error can be obtained from 104The error can be obtained from
104.Xr ERR_get_error 3 . 105.Xr ERR_get_error 3 .
105.Sh SEE ALSO 106.Sh SEE ALSO
107.Xr BIO_f_base64 3 ,
108.Xr BIO_new 3 ,
106.Xr CMS_ContentInfo_new 3 , 109.Xr CMS_ContentInfo_new 3 ,
107.Xr CMS_decrypt 3 , 110.Xr CMS_decrypt 3 ,
108.Xr CMS_get0_type 3 , 111.Xr CMS_get0_type 3 ,
109.Xr CMS_verify 3 , 112.Xr CMS_verify 3 ,
110.Xr d2i_CMS_ContentInfo 3 , 113.Xr d2i_CMS_ContentInfo 3 ,
111.Xr SMIME_read_ASN1 3 , 114.Xr SMIME_read_PKCS7 3 ,
115.Xr SMIME_text 3 ,
112.Xr SMIME_write_CMS 3 116.Xr SMIME_write_CMS 3
113.Sh HISTORY 117.Sh HISTORY
114.Fn SMIME_read_CMS 118.Fn SMIME_read_CMS
diff --git a/src/lib/libcrypto/man/SMIME_read_PKCS7.3 b/src/lib/libcrypto/man/SMIME_read_PKCS7.3
index dbe2765b8b..095115c0dc 100644
--- a/src/lib/libcrypto/man/SMIME_read_PKCS7.3
+++ b/src/lib/libcrypto/man/SMIME_read_PKCS7.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SMIME_read_PKCS7.3,v 1.8 2021/12/14 14:30:50 schwarze Exp $ 1.\" $OpenBSD: SMIME_read_PKCS7.3,v 1.10 2025/06/11 13:41:03 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 14 2021 $ 51.Dd $Mdocdate: June 11 2025 $
52.Dt SMIME_READ_PKCS7 3 52.Dt SMIME_READ_PKCS7 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SMIME_read_PKCS7 55.Nm SMIME_read_PKCS7
56.Nd extract a PKCS#7 object from an S/MIME message 56.Nd extract a PKCS#7 object from an S/MIME message
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/pkcs7.h 59.In openssl/pkcs7.h
59.Ft PKCS7 * 60.Ft PKCS7 *
60.Fo SMIME_read_PKCS7 61.Fo SMIME_read_PKCS7
@@ -124,8 +125,11 @@ if an error occurred.
124The error can be obtained from 125The error can be obtained from
125.Xr ERR_get_error 3 . 126.Xr ERR_get_error 3 .
126.Sh SEE ALSO 127.Sh SEE ALSO
128.Xr BIO_f_base64 3 ,
129.Xr BIO_new 3 ,
127.Xr PKCS7_new 3 , 130.Xr PKCS7_new 3 ,
128.Xr SMIME_read_ASN1 3 , 131.Xr SMIME_read_CMS 3 ,
132.Xr SMIME_text 3 ,
129.Xr SMIME_write_PKCS7 3 133.Xr SMIME_write_PKCS7 3
130.Sh HISTORY 134.Sh HISTORY
131.Fn SMIME_read_PKCS7 135.Fn SMIME_read_PKCS7
diff --git a/src/lib/libcrypto/man/SMIME_text.3 b/src/lib/libcrypto/man/SMIME_text.3
index a4c9689925..719b3d921f 100644
--- a/src/lib/libcrypto/man/SMIME_text.3
+++ b/src/lib/libcrypto/man/SMIME_text.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SMIME_text.3,v 1.1 2021/12/14 15:22:49 schwarze Exp $ 1.\" $OpenBSD: SMIME_text.3,v 1.3 2025/06/11 13:48:54 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 14 2021 $ 17.Dd $Mdocdate: June 11 2025 $
18.Dt SMIME_TEXT 3 18.Dt SMIME_TEXT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SMIME_text 21.Nm SMIME_text
22.Nd remove text/plain MIME headers 22.Nd remove text/plain MIME headers
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/asn1.h 25.In openssl/asn1.h
25.Ft int 26.Ft int
26.Fo SMIME_text 27.Fo SMIME_text
@@ -47,7 +48,10 @@ header, or if the content type is not
47.Dq text/plain . 48.Dq text/plain .
48.Sh SEE ALSO 49.Sh SEE ALSO
49.Xr SMIME_crlf_copy 3 , 50.Xr SMIME_crlf_copy 3 ,
50.Xr SMIME_read_ASN1 3 51.Xr SMIME_read_CMS 3 ,
52.Xr SMIME_read_PKCS7 3 ,
53.Xr SMIME_write_CMS 3 ,
54.Xr SMIME_write_PKCS7 3
51.Sh HISTORY 55.Sh HISTORY
52.Fn SMIME_text 56.Fn SMIME_text
53first appeared in OpenSSL 1.0.0 and has been available since 57first appeared in OpenSSL 1.0.0 and has been available since
diff --git a/src/lib/libcrypto/man/SMIME_write_ASN1.3 b/src/lib/libcrypto/man/SMIME_write_ASN1.3
deleted file mode 100644
index a02fa58570..0000000000
--- a/src/lib/libcrypto/man/SMIME_write_ASN1.3
+++ /dev/null
@@ -1,163 +0,0 @@
1.\" $OpenBSD: SMIME_write_ASN1.3,v 1.2 2023/05/01 07:28:11 tb Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 1 2023 $
18.Dt SMIME_WRITE_ASN1 3
19.Os
20.Sh NAME
21.Nm SMIME_write_ASN1
22.Nd generate an S/MIME message
23.Sh SYNOPSIS
24.In openssl/asn1.h
25.Ft int
26.Fo SMIME_write_ASN1
27.Fa "BIO *out_bio"
28.Fa "ASN1_VALUE *val_in"
29.Fa "BIO *in_bio"
30.Fa "int flags"
31.Fa "int ctype_nid"
32.Fa "int econt_nid"
33.Fa "STACK_OF(X509_ALGOR) *micalg"
34.Fa "const ASN1_ITEM *it"
35.Fc
36.Sh DESCRIPTION
37.Fn SMIME_write_ASN1
38generates an S/MIME message on
39.Fa out_bio
40by writing MIME 1.0 headers
41followed by a BER- and base64-encoded serialization of
42.Fa val_in ,
43which can be of the type
44.Vt CMS_ContentInfo
45or
46.Vt PKCS7
47and has to match the
48.Fa it
49argument.
50.Pp
51The
52.Fa flags
53can be the logical OR of zero or more of the following bits:
54.Bl -tag -width Ds
55.It Dv PKCS7_REUSE_DIGEST
56Skip the calls to
57.Xr PKCS7_dataInit 3
58and
59.Xr PKCS7_dataFinal 3 .
60This flag has no effect unless
61.Dv SMIME_DETACHED
62is also set.
63It is normally used if
64.Fa out_bio
65is already set up to calculate and finalize the digest when written through.
66.It Dv SMIME_BINARY
67If specified, this flag is passed through to
68.Xr SMIME_crlf_copy 3 .
69.It Dv SMIME_CRLFEOL
70End MIME header lines with pairs of carriage return and newline characters.
71By default, no carriage return characters are written
72and header lines are ended with newline characters only.
73.It Dv SMIME_DETACHED
74Use cleartext signing.
75Generate a
76.Qq multipart/signed
77S/MIME message using the
78.Fa micalg
79argument and ignoring the
80.Fa ctype_nid
81and
82.Fa econt_nid
83arguments.
84The content is read from
85.Fa in_bio .
86If
87.Fa in_bio
88is a
89.Dv NULL
90pointer, this flag is ignored.
91.Pp
92If this flag is ignored or not specified,
93the smime-type is chosen according to
94.Fa ctype_nid
95instead:
96.Bl -tag -width Ds
97.It Dv NID_pkcs7_enveloped
98.Qq enveloped-data
99.It Dv NID_pkcs7_signed
100.Qq signed-receipt
101if
102.Fa econt_nid
103is
104.Dv NID_id_smime_ct_receipt
105.br
106.Qq signed-data
107if
108.Fa micalg
109is not empty
110.br
111.Qq certs-only
112if
113.Fa micalg
114is empty
115.It Dv NID_id_smime_ct_compressedData
116.Qq compressed-data
117.El
118.It Dv SMIME_OLDMIME
119In Content-Type headers, use
120.Qq application/x-pkcs7-mime
121or
122.Qq application/x-pkcs7-signature .
123By default,
124.Qq application/pkcs7-mime
125or
126.Qq application/pkcs7-signature
127are used instead.
128.It Dv SMIME_STREAM
129Perform streaming by reading the content from
130.Fa in_bio .
131This only works if
132.Dv SMIME_DETACHED
133is not specified.
134.It SMIME_TEXT
135Prepend the line
136.Qq Content-Type: text/plain
137to the content.
138This only makes sense if
139.Dv SMIME_DETACHED
140is also set.
141It is ignored if the flag
142.Dv SMIME_BINARY
143is also set.
144.El
145.Sh RETURN VALUES
146.Fn SMIME_write_ASN1
147is intended to return 1 on success or 0 on failure.
148.Sh SEE ALSO
149.Xr ASN1_item_i2d_bio 3 ,
150.Xr BIO_f_base64 3 ,
151.Xr BIO_new 3 ,
152.Xr SMIME_crlf_copy 3 ,
153.Xr SMIME_write_CMS 3 ,
154.Xr SMIME_write_PKCS7 3 ,
155.Xr X509_ALGOR_new 3
156.Sh HISTORY
157.Fn SMIME_write_ASN1
158first appeared in OpenSSL 1.0.0 and has been available since
159.Ox 4.9 .
160.Sh BUGS
161.Fn SMIME_write_ASN1
162ignores most errors and is likely to return 1
163even after producing corrupt or incomplete output.
diff --git a/src/lib/libcrypto/man/SMIME_write_CMS.3 b/src/lib/libcrypto/man/SMIME_write_CMS.3
index c2c6b77e53..5f4c43bb7c 100644
--- a/src/lib/libcrypto/man/SMIME_write_CMS.3
+++ b/src/lib/libcrypto/man/SMIME_write_CMS.3
@@ -1,7 +1,24 @@
1.\" $OpenBSD: SMIME_write_CMS.3,v 1.6 2021/12/13 17:24:39 schwarze Exp $ 1.\" $OpenBSD: SMIME_write_CMS.3,v 1.9 2025/06/11 23:16:32 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021, 2025 Ingo Schwarze <schwarze@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.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved. 22.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved.
6.\" 23.\"
7.\" Redistribution and use in source and binary forms, with or without 24.\" Redistribution and use in source and binary forms, with or without
@@ -48,13 +65,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 67.\"
51.Dd $Mdocdate: December 13 2021 $ 68.Dd $Mdocdate: June 11 2025 $
52.Dt SMIME_WRITE_CMS 3 69.Dt SMIME_WRITE_CMS 3
53.Os 70.Os
54.Sh NAME 71.Sh NAME
55.Nm SMIME_write_CMS 72.Nm SMIME_write_CMS
56.Nd convert CMS structure to S/MIME format 73.Nd convert CMS structure to S/MIME format
57.Sh SYNOPSIS 74.Sh SYNOPSIS
75.Lb libcrypto
58.In openssl/cms.h 76.In openssl/cms.h
59.Ft int 77.Ft int
60.Fo SMIME_write_CMS 78.Fo SMIME_write_CMS
@@ -65,21 +83,35 @@
65.Fc 83.Fc
66.Sh DESCRIPTION 84.Sh DESCRIPTION
67.Fn SMIME_write_CMS 85.Fn SMIME_write_CMS
68adds the appropriate MIME headers to the 86generates an S/MIME message on
69.Fa cms 87.Fa out
70structure to produce an S/MIME message and writes it to 88by writing MIME 1.0 headers
71.Fa out . 89followed by a BER- and base64-encoded serialization of
90.Fa cms .
91The BER encoding uses the DER format except as described for
92.Dv CMS_STREAM
93below.
72If streaming is enabled, the content must be supplied in the 94If streaming is enabled, the content must be supplied in the
73.Fa data 95.Fa data
74argument. 96argument.
75.Pp 97.Pp
76The following 98The
77.Fa flags 99.Fa flags
78can be passed: 100can be the logical OR of zero or more of the following bits:
79.Bl -tag -width Ds 101.Bl -tag -width Ds
80.It Dv CMS_DETACHED 102.It Dv CMS_DETACHED
81Use cleartext signing. 103Use cleartext signing and generate a
82This option only makes sense if 104.Qq multipart/signed
105S/MIME message.
106The content is read from
107.Fa data .
108If
109.Fa data
110is a
111.Dv NULL
112pointer, this flag is ignored.
113.Pp
114This flag is only supported if
83.Fa cms 115.Fa cms
84is of the type 116is of the type
85.Vt SignedData 117.Vt SignedData
@@ -94,13 +126,46 @@ is not set, the data must be read twice:
94once to compute the signature in 126once to compute the signature in
95.Xr CMS_sign 3 127.Xr CMS_sign 3
96and once to output the S/MIME message. 128and once to output the S/MIME message.
97.It Dv CMS_TEXT 129.Pp
98Add MIME headers for type text/plain to the content. 130If
99This only makes sense if 131.Dv CMS_DETACHED
132is ignored or not specified, the smime-type is chosen according to
133.Xr CMS_get0_type 3 :
134.Bl -tag -width Ds
135.It Dv NID_pkcs7_enveloped
136.Qq enveloped-data
137.It Dv NID_pkcs7_signed
138.Bl -tag -width Msigned-receiptM -compact
139.It Qq signed-receipt
140if
141.Xr CMS_get0_eContentType 3
142is
143.Dv NID_id_smime_ct_receipt
144.It Qq signed-data
145if
146.Fa cms
147specifies any digest algorithm
148.It Qq certs-only
149otherwise
150.El
151.It Dv NID_id_smime_ct_compressedData
152.Qq compressed-data
153.El
154.It Dv CMS_REUSE_DIGEST
155Skip the calls to
156.Xr CMS_dataInit 3
157and
158.Xr CMS_dataFinal 3 .
159This flag has no effect unless
100.Dv CMS_DETACHED 160.Dv CMS_DETACHED
101is also set. 161is also set.
102.It Dv CMS_STREAM 162.It Dv CMS_STREAM
103Perform streaming. 163Perform streaming by reading the content from
164.Fa data .
165This only works if
166.Dv CMS_DETACHED
167is not specified.
168.Pp
104This flag should only be set if 169This flag should only be set if
105.Dv CMS_STREAM 170.Dv CMS_STREAM
106was also passed to the function that created 171was also passed to the function that created
@@ -111,17 +176,38 @@ constructed encoding except in the case of
111.Vt SignedData 176.Vt SignedData
112with detached content where the content is absent and DER format is 177with detached content where the content is absent and DER format is
113used. 178used.
179.It Dv CMS_TEXT
180Prepend the line
181.Qq Content-Type: text/plain
182to the content.
183This only makes sense if
184.Dv CMS_DETACHED
185is also set.
186It is ignored if the flag
187.Dv SMIME_BINARY
188is also set.
189.It Dv SMIME_BINARY
190If specified, this flag is passed through to
191.Xr SMIME_crlf_copy 3 .
192.It Dv SMIME_CRLFEOL
193End MIME header lines with pairs of carriage return and newline characters.
194By default, no carriage return characters are written
195and header lines are ended with newline characters only.
114.El 196.El
115.Sh RETURN VALUES 197.Sh RETURN VALUES
116.Fn SMIME_write_CMS 198.Fn SMIME_write_CMS
117returns 1 for success or 0 for failure. 199is intended to return 1 on success or 0 on failure.
118.Sh SEE ALSO 200.Sh SEE ALSO
201.Xr BIO_f_base64 3 ,
202.Xr BIO_new 3 ,
119.Xr CMS_ContentInfo_new 3 , 203.Xr CMS_ContentInfo_new 3 ,
120.Xr CMS_encrypt 3 , 204.Xr CMS_encrypt 3 ,
121.Xr CMS_sign 3 , 205.Xr CMS_sign 3 ,
122.Xr d2i_CMS_ContentInfo 3 , 206.Xr d2i_CMS_ContentInfo 3 ,
123.Xr ERR_get_error 3 , 207.Xr ERR_get_error 3 ,
124.Xr SMIME_write_ASN1 3 208.Xr SMIME_crlf_copy 3 ,
209.Xr SMIME_read_CMS 3 ,
210.Xr SMIME_write_PKCS7 3
125.Sh HISTORY 211.Sh HISTORY
126.Fn SMIME_write_CMS 212.Fn SMIME_write_CMS
127first appeared in OpenSSL 0.9.8h 213first appeared in OpenSSL 0.9.8h
@@ -129,5 +215,9 @@ and has been available since
129.Ox 6.7 . 215.Ox 6.7 .
130.Sh BUGS 216.Sh BUGS
131.Fn SMIME_write_CMS 217.Fn SMIME_write_CMS
218ignores most errors and is likely to return 1
219even after producing corrupt or incomplete output.
220.Pp
221.Fn SMIME_write_CMS
132always base64 encodes CMS structures. 222always base64 encodes CMS structures.
133There should be an option to disable this. 223There should be an option to disable this.
diff --git a/src/lib/libcrypto/man/SMIME_write_PKCS7.3 b/src/lib/libcrypto/man/SMIME_write_PKCS7.3
index c1a9f051d0..5e344d9c63 100644
--- a/src/lib/libcrypto/man/SMIME_write_PKCS7.3
+++ b/src/lib/libcrypto/man/SMIME_write_PKCS7.3
@@ -1,10 +1,10 @@
1.\" $OpenBSD: SMIME_write_PKCS7.3,v 1.9 2021/12/14 15:46:48 schwarze Exp $ 1.\" $OpenBSD: SMIME_write_PKCS7.3,v 1.12 2025/06/11 23:16:32 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license: 5.\" The changes are covered by the following Copyright and license:
6.\" 6.\"
7.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 7.\" Copyright (c) 2021, 2025 Ingo Schwarze <schwarze@openbsd.org>
8.\" 8.\"
9.\" Permission to use, copy, modify, and distribute this software for any 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 10.\" purpose with or without fee is hereby granted, provided that the above
@@ -66,13 +66,14 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: December 14 2021 $ 69.Dd $Mdocdate: June 11 2025 $
70.Dt SMIME_WRITE_PKCS7 3 70.Dt SMIME_WRITE_PKCS7 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
73.Nm SMIME_write_PKCS7 73.Nm SMIME_write_PKCS7
74.Nd convert PKCS#7 structure to S/MIME format 74.Nd convert PKCS#7 structure to S/MIME format
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libcrypto
76.In openssl/pkcs7.h 77.In openssl/pkcs7.h
77.Ft int 78.Ft int
78.Fo SMIME_write_PKCS7 79.Fo SMIME_write_PKCS7
@@ -83,48 +84,81 @@
83.Fc 84.Fc
84.Sh DESCRIPTION 85.Sh DESCRIPTION
85.Fn SMIME_write_PKCS7 86.Fn SMIME_write_PKCS7
86adds the appropriate MIME headers to a PKCS#7 structure to produce an 87generates an S/MIME message on
87S/MIME message.
88.Pp
89.Fa out 88.Fa out
90is the 89by writing MIME 1.0 headers
91.Vt BIO 90followed by a BER- and base64-encoded serialization of
92to write the data to. 91.Fa p7 .
93.Fa p7 92The BER encoding uses the DER format except as described for
94is the appropriate 93.Dv PKCS7_STREAM
95.Vt PKCS7 94below.
96structure.
97If streaming is enabled, then the content must be supplied in the 95If streaming is enabled, then the content must be supplied in the
98.Fa data 96.Fa data
99argument. 97argument.
100.Fa flags
101is an optional set of flags.
102.Pp 98.Pp
103The following flags can be passed in the 99The
104.Fa flags 100.Fa flags
105parameter. 101can be the logical OR of zero or more of the following bits:
106.Pp 102.Bl -tag -width Ds
103.It Dv PKCS7_DETACHED
104Use cleartext signing and generate a
105.Qq multipart/signed
106S/MIME message.
107The content is read from
108.Fa data .
107If 109If
108.Dv PKCS7_DETACHED 110.Fa data
109is set, then cleartext signing will be used. 111is a
110This option only makes sense for signedData where 112.Dv NULL
113pointer, this flag is ignored.
114.Pp
115This flag is only supported for signedData where
111.Dv PKCS7_DETACHED 116.Dv PKCS7_DETACHED
112is also set when 117is also set when
113.Xr PKCS7_sign 3 118.Xr PKCS7_sign 3
114is also called. 119is called.
115.Pp 120.Pp
116If the 121If
117.Dv PKCS7_TEXT 122.Dv PKCS7_STREAM
118flag is set, MIME headers for type 123is not set, the data must be read twice: once to compute the
119.Sy text/plain 124signature in
120are added to the content. 125.Xr PKCS7_sign 3
121This only makes sense if 126and once to output the S/MIME message.
127.Pp
128If
129.Dv PKCS7_DETACHED
130is ignored or not specified, the smime-type is chosen according to the type of
131.Fa p7 :
132.Bl -tag -width Ds
133.It Dv NID_pkcs7_enveloped
134.Qq enveloped-data
135.It Dv NID_pkcs7_signed
136.Bl -tag -width Msigned-dataM -compact
137.It Qq signed-data
138if
139.Fa p7
140specifies any digest algorithm
141.It Qq certs-only
142otherwise
143.El
144.It Dv NID_id_smime_ct_compressedData
145.Qq compressed-data
146.El
147.It Dv PKCS7_REUSE_DIGEST
148Skip the calls to
149.Xr PKCS7_dataInit 3
150and
151.Xr PKCS7_dataFinal 3 .
152This flag has no effect unless
122.Dv PKCS7_DETACHED 153.Dv PKCS7_DETACHED
123is also set. 154is also set.
155.It Dv PKCS7_STREAM
156Perform streaming by reading the content from
157.Fa data .
158This only works if
159.Dv PKCS7_DETACHED
160is not specified.
124.Pp 161.Pp
125If the
126.Dv PKCS7_STREAM
127flag is set, streaming is performed.
128This flag should only be set if 162This flag should only be set if
129.Dv PKCS7_STREAM 163.Dv PKCS7_STREAM
130was also set in the previous call to 164was also set in the previous call to
@@ -132,13 +166,28 @@ was also set in the previous call to
132or 166or
133.Xr PKCS7_encrypt 3 . 167.Xr PKCS7_encrypt 3 .
134.Pp 168.Pp
135The bit 169The content is output in BER format using indefinite length constructed
136.Dv SMIME_OLDMIME 170encoding except in the case of signed data with detached content
137is inverted before passing on the 171where the content is absent and DER format is used.
138.Fa flags 172.It Dv PKCS7_TEXT
139to 173Prepend the line
140.Xr SMIME_write_ASN1 3 . 174.Qq Content-Type: text/plain
141Consequently, if this bit is set in the 175to the content.
176This only makes sense if
177.Dv PKCS7_DETACHED
178is also set.
179It is ignored if the flag
180.Dv SMIME_BINARY
181is also set.
182.It Dv SMIME_BINARY
183If specified, this flag is passed through to
184.Xr SMIME_crlf_copy 3 .
185.It Dv SMIME_CRLFEOL
186End MIME header lines with pairs of carriage return and newline characters.
187By default, no carriage return characters are written
188and header lines are ended with newline characters only.
189.It Dv SMIME_OLDMIME
190If this bit is set in the
142.Fa flags 191.Fa flags
143argument, 192argument,
144.Qq application/pkcs7-mime 193.Qq application/pkcs7-mime
@@ -150,35 +199,30 @@ Otherwise,
150or 199or
151.Qq application/x-pkcs7-signature 200.Qq application/x-pkcs7-signature
152is used. 201is used.
153.Pp 202.El
154If cleartext signing is being used and
155.Dv PKCS7_STREAM
156is not set, then the data must be read twice: once to compute the
157signature in
158.Xr PKCS7_sign 3
159and once to output the S/MIME message.
160.Pp
161If streaming is performed, the content is output in BER format using
162indefinite length constructed encoding except in the case of signed
163data with detached content where the content is absent and DER
164format is used.
165.Sh RETURN VALUES 203.Sh RETURN VALUES
166Upon successful completion, 1 is returned; 204.Fn SMIME_write_PKCS7
167otherwise 0 is returned and an error code can be retrieved with 205is intended to return 1 on success or 0 on failure.
168.Xr ERR_get_error 3 .
169.Sh SEE ALSO 206.Sh SEE ALSO
207.Xr BIO_f_base64 3 ,
208.Xr BIO_new 3 ,
170.Xr i2d_PKCS7_bio_stream 3 , 209.Xr i2d_PKCS7_bio_stream 3 ,
171.Xr PEM_write_bio_PKCS7_stream 3 , 210.Xr PEM_write_bio_PKCS7_stream 3 ,
172.Xr PEM_write_PKCS7 3 , 211.Xr PEM_write_PKCS7 3 ,
173.Xr PKCS7_final 3 , 212.Xr PKCS7_final 3 ,
174.Xr PKCS7_new 3 , 213.Xr PKCS7_new 3 ,
214.Xr SMIME_crlf_copy 3 ,
175.Xr SMIME_read_PKCS7 3 , 215.Xr SMIME_read_PKCS7 3 ,
176.Xr SMIME_write_ASN1 3 216.Xr SMIME_write_CMS 3
177.Sh HISTORY 217.Sh HISTORY
178.Fn SMIME_write_PKCS7 218.Fn SMIME_write_PKCS7
179first appeared in OpenSSL 0.9.5 and has been available since 219first appeared in OpenSSL 0.9.5 and has been available since
180.Ox 2.7 . 220.Ox 2.7 .
181.Sh BUGS 221.Sh BUGS
182.Fn SMIME_write_PKCS7 222.Fn SMIME_write_PKCS7
223ignores most errors and is likely to return 1
224even after producing corrupt or incomplete output.
225.Pp
226.Fn SMIME_write_PKCS7
183always base64 encodes PKCS#7 structures. 227always base64 encodes PKCS#7 structures.
184There should be an option to disable this. 228There should be an option to disable this.
diff --git a/src/lib/libcrypto/man/STACK_OF.3 b/src/lib/libcrypto/man/STACK_OF.3
index 4c627eed9b..38bca99cf6 100644
--- a/src/lib/libcrypto/man/STACK_OF.3
+++ b/src/lib/libcrypto/man/STACK_OF.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: STACK_OF.3,v 1.5 2021/10/24 13:10:46 schwarze Exp $ 1.\" $OpenBSD: STACK_OF.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 24 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt STACK_OF 3 18.Dt STACK_OF 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm STACK_OF 21.Nm STACK_OF
22.Nd variable-sized arrays of pointers, called OpenSSL stacks 22.Nd variable-sized arrays of pointers, called OpenSSL stacks
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/safestack.h 25.In openssl/safestack.h
25.Fn STACK_OF type 26.Fn STACK_OF type
26.Sh DESCRIPTION 27.Sh DESCRIPTION
diff --git a/src/lib/libcrypto/man/TS_REQ_new.3 b/src/lib/libcrypto/man/TS_REQ_new.3
index 8dbd15ea7e..796b58f4f8 100644
--- a/src/lib/libcrypto/man/TS_REQ_new.3
+++ b/src/lib/libcrypto/man/TS_REQ_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: TS_REQ_new.3,v 1.6 2019/06/06 01:06:59 schwarze Exp $ 1.\" $OpenBSD: TS_REQ_new.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 6 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt TS_REQ_NEW 3 18.Dt TS_REQ_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,6 +32,7 @@
32.Nm TS_MSG_IMPRINT_free 32.Nm TS_MSG_IMPRINT_free
33.Nd X.509 time-stamp protocol 33.Nd X.509 time-stamp protocol
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/ts.h 36.In openssl/ts.h
36.Ft TS_REQ * 37.Ft TS_REQ *
37.Fn TS_REQ_new void 38.Fn TS_REQ_new void
diff --git a/src/lib/libcrypto/man/UI_create_method.3 b/src/lib/libcrypto/man/UI_create_method.3
index ffd6b98157..a116baaa79 100644
--- a/src/lib/libcrypto/man/UI_create_method.3
+++ b/src/lib/libcrypto/man/UI_create_method.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: UI_create_method.3,v 1.6 2023/05/22 19:38:04 tb Exp $ 1.\" $OpenBSD: UI_create_method.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL UI_create_method.pod 8e3d46e5 Mar 11 10:51:04 2017 +0100 2.\" OpenSSL UI_create_method.pod 8e3d46e5 Mar 11 10:51:04 2017 +0100
3.\" 3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>. 4.\" This file was written by Richard Levitte <levitte@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 22 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt UI_CREATE_METHOD 3 52.Dt UI_CREATE_METHOD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -68,6 +68,7 @@
68.Nm UI_method_get_prompt_constructor 68.Nm UI_method_get_prompt_constructor
69.Nd user interface method creation and destruction 69.Nd user interface method creation and destruction
70.Sh SYNOPSIS 70.Sh SYNOPSIS
71.Lb libcrypto
71.In openssl/ui.h 72.In openssl/ui.h
72.Ft UI_METHOD * 73.Ft UI_METHOD *
73.Fo UI_create_method 74.Fo UI_create_method
diff --git a/src/lib/libcrypto/man/UI_get_string_type.3 b/src/lib/libcrypto/man/UI_get_string_type.3
index bc0449a90e..84c774d94d 100644
--- a/src/lib/libcrypto/man/UI_get_string_type.3
+++ b/src/lib/libcrypto/man/UI_get_string_type.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: UI_get_string_type.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $ 1.\" $OpenBSD: UI_get_string_type.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL UI_STRING.pod e9c9971b Jul 1 18:28:50 2017 +0200 2.\" OpenSSL UI_STRING.pod e9c9971b Jul 1 18:28:50 2017 +0200
3.\" 3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org> 4.\" This file was written by Richard Levitte <levitte@openssl.org>
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 22 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt UI_GET_STRING_TYPE 3 52.Dt UI_GET_STRING_TYPE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -63,6 +63,7 @@
63.Nm UI_set_result 63.Nm UI_set_result
64.Nd OpenSSL user interface string parsing 64.Nd OpenSSL user interface string parsing
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libcrypto
66.In openssl/ui.h 67.In openssl/ui.h
67.Bd -literal 68.Bd -literal
68enum UI_string_types { 69enum UI_string_types {
diff --git a/src/lib/libcrypto/man/UI_new.3 b/src/lib/libcrypto/man/UI_new.3
index e55477f31e..853219aac2 100644
--- a/src/lib/libcrypto/man/UI_new.3
+++ b/src/lib/libcrypto/man/UI_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: UI_new.3,v 1.13 2025/03/09 15:25:14 tb Exp $ 1.\" $OpenBSD: UI_new.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 78b19e90 Jan 11 00:12:01 2017 +0100 2.\" full merge up to: OpenSSL 78b19e90 Jan 11 00:12:01 2017 +0100
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 9 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt UI_NEW 3 53.Dt UI_NEW 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -80,6 +80,7 @@
80.Nm UI_null 80.Nm UI_null
81.Nd New User Interface 81.Nd New User Interface
82.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
83.In openssl/ui.h 84.In openssl/ui.h
84.Ft UI * 85.Ft UI *
85.Fn UI_new void 86.Fn UI_new void
diff --git a/src/lib/libcrypto/man/X25519.3 b/src/lib/libcrypto/man/X25519.3
index a327f8c7b2..3686df9bfa 100644
--- a/src/lib/libcrypto/man/X25519.3
+++ b/src/lib/libcrypto/man/X25519.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X25519.3,v 1.7 2022/12/15 17:20:48 schwarze Exp $ 1.\" $OpenBSD: X25519.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" contains some text from: BoringSSL curve25519.h, curve25519.c 2.\" contains some text from: BoringSSL curve25519.h, curve25519.c
3.\" content also checked up to: OpenSSL f929439f Mar 15 12:19:16 2018 +0000 3.\" content also checked up to: OpenSSL f929439f Mar 15 12:19:16 2018 +0000
4.\" 4.\"
@@ -24,7 +24,7 @@
24.\" by Daniel J. Bernstein and others that are included in SUPERCOP 24.\" by Daniel J. Bernstein and others that are included in SUPERCOP
25.\" and that Adam Langley's BoringSSL implementation is based on. 25.\" and that Adam Langley's BoringSSL implementation is based on.
26.\" 26.\"
27.Dd $Mdocdate: December 15 2022 $ 27.Dd $Mdocdate: June 8 2025 $
28.Dt X25519 3 28.Dt X25519 3
29.Os 29.Os
30.Sh NAME 30.Sh NAME
@@ -35,6 +35,7 @@
35.Nm ED25519_verify 35.Nm ED25519_verify
36.Nd Elliptic Curve Diffie-Hellman and signature primitives based on Curve25519 36.Nd Elliptic Curve Diffie-Hellman and signature primitives based on Curve25519
37.Sh SYNOPSIS 37.Sh SYNOPSIS
38.Lb libcrypto
38.In openssl/curve25519.h 39.In openssl/curve25519.h
39.Ft int 40.Ft int
40.Fo X25519 41.Fo X25519
diff --git a/src/lib/libcrypto/man/X509V3_EXT_get_nid.3 b/src/lib/libcrypto/man/X509V3_EXT_get_nid.3
index ad153c36d0..78975874aa 100644
--- a/src/lib/libcrypto/man/X509V3_EXT_get_nid.3
+++ b/src/lib/libcrypto/man/X509V3_EXT_get_nid.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509V3_EXT_get_nid.3,v 1.8 2024/12/24 09:48:56 schwarze Exp $ 1.\" $OpenBSD: X509V3_EXT_get_nid.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 24 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_EXT_GET_NID 3 18.Dt X509V3_EXT_GET_NID 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509V3_EXT_get 22.Nm X509V3_EXT_get
23.Nd retrieve X.509v3 certificate extension methods 23.Nd retrieve X.509v3 certificate extension methods
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft const X509V3_EXT_METHOD * 27.Ft const X509V3_EXT_METHOD *
27.Fo X509V3_EXT_get_nid 28.Fo X509V3_EXT_get_nid
diff --git a/src/lib/libcrypto/man/X509V3_EXT_print.3 b/src/lib/libcrypto/man/X509V3_EXT_print.3
index edb97d3a36..8705e4d5ac 100644
--- a/src/lib/libcrypto/man/X509V3_EXT_print.3
+++ b/src/lib/libcrypto/man/X509V3_EXT_print.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509V3_EXT_print.3,v 1.3 2024/12/28 10:19:45 schwarze Exp $ 1.\" $OpenBSD: X509V3_EXT_print.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021, 2024 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021, 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 28 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_EXT_PRINT 3 18.Dt X509V3_EXT_PRINT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509V3_EXT_print_fp 22.Nm X509V3_EXT_print_fp
23.Nd pretty-print an X.509 extension 23.Nd pretty-print an X.509 extension
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft int 27.Ft int
27.Fo X509V3_EXT_print 28.Fo X509V3_EXT_print
diff --git a/src/lib/libcrypto/man/X509V3_extensions_print.3 b/src/lib/libcrypto/man/X509V3_extensions_print.3
index 8c43fe9b01..d95a4da01e 100644
--- a/src/lib/libcrypto/man/X509V3_extensions_print.3
+++ b/src/lib/libcrypto/man/X509V3_extensions_print.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509V3_extensions_print.3,v 1.2 2021/11/26 13:48:21 jsg Exp $ 1.\" $OpenBSD: X509V3_extensions_print.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 26 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_EXTENSIONS_PRINT 3 18.Dt X509V3_EXTENSIONS_PRINT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm X509V3_extensions_print 21.Nm X509V3_extensions_print
22.Nd pretty-print an array of X.509 extensions 22.Nd pretty-print an array of X.509 extensions
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/x509v3.h 25.In openssl/x509v3.h
25.Ft int 26.Ft int
26.Fo X509V3_extensions_print 27.Fo X509V3_extensions_print
diff --git a/src/lib/libcrypto/man/X509V3_get_d2i.3 b/src/lib/libcrypto/man/X509V3_get_d2i.3
index bf442dc846..7920fca09f 100644
--- a/src/lib/libcrypto/man/X509V3_get_d2i.3
+++ b/src/lib/libcrypto/man/X509V3_get_d2i.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509V3_get_d2i.3,v 1.25 2024/12/31 20:17:00 tb Exp $ 1.\" $OpenBSD: X509V3_get_d2i.3,v 1.26 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL ff7fbfd5 Nov 2 11:52:01 2015 +0000 2.\" full merge up to: OpenSSL ff7fbfd5 Nov 2 11:52:01 2015 +0000
3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 31 2024 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt X509V3_GET_D2I 3 71.Dt X509V3_GET_D2I 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -87,6 +87,7 @@
87.Nm X509_get0_uids 87.Nm X509_get0_uids
88.Nd X509 extension decode and encode functions 88.Nd X509 extension decode and encode functions
89.Sh SYNOPSIS 89.Sh SYNOPSIS
90.Lb libcrypto
90.In openssl/x509v3.h 91.In openssl/x509v3.h
91.Ft void * 92.Ft void *
92.Fo X509V3_get_d2i 93.Fo X509V3_get_d2i
diff --git a/src/lib/libcrypto/man/X509V3_parse_list.3 b/src/lib/libcrypto/man/X509V3_parse_list.3
index 447f1a5e94..385f8ad9c8 100644
--- a/src/lib/libcrypto/man/X509V3_parse_list.3
+++ b/src/lib/libcrypto/man/X509V3_parse_list.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509V3_parse_list.3,v 1.2 2024/12/24 09:48:56 schwarze Exp $ 1.\" $OpenBSD: X509V3_parse_list.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 24 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_PARSE_LIST 3 18.Dt X509V3_PARSE_LIST 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509V3_conf_free 22.Nm X509V3_conf_free
23.Nd create and destroy CONF_VALUE objects 23.Nd create and destroy CONF_VALUE objects
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft STACK_OF(CONF_VALUE) * 27.Ft STACK_OF(CONF_VALUE) *
27.Fn X509V3_parse_list "const char *string" 28.Fn X509V3_parse_list "const char *string"
diff --git a/src/lib/libcrypto/man/X509_ALGOR_dup.3 b/src/lib/libcrypto/man/X509_ALGOR_dup.3
index ef7ca75863..bc9ba4b77d 100644
--- a/src/lib/libcrypto/man/X509_ALGOR_dup.3
+++ b/src/lib/libcrypto/man/X509_ALGOR_dup.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_ALGOR_dup.3,v 1.23 2024/03/19 17:34:05 tb Exp $ 1.\" $OpenBSD: X509_ALGOR_dup.3,v 1.24 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 4692340e Jun 7 15:49:08 2016 -0400 2.\" OpenSSL 4692340e Jun 7 15:49:08 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: March 19 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt X509_ALGOR_DUP 3 70.Dt X509_ALGOR_DUP 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -78,6 +78,7 @@
78.Nm X509_ALGOR_cmp 78.Nm X509_ALGOR_cmp
79.Nd create, change, and inspect algorithm identifiers 79.Nd create, change, and inspect algorithm identifiers
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/x509.h 82.In openssl/x509.h
82.Ft X509_ALGOR * 83.Ft X509_ALGOR *
83.Fn X509_ALGOR_new void 84.Fn X509_ALGOR_new void
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3
index 4212e27d7e..b452fcbea2 100644
--- a/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3
+++ b/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_ATTRIBUTE_get0_object.3,v 1.2 2021/10/21 16:26:34 schwarze Exp $ 1.\" $OpenBSD: X509_ATTRIBUTE_get0_object.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 21 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_ATTRIBUTE_GET0_OBJECT 3 18.Dt X509_ATTRIBUTE_GET0_OBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.\" The type is called "Attribute" with capital "A", not "attribute". 27.\" The type is called "Attribute" with capital "A", not "attribute".
28.Nd X.501 Attribute read accessors 28.Nd X.501 Attribute read accessors
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/x509.h 31.In openssl/x509.h
31.Ft ASN1_OBJECT * 32.Ft ASN1_OBJECT *
32.Fo X509_ATTRIBUTE_get0_object 33.Fo X509_ATTRIBUTE_get0_object
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3
index cc2b27d4c0..63a5c58169 100644
--- a/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3
+++ b/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_ATTRIBUTE_new.3,v 1.18 2024/09/02 07:57:27 tb Exp $ 1.\" $OpenBSD: X509_ATTRIBUTE_new.3,v 1.19 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 2 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_ATTRIBUTE_NEW 3 18.Dt X509_ATTRIBUTE_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.\" The type is called "Attribute" with capital "A", not "attribute". 27.\" The type is called "Attribute" with capital "A", not "attribute".
28.Nd generic X.501 Attribute 28.Nd generic X.501 Attribute
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libcrypto
30.In openssl/x509.h 31.In openssl/x509.h
31.Ft X509_ATTRIBUTE * 32.Ft X509_ATTRIBUTE *
32.Fn X509_ATTRIBUTE_new void 33.Fn X509_ATTRIBUTE_new void
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3
index 3555d4b169..d26e7de473 100644
--- a/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3
+++ b/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_ATTRIBUTE_set1_object.3,v 1.3 2021/11/26 13:48:21 jsg Exp $ 1.\" $OpenBSD: X509_ATTRIBUTE_set1_object.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 26 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_ATTRIBUTE_SET1_OBJECT 3 18.Dt X509_ATTRIBUTE_SET1_OBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.\" The type is called "Attribute" with capital "A", not "attribute". 28.\" The type is called "Attribute" with capital "A", not "attribute".
29.Nd modify an X.501 Attribute 29.Nd modify an X.501 Attribute
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/x509.h 32.In openssl/x509.h
32.Ft int 33.Ft int
33.Fo X509_ATTRIBUTE_set1_object 34.Fo X509_ATTRIBUTE_set1_object
diff --git a/src/lib/libcrypto/man/X509_CINF_new.3 b/src/lib/libcrypto/man/X509_CINF_new.3
index 6c09c58545..62399c07f7 100644
--- a/src/lib/libcrypto/man/X509_CINF_new.3
+++ b/src/lib/libcrypto/man/X509_CINF_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_CINF_new.3,v 1.11 2024/09/02 08:04:32 tb Exp $ 1.\" $OpenBSD: X509_CINF_new.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 2 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_CINF_NEW 3 18.Dt X509_CINF_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm X509_CERT_AUX_free 26.Nm X509_CERT_AUX_free
27.Nd X.509 certificate information objects 27.Nd X.509 certificate information objects
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/x509.h 30.In openssl/x509.h
30.Ft X509_CINF * 31.Ft X509_CINF *
31.Fn X509_CINF_new void 32.Fn X509_CINF_new void
diff --git a/src/lib/libcrypto/man/X509_CRL_get0_by_serial.3 b/src/lib/libcrypto/man/X509_CRL_get0_by_serial.3
index f5edee6085..5a7d57c3f5 100644
--- a/src/lib/libcrypto/man/X509_CRL_get0_by_serial.3
+++ b/src/lib/libcrypto/man/X509_CRL_get0_by_serial.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_CRL_get0_by_serial.3,v 1.13 2024/03/06 02:34:14 tb Exp $ 1.\" $OpenBSD: X509_CRL_get0_by_serial.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL cdd6c8c5 Mar 20 12:29:37 2017 +0100 2.\" full merge up to: OpenSSL cdd6c8c5 Mar 20 12:29:37 2017 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 6 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_CRL_GET0_BY_SERIAL 3 52.Dt X509_CRL_GET0_BY_SERIAL 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm X509_CRL_sort 59.Nm X509_CRL_sort
60.Nd add, sort, and retrieve CRL entries 60.Nd add, sort, and retrieve CRL entries
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/x509.h 63.In openssl/x509.h
63.Ft int 64.Ft int
64.Fo X509_CRL_get0_by_serial 65.Fo X509_CRL_get0_by_serial
diff --git a/src/lib/libcrypto/man/X509_CRL_new.3 b/src/lib/libcrypto/man/X509_CRL_new.3
index f9355fcfd3..36a6439269 100644
--- a/src/lib/libcrypto/man/X509_CRL_new.3
+++ b/src/lib/libcrypto/man/X509_CRL_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_CRL_new.3,v 1.14 2024/03/06 02:34:14 tb Exp $ 1.\" $OpenBSD: X509_CRL_new.3,v 1.15 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016, 2018, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016, 2018, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 6 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_CRL_NEW 3 18.Dt X509_CRL_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm X509_CRL_INFO_free 26.Nm X509_CRL_INFO_free
27.Nd X.509 certificate revocation lists 27.Nd X.509 certificate revocation lists
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/x509.h 30.In openssl/x509.h
30.Ft X509_CRL * 31.Ft X509_CRL *
31.Fn X509_CRL_new void 32.Fn X509_CRL_new void
diff --git a/src/lib/libcrypto/man/X509_CRL_print.3 b/src/lib/libcrypto/man/X509_CRL_print.3
index 2f4832f0e7..1f1d278968 100644
--- a/src/lib/libcrypto/man/X509_CRL_print.3
+++ b/src/lib/libcrypto/man/X509_CRL_print.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_CRL_print.3,v 1.1 2021/07/19 13:16:43 schwarze Exp $ 1.\" $OpenBSD: X509_CRL_print.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 19 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_CRL_PRINT 3 18.Dt X509_CRL_PRINT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509_CRL_print_fp 22.Nm X509_CRL_print_fp
23.Nd pretty-print a certificate revocation list 23.Nd pretty-print a certificate revocation list
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509.h 26.In openssl/x509.h
26.Ft int 27.Ft int
27.Fo X509_CRL_print 28.Fo X509_CRL_print
diff --git a/src/lib/libcrypto/man/X509_EXTENSION_set_object.3 b/src/lib/libcrypto/man/X509_EXTENSION_set_object.3
index 45cf0dbaa5..f1356c350b 100644
--- a/src/lib/libcrypto/man/X509_EXTENSION_set_object.3
+++ b/src/lib/libcrypto/man/X509_EXTENSION_set_object.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_EXTENSION_set_object.3,v 1.19 2024/12/28 11:04:09 schwarze Exp $ 1.\" $OpenBSD: X509_EXTENSION_set_object.3,v 1.20 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 28 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt X509_EXTENSION_SET_OBJECT 3 69.Dt X509_EXTENSION_SET_OBJECT 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -85,6 +85,7 @@
85.\" The ASN.1 structure is called "Extension", not "extension". 85.\" The ASN.1 structure is called "Extension", not "extension".
86.Nd create, change, and inspect X.509 Extension objects 86.Nd create, change, and inspect X.509 Extension objects
87.Sh SYNOPSIS 87.Sh SYNOPSIS
88.Lb libcrypto
88.In openssl/x509.h 89.In openssl/x509.h
89.Ft X509_EXTENSION * 90.Ft X509_EXTENSION *
90.Fn X509_EXTENSION_new void 91.Fn X509_EXTENSION_new void
diff --git a/src/lib/libcrypto/man/X509_INFO_new.3 b/src/lib/libcrypto/man/X509_INFO_new.3
index 1e9bb832f3..38bf6fe55c 100644
--- a/src/lib/libcrypto/man/X509_INFO_new.3
+++ b/src/lib/libcrypto/man/X509_INFO_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_INFO_new.3,v 1.3 2021/10/19 10:39:33 schwarze Exp $ 1.\" $OpenBSD: X509_INFO_new.3,v 1.5 2025/07/16 17:59:10 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: October 19 2021 $ 16.Dd $Mdocdate: July 16 2025 $
17.Dt X509_INFO_NEW 3 17.Dt X509_INFO_NEW 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
@@ -21,6 +21,7 @@
21.Nm X509_INFO_free 21.Nm X509_INFO_free
22.Nd X.509 certificate wrapper object 22.Nd X.509 certificate wrapper object
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/x509.h 25.In openssl/x509.h
25.Ft X509_INFO * 26.Ft X509_INFO *
26.Fn X509_INFO_new void 27.Fn X509_INFO_new void
@@ -60,10 +61,9 @@ object or
60.Dv NULL 61.Dv NULL
61if an error occurs. 62if an error occurs.
62.Sh SEE ALSO 63.Sh SEE ALSO
63.Xr PEM_X509_INFO_read 3 , 64.Xr PEM_X509_INFO_read_bio 3 ,
64.Xr X509_CRL_new 3 , 65.Xr X509_CRL_new 3 ,
65.Xr X509_new 3 , 66.Xr X509_new 3
66.Xr X509_PKEY_new 3
67.Sh HISTORY 67.Sh HISTORY
68.Fn X509_INFO_new 68.Fn X509_INFO_new
69and 69and
diff --git a/src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3 b/src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3
index 5980f8f80d..74e3aaed3c 100644
--- a/src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3
+++ b/src/lib/libcrypto/man/X509_LOOKUP_hash_dir.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_LOOKUP_hash_dir.3,v 1.13 2024/09/02 07:20:21 tb Exp $ 1.\" $OpenBSD: X509_LOOKUP_hash_dir.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: September 2 2024 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt X509_LOOKUP_HASH_DIR 3 71.Dt X509_LOOKUP_HASH_DIR 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -76,6 +76,7 @@
76.Nm X509_LOOKUP_mem 76.Nm X509_LOOKUP_mem
77.Nd certificate lookup methods 77.Nd certificate lookup methods
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/x509_vfy.h 80.In openssl/x509_vfy.h
80.Ft const X509_LOOKUP_METHOD * 81.Ft const X509_LOOKUP_METHOD *
81.Fn X509_LOOKUP_hash_dir void 82.Fn X509_LOOKUP_hash_dir void
diff --git a/src/lib/libcrypto/man/X509_LOOKUP_new.3 b/src/lib/libcrypto/man/X509_LOOKUP_new.3
index 559dbbb594..5fa9f99d7c 100644
--- a/src/lib/libcrypto/man/X509_LOOKUP_new.3
+++ b/src/lib/libcrypto/man/X509_LOOKUP_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_LOOKUP_new.3,v 1.12 2024/09/06 07:48:20 tb Exp $ 1.\" $OpenBSD: X509_LOOKUP_new.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 6 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_LOOKUP_NEW 3 18.Dt X509_LOOKUP_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,6 +32,7 @@
32.\" and because it doesn't do much in the first place. 32.\" and because it doesn't do much in the first place.
33.Nd certificate lookup object 33.Nd certificate lookup object
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/x509_vfy.h 36.In openssl/x509_vfy.h
36.Ft void 37.Ft void
37.Fn X509_LOOKUP_free "X509_LOOKUP *lookup" 38.Fn X509_LOOKUP_free "X509_LOOKUP *lookup"
diff --git a/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 b/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3
index 2eadec7b4d..ac6d590c5f 100644
--- a/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3
+++ b/src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_NAME_ENTRY_get_object.3,v 1.16 2021/12/10 16:58:20 schwarze Exp $ 1.\" $OpenBSD: X509_NAME_ENTRY_get_object.3,v 1.17 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" selective merge up to: OpenSSL ca34e08d Dec 12 07:38:07 2018 +0100 3.\" selective merge up to: OpenSSL ca34e08d Dec 12 07:38:07 2018 +0100
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 10 2021 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt X509_NAME_ENTRY_GET_OBJECT 3 71.Dt X509_NAME_ENTRY_GET_OBJECT 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -85,6 +85,7 @@
85.\" This object defined in X.501, not in X.509. 85.\" This object defined in X.501, not in X.509.
86.Nd X.501 relative distinguished name 86.Nd X.501 relative distinguished name
87.Sh SYNOPSIS 87.Sh SYNOPSIS
88.Lb libcrypto
88.In openssl/x509.h 89.In openssl/x509.h
89.Ft X509_NAME_ENTRY * 90.Ft X509_NAME_ENTRY *
90.Fn X509_NAME_ENTRY_new void 91.Fn X509_NAME_ENTRY_new void
diff --git a/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 b/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3
index 3c1237d20e..30cc3bccb1 100644
--- a/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3
+++ b/src/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_NAME_add_entry_by_txt.3,v 1.16 2022/03/31 17:27:17 naddy Exp $ 1.\" $OpenBSD: X509_NAME_add_entry_by_txt.3,v 1.17 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 2.\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 31 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt X509_NAME_ADD_ENTRY_BY_TXT 3 53.Dt X509_NAME_ADD_ENTRY_BY_TXT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -60,6 +60,7 @@
60.Nm X509_NAME_delete_entry 60.Nm X509_NAME_delete_entry
61.Nd X509_NAME modification functions 61.Nd X509_NAME modification functions
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/x509.h 64.In openssl/x509.h
64.Ft int 65.Ft int
65.Fo X509_NAME_add_entry_by_txt 66.Fo X509_NAME_add_entry_by_txt
diff --git a/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3 b/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3
index a2ceb10eb5..57dd488181 100644
--- a/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3
+++ b/src/lib/libcrypto/man/X509_NAME_get_index_by_NID.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_NAME_get_index_by_NID.3,v 1.16 2023/05/29 11:54:50 beck Exp $ 1.\" $OpenBSD: X509_NAME_get_index_by_NID.3,v 1.17 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 2.\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: May 29 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt X509_NAME_GET_INDEX_BY_NID 3 53.Dt X509_NAME_GET_INDEX_BY_NID 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -61,6 +61,7 @@
61.Nm X509_NAME_get_text_by_OBJ 61.Nm X509_NAME_get_text_by_OBJ
62.Nd X509_NAME lookup and enumeration functions 62.Nd X509_NAME lookup and enumeration functions
63.Sh SYNOPSIS 63.Sh SYNOPSIS
64.Lb libcrypto
64.In openssl/x509.h 65.In openssl/x509.h
65.Ft int 66.Ft int
66.Fo X509_NAME_get_index_by_NID 67.Fo X509_NAME_get_index_by_NID
diff --git a/src/lib/libcrypto/man/X509_NAME_hash.3 b/src/lib/libcrypto/man/X509_NAME_hash.3
index 55de9bbe2e..2e03f41ed2 100644
--- a/src/lib/libcrypto/man/X509_NAME_hash.3
+++ b/src/lib/libcrypto/man/X509_NAME_hash.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_NAME_hash.3,v 1.4 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: X509_NAME_hash.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 17 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_NAME_HASH 3 18.Dt X509_NAME_HASH 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -31,6 +31,7 @@
31.\" The type is called "Name" with capital "N", not "name". 31.\" The type is called "Name" with capital "N", not "name".
32.Nd calculate SHA-1 or MD5 hashes of X.501 Name objects 32.Nd calculate SHA-1 or MD5 hashes of X.501 Name objects
33.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Lb libcrypto
34.In openssl/x509.h 35.In openssl/x509.h
35.Ft unsigned long 36.Ft unsigned long
36.Fn X509_NAME_hash "X509_NAME *name" 37.Fn X509_NAME_hash "X509_NAME *name"
diff --git a/src/lib/libcrypto/man/X509_NAME_new.3 b/src/lib/libcrypto/man/X509_NAME_new.3
index 3a4786a9ae..279df816fe 100644
--- a/src/lib/libcrypto/man/X509_NAME_new.3
+++ b/src/lib/libcrypto/man/X509_NAME_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_NAME_new.3,v 1.9 2021/07/20 17:31:32 schwarze Exp $ 1.\" $OpenBSD: X509_NAME_new.3,v 1.10 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 20 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_NAME_NEW 3 18.Dt X509_NAME_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.\" The type in called "Name" with capital "N", not "name". 25.\" The type in called "Name" with capital "N", not "name".
26.Nd X.501 Name object 26.Nd X.501 Name object
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/x509.h 29.In openssl/x509.h
29.Ft X509_NAME * 30.Ft X509_NAME *
30.Fn X509_NAME_new void 31.Fn X509_NAME_new void
diff --git a/src/lib/libcrypto/man/X509_NAME_print_ex.3 b/src/lib/libcrypto/man/X509_NAME_print_ex.3
index fc06a717cc..845428b3fb 100644
--- a/src/lib/libcrypto/man/X509_NAME_print_ex.3
+++ b/src/lib/libcrypto/man/X509_NAME_print_ex.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_NAME_print_ex.3,v 1.17 2025/03/09 16:45:31 tb Exp $ 1.\" $OpenBSD: X509_NAME_print_ex.3,v 1.18 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: March 9 2025 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt X509_NAME_PRINT_EX 3 54.Dt X509_NAME_PRINT_EX 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -59,6 +59,7 @@
59.Nm X509_NAME_oneline 59.Nm X509_NAME_oneline
60.Nd X509_NAME printing routines 60.Nd X509_NAME printing routines
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/x509.h 63.In openssl/x509.h
63.Ft int 64.Ft int
64.Fo X509_NAME_print_ex 65.Fo X509_NAME_print_ex
diff --git a/src/lib/libcrypto/man/X509_OBJECT_get0_X509.3 b/src/lib/libcrypto/man/X509_OBJECT_get0_X509.3
index 56b3926a8b..1b0de39265 100644
--- a/src/lib/libcrypto/man/X509_OBJECT_get0_X509.3
+++ b/src/lib/libcrypto/man/X509_OBJECT_get0_X509.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_OBJECT_get0_X509.3,v 1.16 2025/03/08 17:02:59 tb Exp $ 1.\" $OpenBSD: X509_OBJECT_get0_X509.3,v 1.17 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2018, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2018, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 8 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_OBJECT_GET0_X509 3 18.Dt X509_OBJECT_GET0_X509 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.Nm X509_OBJECT_retrieve_match 28.Nm X509_OBJECT_retrieve_match
29.Nd certificate, CRL, private key, and string wrapper for certificate stores 29.Nd certificate, CRL, private key, and string wrapper for certificate stores
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/x509_vfy.h 32.In openssl/x509_vfy.h
32.Ft X509_LOOKUP_TYPE 33.Ft X509_LOOKUP_TYPE
33.Fo X509_OBJECT_get_type 34.Fo X509_OBJECT_get_type
diff --git a/src/lib/libcrypto/man/X509_PKEY_new.3 b/src/lib/libcrypto/man/X509_PKEY_new.3
deleted file mode 100644
index 253b0f6db5..0000000000
--- a/src/lib/libcrypto/man/X509_PKEY_new.3
+++ /dev/null
@@ -1,92 +0,0 @@
1.\" $OpenBSD: X509_PKEY_new.3,v 1.1 2021/10/19 10:39:33 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: October 19 2021 $
18.Dt X509_PKEY_NEW 3
19.Os
20.Sh NAME
21.Nm X509_PKEY_new ,
22.Nm X509_PKEY_free
23.Nd X.509 private key wrapper object
24.Sh SYNOPSIS
25.In openssl/x509.h
26.Ft X509_PKEY *
27.Fn X509_PKEY_new void
28.Ft void
29.Fn X509_PKEY_free "X509_PKEY *wrapper"
30.Sh DESCRIPTION
31.Vt X509_PKEY
32is a reference-counted wrapper object that can store
33.Bl -bullet -width 1n
34.It
35a pointer to an encrypted and ASN.1-encoded private key
36.It
37a pointer to an
38.Vt EVP_PKEY
39object representing the same key in decrypted form
40.It
41a pointer to an
42.Vt X509_ALGOR
43object identifying the algorithm used by the key
44.El
45.Pp
46The object may contain only the encrypted key or only the decrypted
47key or both.
48.Pp
49.Vt X509_PKEY
50is used as a sub-object of the
51.Vt X509_INFO
52object created by
53.Xr PEM_X509_INFO_read_bio 3
54if the PEM file contains any RSA, DSA, or EC PRIVATE KEY object.
55.Pp
56.Fn X509_PKEY_new
57allocates and initializes an empty
58.Vt X509_PKEY
59object and sets its reference count to 1.
60.Pp
61.Fn X509_PKEY_free
62decrements the reference count of the
63.Fa wrapper
64object by 1.
65If the reference count reaches 0,
66it frees all internal objects allocated by the
67.Fa wrapper
68as well as the storage needed for the
69.Fa wrapper
70object itself.
71If
72.Fa wrapper
73is a
74.Dv NULL
75pointer, no action occurs.
76.Sh RETURN VALUES
77.Fn X509_PKEY_new
78returns a pointer to the new
79.Vt X509_PKEY
80object or
81.Dv NULL
82if memory allocation fails.
83.Sh SEE ALSO
84.Xr EVP_PKEY_new 3 ,
85.Xr PEM_X509_INFO_read 3 ,
86.Xr X509_INFO_new 3
87.Sh HISTORY
88.Fn X509_PKEY_new
89and
90.Fn X509_PKEY_free
91first appeared in SSLeay 0.6.0 and have been available since
92.Ox 2.4 .
diff --git a/src/lib/libcrypto/man/X509_PUBKEY_new.3 b/src/lib/libcrypto/man/X509_PUBKEY_new.3
index df1c50bda2..1ef1afbc34 100644
--- a/src/lib/libcrypto/man/X509_PUBKEY_new.3
+++ b/src/lib/libcrypto/man/X509_PUBKEY_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_PUBKEY_new.3,v 1.18 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: X509_PUBKEY_new.3,v 1.19 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 6 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt X509_PUBKEY_NEW 3 69.Dt X509_PUBKEY_NEW 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -86,6 +86,7 @@
86.Nm X509_PUBKEY_get0_param 86.Nm X509_PUBKEY_get0_param
87.Nd X.509 SubjectPublicKeyInfo structure 87.Nd X.509 SubjectPublicKeyInfo structure
88.Sh SYNOPSIS 88.Sh SYNOPSIS
89.Lb libcrypto
89.In openssl/x509.h 90.In openssl/x509.h
90.Ft X509_PUBKEY * 91.Ft X509_PUBKEY *
91.Fn X509_PUBKEY_new void 92.Fn X509_PUBKEY_new void
diff --git a/src/lib/libcrypto/man/X509_PURPOSE_set.3 b/src/lib/libcrypto/man/X509_PURPOSE_set.3
index 1f723e9b9f..cb955f392c 100644
--- a/src/lib/libcrypto/man/X509_PURPOSE_set.3
+++ b/src/lib/libcrypto/man/X509_PURPOSE_set.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_PURPOSE_set.3,v 1.1 2021/07/23 14:27:32 schwarze Exp $ 1.\" $OpenBSD: X509_PURPOSE_set.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 23 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_PURPOSE_SET 3 18.Dt X509_PURPOSE_SET 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -31,6 +31,7 @@
31.Nm X509_PURPOSE_get_trust 31.Nm X509_PURPOSE_get_trust
32.Nd purpose objects, indices, and identifiers 32.Nd purpose objects, indices, and identifiers
33.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Lb libcrypto
34.In openssl/x509v3.h 35.In openssl/x509v3.h
35.Ft int 36.Ft int
36.Fo X509_PURPOSE_set 37.Fo X509_PURPOSE_set
diff --git a/src/lib/libcrypto/man/X509_REQ_add1_attr.3 b/src/lib/libcrypto/man/X509_REQ_add1_attr.3
index f9b602dbef..6beb024039 100644
--- a/src/lib/libcrypto/man/X509_REQ_add1_attr.3
+++ b/src/lib/libcrypto/man/X509_REQ_add1_attr.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_REQ_add1_attr.3,v 1.4 2024/09/02 07:56:28 tb Exp $ 1.\" $OpenBSD: X509_REQ_add1_attr.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 2 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_REQ_ADD1_ATTR 3 18.Dt X509_REQ_ADD1_ATTR 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -29,6 +29,7 @@
29.Nm X509_REQ_get_attr_by_NID 29.Nm X509_REQ_get_attr_by_NID
30.Nd X.501 Attributes of PKCS#10 certification requests 30.Nd X.501 Attributes of PKCS#10 certification requests
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libcrypto
32.In openssl/x509.h 33.In openssl/x509.h
33.Ft int 34.Ft int
34.Fo X509_REQ_add1_attr 35.Fo X509_REQ_add1_attr
diff --git a/src/lib/libcrypto/man/X509_REQ_add_extensions.3 b/src/lib/libcrypto/man/X509_REQ_add_extensions.3
index ff33edf474..804e787947 100644
--- a/src/lib/libcrypto/man/X509_REQ_add_extensions.3
+++ b/src/lib/libcrypto/man/X509_REQ_add_extensions.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_REQ_add_extensions.3,v 1.2 2024/08/18 11:04:55 tb Exp $ 1.\" $OpenBSD: X509_REQ_add_extensions.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 18 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_REQ_ADD_EXTENSIONS 3 18.Dt X509_REQ_ADD_EXTENSIONS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm X509_REQ_extension_nid 24.Nm X509_REQ_extension_nid
25.Nd extensions in certification requests 25.Nd extensions in certification requests
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509.h 28.In openssl/x509.h
28.Ft int 29.Ft int
29.Fo X509_REQ_add_extensions 30.Fo X509_REQ_add_extensions
diff --git a/src/lib/libcrypto/man/X509_REQ_new.3 b/src/lib/libcrypto/man/X509_REQ_new.3
index 0a5828d5d4..a62f2c3acb 100644
--- a/src/lib/libcrypto/man/X509_REQ_new.3
+++ b/src/lib/libcrypto/man/X509_REQ_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_REQ_new.3,v 1.11 2021/10/29 09:42:07 schwarze Exp $ 1.\" $OpenBSD: X509_REQ_new.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 29 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_REQ_NEW 3 18.Dt X509_REQ_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm X509_REQ_INFO_free 26.Nm X509_REQ_INFO_free
27.Nd PKCS#10 certification requests 27.Nd PKCS#10 certification requests
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/x509.h 30.In openssl/x509.h
30.Ft X509_REQ * 31.Ft X509_REQ *
31.Fn X509_REQ_new void 32.Fn X509_REQ_new void
diff --git a/src/lib/libcrypto/man/X509_REQ_print_ex.3 b/src/lib/libcrypto/man/X509_REQ_print_ex.3
index eee06abb21..8d87396b14 100644
--- a/src/lib/libcrypto/man/X509_REQ_print_ex.3
+++ b/src/lib/libcrypto/man/X509_REQ_print_ex.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_REQ_print_ex.3,v 1.3 2025/03/09 14:02:46 tb Exp $ 1.\" $OpenBSD: X509_REQ_print_ex.3,v 1.4 2025/06/08 22:30:52 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 9 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_REQ_PRINT_EX 3 18.Dt X509_REQ_PRINT_EX 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,8 @@
23.Nm X509_REQ_print_fp 23.Nm X509_REQ_print_fp
24.Nd pretty-print a PKCS#10 certification request 24.Nd pretty-print a PKCS#10 certification request
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
27.In openssl/x509.h
26.Ft int 28.Ft int
27.Fo X509_REQ_print_ex 29.Fo X509_REQ_print_ex
28.Fa "BIO *bio" 30.Fa "BIO *bio"
diff --git a/src/lib/libcrypto/man/X509_REVOKED_new.3 b/src/lib/libcrypto/man/X509_REVOKED_new.3
index c1a50d1c9a..6dffcfd03e 100644
--- a/src/lib/libcrypto/man/X509_REVOKED_new.3
+++ b/src/lib/libcrypto/man/X509_REVOKED_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_REVOKED_new.3,v 1.12 2021/07/19 13:16:43 schwarze Exp $ 1.\" $OpenBSD: X509_REVOKED_new.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/X509_CRL_get0_by_serial cdd6c8c5 Mar 20 12:29:37 2017 +0100 3.\" OpenSSL man3/X509_CRL_get0_by_serial cdd6c8c5 Mar 20 12:29:37 2017 +0100
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: July 19 2021 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt X509_REVOKED_NEW 3 70.Dt X509_REVOKED_NEW 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -79,6 +79,7 @@
79.Nm X509_REVOKED_set_revocationDate 79.Nm X509_REVOKED_set_revocationDate
80.Nd create, change, and inspect an X.509 CRL revoked entry 80.Nd create, change, and inspect an X.509 CRL revoked entry
81.Sh SYNOPSIS 81.Sh SYNOPSIS
82.Lb libcrypto
82.In openssl/x509.h 83.In openssl/x509.h
83.Ft X509_REVOKED * 84.Ft X509_REVOKED *
84.Fn X509_REVOKED_new void 85.Fn X509_REVOKED_new void
diff --git a/src/lib/libcrypto/man/X509_SIG_get0.3 b/src/lib/libcrypto/man/X509_SIG_get0.3
index 456261ca3f..339fcc0cf5 100644
--- a/src/lib/libcrypto/man/X509_SIG_get0.3
+++ b/src/lib/libcrypto/man/X509_SIG_get0.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_SIG_get0.3,v 1.1 2021/10/23 15:39:06 tb Exp $ 1.\" $OpenBSD: X509_SIG_get0.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: October 23 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt X509_SIG_GET0 3 53.Dt X509_SIG_GET0 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm X509_SIG_getm 57.Nm X509_SIG_getm
58.Nd DigestInfo functions 58.Nd DigestInfo functions
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/x509.h 61.In openssl/x509.h
61.Ft void 62.Ft void
62.Fo X509_SIG_get0 63.Fo X509_SIG_get0
diff --git a/src/lib/libcrypto/man/X509_SIG_new.3 b/src/lib/libcrypto/man/X509_SIG_new.3
index 8e6b29dea5..8fafc00c98 100644
--- a/src/lib/libcrypto/man/X509_SIG_new.3
+++ b/src/lib/libcrypto/man/X509_SIG_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_SIG_new.3,v 1.5 2021/10/27 11:24:47 schwarze Exp $ 1.\" $OpenBSD: X509_SIG_new.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 27 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_SIG_NEW 3 18.Dt X509_SIG_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509_SIG_free 22.Nm X509_SIG_free
23.Nd PKCS#7 digest information 23.Nd PKCS#7 digest information
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509.h 26.In openssl/x509.h
26.Ft X509_SIG * 27.Ft X509_SIG *
27.Fn X509_SIG_new void 28.Fn X509_SIG_new void
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3 b/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3
index 1f221563cb..5eb2bfe8cb 100644
--- a/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_get_error.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_CTX_get_error.3,v 1.28 2023/06/06 16:20:13 schwarze Exp $ 1.\" $OpenBSD: X509_STORE_CTX_get_error.3,v 1.29 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/X509_STORE_CTX_get_error 24a535ea Sep 22 13:14:20 2020 +0100 3.\" OpenSSL man3/X509_STORE_CTX_get_error 24a535ea Sep 22 13:14:20 2020 +0100
4.\" OpenSSL man3/X509_STORE_CTX_new 24a535ea Sep 22 13:14:20 2020 +0100 4.\" OpenSSL man3/X509_STORE_CTX_new 24a535ea Sep 22 13:14:20 2020 +0100
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: June 6 2023 $ 71.Dd $Mdocdate: June 8 2025 $
72.Dt X509_STORE_CTX_GET_ERROR 3 72.Dt X509_STORE_CTX_GET_ERROR 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -89,6 +89,7 @@
89.Nm X509_verify_cert_error_string 89.Nm X509_verify_cert_error_string
90.Nd get or set certificate verification status information 90.Nd get or set certificate verification status information
91.Sh SYNOPSIS 91.Sh SYNOPSIS
92.Lb libcrypto
92.In openssl/x509_vfy.h 93.In openssl/x509_vfy.h
93.Ft int 94.Ft int
94.Fo X509_STORE_CTX_get_error 95.Fo X509_STORE_CTX_get_error
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3 b/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3
index bfec65a123..1c34efa947 100644
--- a/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_CTX_get_ex_new_index.3,v 1.6 2021/07/29 08:32:13 schwarze Exp $ 1.\" $OpenBSD: X509_STORE_CTX_get_ex_new_index.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: July 29 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_STORE_CTX_GET_EX_NEW_INDEX 3 52.Dt X509_STORE_CTX_GET_EX_NEW_INDEX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm X509_STORE_CTX_get_app_data 59.Nm X509_STORE_CTX_get_app_data
60.Nd add application specific data to X509_STORE_CTX structures 60.Nd add application specific data to X509_STORE_CTX structures
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libcrypto
62.In openssl/x509_vfy.h 63.In openssl/x509_vfy.h
63.Ft int 64.Ft int
64.Fo X509_STORE_CTX_get_ex_new_index 65.Fo X509_STORE_CTX_get_ex_new_index
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_new.3 b/src/lib/libcrypto/man/X509_STORE_CTX_new.3
index 96af7a8afb..4c0f8c5857 100644
--- a/src/lib/libcrypto/man/X509_STORE_CTX_new.3
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_CTX_new.3,v 1.27 2022/11/16 14:55:40 schwarze Exp $ 1.\" $OpenBSD: X509_STORE_CTX_new.3,v 1.28 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100 2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: November 16 2022 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt X509_STORE_CTX_NEW 3 71.Dt X509_STORE_CTX_NEW 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -89,6 +89,7 @@
89.\" X509_STORE_CTX_set_verify moved to X509_STORE_CTX_set_verify(3) 89.\" X509_STORE_CTX_set_verify moved to X509_STORE_CTX_set_verify(3)
90.Nd X509_STORE_CTX initialisation 90.Nd X509_STORE_CTX initialisation
91.Sh SYNOPSIS 91.Sh SYNOPSIS
92.Lb libcrypto
92.In openssl/x509_vfy.h 93.In openssl/x509_vfy.h
93.Ft X509_STORE_CTX * 94.Ft X509_STORE_CTX *
94.Fn X509_STORE_CTX_new void 95.Fn X509_STORE_CTX_new void
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
index 04bb202bac..028d4da810 100644
--- a/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_CTX_set_flags.3,v 1.8 2024/08/29 20:21:10 tb Exp $ 1.\" $OpenBSD: X509_STORE_CTX_set_flags.3,v 1.9 2025/06/08 22:37:23 schwarze Exp $
2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100 2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: August 29 2024 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt X509_STORE_CTX_SET_FLAGS 3 71.Dt X509_STORE_CTX_SET_FLAGS 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -76,13 +76,12 @@
76.Nm X509_STORE_CTX_set_depth , 76.Nm X509_STORE_CTX_set_depth ,
77.Nm X509_STORE_CTX_set_trust , 77.Nm X509_STORE_CTX_set_trust ,
78.Nm X509_STORE_CTX_set_purpose , 78.Nm X509_STORE_CTX_set_purpose ,
79.\" .Nm X509_STORE_CTX_purpose_inherit is intentionally undocumented
80.\" because it will be removed in the next major bump.
81.Nm X509_STORE_CTX_get0_param , 79.Nm X509_STORE_CTX_get0_param ,
82.Nm X509_STORE_CTX_set0_param , 80.Nm X509_STORE_CTX_set0_param ,
83.Nm X509_STORE_CTX_set_default 81.Nm X509_STORE_CTX_set_default
84.Nd X509_STORE_CTX parameter initialisation 82.Nd X509_STORE_CTX parameter initialisation
85.Sh SYNOPSIS 83.Sh SYNOPSIS
84.Lb libcrypto
86.In openssl/x509_vfy.h 85.In openssl/x509_vfy.h
87.Ft void 86.Ft void
88.Fo X509_STORE_CTX_set_flags 87.Fo X509_STORE_CTX_set_flags
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3
index 8c27deea5d..4a319ed8bb 100644
--- a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_CTX_set_verify.3,v 1.8 2024/06/07 05:51:39 tb Exp $ 1.\" $OpenBSD: X509_STORE_CTX_set_verify.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021, 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" Copyright (c) 2023 Job Snijders <job@openbsd.org> 4.\" Copyright (c) 2023 Job Snijders <job@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: June 7 2024 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt X509_STORE_CTX_SET_VERIFY 3 19.Dt X509_STORE_CTX_SET_VERIFY 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -31,6 +31,7 @@
31.Nm X509_STORE_CTX_get_check_issued 31.Nm X509_STORE_CTX_get_check_issued
32.Nd user-defined certificate chain verification function 32.Nd user-defined certificate chain verification function
33.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Lb libcrypto
34.In openssl/x509_vfy.h 35.In openssl/x509_vfy.h
35.Ft typedef int 36.Ft typedef int
36.Fo (*X509_STORE_CTX_verify_fn) 37.Fo (*X509_STORE_CTX_verify_fn)
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3
index 0fe086b721..29f1e79b62 100644
--- a/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_set_verify_cb.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_CTX_set_verify_cb.3,v 1.12 2023/05/30 07:37:34 op Exp $ 1.\" $OpenBSD: X509_STORE_CTX_set_verify_cb.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 2.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: May 30 2023 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt X509_STORE_CTX_SET_VERIFY_CB 3 70.Dt X509_STORE_CTX_SET_VERIFY_CB 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -75,6 +75,7 @@
75.Nm X509_STORE_CTX_get_verify_cb 75.Nm X509_STORE_CTX_get_verify_cb
76.Nd set and retrieve verification callback 76.Nd set and retrieve verification callback
77.Sh SYNOPSIS 77.Sh SYNOPSIS
78.Lb libcrypto
78.In openssl/x509_vfy.h 79.In openssl/x509_vfy.h
79.Ft typedef int 80.Ft typedef int
80.Fo (*X509_STORE_CTX_verify_cb) 81.Fo (*X509_STORE_CTX_verify_cb)
diff --git a/src/lib/libcrypto/man/X509_STORE_get_by_subject.3 b/src/lib/libcrypto/man/X509_STORE_get_by_subject.3
index 0f6fbd8410..a8379ad5cb 100644
--- a/src/lib/libcrypto/man/X509_STORE_get_by_subject.3
+++ b/src/lib/libcrypto/man/X509_STORE_get_by_subject.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_get_by_subject.3,v 1.6 2024/05/12 05:08:59 tb Exp $ 1.\" $OpenBSD: X509_STORE_get_by_subject.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021, 2023 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021, 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: May 12 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_STORE_GET_BY_SUBJECT 3 18.Dt X509_STORE_GET_BY_SUBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.Nm X509_STORE_get1_crls 28.Nm X509_STORE_get1_crls
29.Nd retrieve objects from a certificate store 29.Nd retrieve objects from a certificate store
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/x509_vfy.h 32.In openssl/x509_vfy.h
32.Ft int 33.Ft int
33.Fo X509_STORE_CTX_get_by_subject 34.Fo X509_STORE_CTX_get_by_subject
diff --git a/src/lib/libcrypto/man/X509_STORE_load_locations.3 b/src/lib/libcrypto/man/X509_STORE_load_locations.3
index a8177b0fd4..d876ef831a 100644
--- a/src/lib/libcrypto/man/X509_STORE_load_locations.3
+++ b/src/lib/libcrypto/man/X509_STORE_load_locations.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_load_locations.3,v 1.12 2024/09/02 07:20:21 tb Exp $ 1.\" $OpenBSD: X509_STORE_load_locations.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000 3.\" OpenSSL X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000
4.\" 4.\"
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: September 2 2024 $ 19.Dd $Mdocdate: June 8 2025 $
20.Dt X509_STORE_LOAD_LOCATIONS 3 20.Dt X509_STORE_LOAD_LOCATIONS 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -26,6 +26,7 @@
26.Nm X509_STORE_add_lookup 26.Nm X509_STORE_add_lookup
27.Nd configure files and directories used by a certificate store 27.Nd configure files and directories used by a certificate store
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/x509_vfy.h 30.In openssl/x509_vfy.h
30.Ft int 31.Ft int
31.Fo X509_STORE_load_locations 32.Fo X509_STORE_load_locations
diff --git a/src/lib/libcrypto/man/X509_STORE_new.3 b/src/lib/libcrypto/man/X509_STORE_new.3
index a17da03a41..e1d146da43 100644
--- a/src/lib/libcrypto/man/X509_STORE_new.3
+++ b/src/lib/libcrypto/man/X509_STORE_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_new.3,v 1.7 2021/11/17 16:08:32 schwarze Exp $ 1.\" $OpenBSD: X509_STORE_new.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: November 17 2021 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt X509_STORE_NEW 3 71.Dt X509_STORE_NEW 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -76,6 +76,7 @@
76.Nm X509_STORE_free 76.Nm X509_STORE_free
77.Nd allocate and free X.509 certificate stores 77.Nd allocate and free X.509 certificate stores
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/x509_vfy.h 80.In openssl/x509_vfy.h
80.Ft X509_STORE * 81.Ft X509_STORE *
81.Fn X509_STORE_new void 82.Fn X509_STORE_new void
diff --git a/src/lib/libcrypto/man/X509_STORE_set1_param.3 b/src/lib/libcrypto/man/X509_STORE_set1_param.3
index 527fe652e5..d96a33a8fa 100644
--- a/src/lib/libcrypto/man/X509_STORE_set1_param.3
+++ b/src/lib/libcrypto/man/X509_STORE_set1_param.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_set1_param.3,v 1.22 2024/03/14 22:19:12 tb Exp $ 1.\" $OpenBSD: X509_STORE_set1_param.3,v 1.23 2025/06/08 22:40:30 schwarze Exp $
2.\" content checked up to: 2.\" content checked up to:
3.\" OpenSSL man3/X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000 3.\" OpenSSL man3/X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000
4.\" OpenSSL man3/X509_STORE_get0_param e90fc053 Jul 15 09:39:45 2017 -0400 4.\" OpenSSL man3/X509_STORE_get0_param e90fc053 Jul 15 09:39:45 2017 -0400
@@ -17,7 +17,7 @@
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\" 19.\"
20.Dd $Mdocdate: March 14 2024 $ 20.Dd $Mdocdate: June 8 2025 $
21.Dt X509_STORE_SET1_PARAM 3 21.Dt X509_STORE_SET1_PARAM 3
22.Os 22.Os
23.Sh NAME 23.Sh NAME
@@ -36,6 +36,7 @@
36.Nm X509_STORE_get_ex_data 36.Nm X509_STORE_get_ex_data
37.Nd get and set X509_STORE data 37.Nd get and set X509_STORE data
38.Sh SYNOPSIS 38.Sh SYNOPSIS
39.Lb libcrypto
39.In openssl/x509_vfy.h 40.In openssl/x509_vfy.h
40.Ft int 41.Ft int
41.Fo X509_STORE_set1_param 42.Fo X509_STORE_set1_param
diff --git a/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 b/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3
index bdd5ea5044..a09e6741a2 100644
--- a/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3
+++ b/src/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_set_verify_cb_func.3,v 1.12 2022/11/16 14:51:08 schwarze Exp $ 1.\" $OpenBSD: X509_STORE_set_verify_cb_func.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" selective merge up to: OpenSSL 315c47e0 Dec 1 14:22:16 2020 +0100 3.\" selective merge up to: OpenSSL 315c47e0 Dec 1 14:22:16 2020 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: November 16 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt X509_STORE_SET_VERIFY_CB_FUNC 3 53.Dt X509_STORE_SET_VERIFY_CB_FUNC 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -58,6 +58,7 @@
58.Nm X509_STORE_get_verify_cb 58.Nm X509_STORE_get_verify_cb
59.Nd set verification callback 59.Nd set verification callback
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/x509_vfy.h 62.In openssl/x509_vfy.h
62.Ft void 63.Ft void
63.Fo X509_STORE_set_verify_cb 64.Fo X509_STORE_set_verify_cb
diff --git a/src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3 b/src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3
index a22d2b1b4b..333b3860e0 100644
--- a/src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3
+++ b/src/lib/libcrypto/man/X509_VERIFY_PARAM_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_VERIFY_PARAM_new.3,v 1.5 2023/05/24 09:57:50 tb Exp $ 1.\" $OpenBSD: X509_VERIFY_PARAM_new.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2018, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2018, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: May 24 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_VERIFY_PARAM_NEW 3 18.Dt X509_VERIFY_PARAM_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -38,6 +38,7 @@
38.\" X509_VP_FLAG_ONCE 38.\" X509_VP_FLAG_ONCE
39.Nd X509 verification parameter objects 39.Nd X509 verification parameter objects
40.Sh SYNOPSIS 40.Sh SYNOPSIS
41.Lb libcrypto
41.In openssl/x509_vfy.h 42.In openssl/x509_vfy.h
42.Ft X509_VERIFY_PARAM * 43.Ft X509_VERIFY_PARAM *
43.Fo X509_VERIFY_PARAM_new 44.Fo X509_VERIFY_PARAM_new
diff --git a/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 b/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
index a0ae839f9a..e21d1122a9 100644
--- a/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
+++ b/src/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.29 2023/04/30 19:40:23 tb Exp $ 1.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.30 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL d33def66 Feb 9 14:17:13 2016 -0500 2.\" full merge up to: OpenSSL d33def66 Feb 9 14:17:13 2016 -0500
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: April 30 2023 $ 71.Dd $Mdocdate: June 8 2025 $
72.Dt X509_VERIFY_PARAM_SET_FLAGS 3 72.Dt X509_VERIFY_PARAM_SET_FLAGS 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -95,6 +95,7 @@
95.Nm X509_VERIFY_PARAM_set1_ip_asc 95.Nm X509_VERIFY_PARAM_set1_ip_asc
96.Nd X509 verification parameters 96.Nd X509 verification parameters
97.Sh SYNOPSIS 97.Sh SYNOPSIS
98.Lb libcrypto
98.In openssl/x509_vfy.h 99.In openssl/x509_vfy.h
99.Ft const char * 100.Ft const char *
100.Fo X509_VERIFY_PARAM_get0_name 101.Fo X509_VERIFY_PARAM_get0_name
diff --git a/src/lib/libcrypto/man/X509_add1_trust_object.3 b/src/lib/libcrypto/man/X509_add1_trust_object.3
index 067bf64464..e1ca67a8f3 100644
--- a/src/lib/libcrypto/man/X509_add1_trust_object.3
+++ b/src/lib/libcrypto/man/X509_add1_trust_object.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_add1_trust_object.3,v 1.4 2024/09/02 08:04:32 tb Exp $ 1.\" $OpenBSD: X509_add1_trust_object.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 2 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_ADD1_TRUST_OBJECT 3 18.Dt X509_ADD1_TRUST_OBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm X509_reject_clear 24.Nm X509_reject_clear
25.Nd mark an X.509 certificate as intended for a specific purpose 25.Nd mark an X.509 certificate as intended for a specific purpose
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509.h 28.In openssl/x509.h
28.Ft int 29.Ft int
29.Fo X509_add1_trust_object 30.Fo X509_add1_trust_object
diff --git a/src/lib/libcrypto/man/X509_check_ca.3 b/src/lib/libcrypto/man/X509_check_ca.3
index 114bac69e7..2aa496b6ff 100644
--- a/src/lib/libcrypto/man/X509_check_ca.3
+++ b/src/lib/libcrypto/man/X509_check_ca.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_check_ca.3,v 1.7 2022/05/10 19:44:29 tb Exp $ 1.\" $OpenBSD: X509_check_ca.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Victor B. Wagner <vitus@cryptocom.ru>. 4.\" This file was written by Victor B. Wagner <vitus@cryptocom.ru>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 10 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_CHECK_CA 3 52.Dt X509_CHECK_CA 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm X509_check_ca 55.Nm X509_check_ca
56.Nd check whether a certificate is a CA certificate 56.Nd check whether a certificate is a CA certificate
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/x509v3.h 59.In openssl/x509v3.h
59.Ft int 60.Ft int
60.Fo X509_check_ca 61.Fo X509_check_ca
diff --git a/src/lib/libcrypto/man/X509_check_host.3 b/src/lib/libcrypto/man/X509_check_host.3
index dbc56c0d21..be3190b2d2 100644
--- a/src/lib/libcrypto/man/X509_check_host.3
+++ b/src/lib/libcrypto/man/X509_check_host.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_check_host.3,v 1.6 2020/09/17 08:04:22 schwarze Exp $ 1.\" $OpenBSD: X509_check_host.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL a09e4d24 Jun 12 01:56:31 2014 -0400 2.\" full merge up to: OpenSSL a09e4d24 Jun 12 01:56:31 2014 -0400
3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200 3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
4.\" 4.\"
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: September 17 2020 $ 54.Dd $Mdocdate: June 8 2025 $
55.Dt X509_CHECK_HOST 3 55.Dt X509_CHECK_HOST 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -61,6 +61,7 @@
61.Nm X509_check_ip_asc 61.Nm X509_check_ip_asc
62.Nd X.509 certificate matching 62.Nd X.509 certificate matching
63.Sh SYNOPSIS 63.Sh SYNOPSIS
64.Lb libcrypto
64.In openssl/x509v3.h 65.In openssl/x509v3.h
65.Ft int 66.Ft int
66.Fo X509_check_host 67.Fo X509_check_host
diff --git a/src/lib/libcrypto/man/X509_check_issued.3 b/src/lib/libcrypto/man/X509_check_issued.3
index f8c2a5297a..24457674d5 100644
--- a/src/lib/libcrypto/man/X509_check_issued.3
+++ b/src/lib/libcrypto/man/X509_check_issued.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_check_issued.3,v 1.4 2019/06/06 01:06:59 schwarze Exp $ 1.\" $OpenBSD: X509_check_issued.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Victor B. Wagner <vitus@cryptocom.ru>. 4.\" This file was written by Victor B. Wagner <vitus@cryptocom.ru>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 6 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_CHECK_ISSUED 3 52.Dt X509_CHECK_ISSUED 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm X509_check_issued 55.Nm X509_check_issued
56.Nd check whether a certificate was issued using a given CA certificate 56.Nd check whether a certificate was issued using a given CA certificate
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/x509v3.h 59.In openssl/x509v3.h
59.Ft int 60.Ft int
60.Fo X509_check_issued 61.Fo X509_check_issued
diff --git a/src/lib/libcrypto/man/X509_check_private_key.3 b/src/lib/libcrypto/man/X509_check_private_key.3
index 31df2126cc..61ff091728 100644
--- a/src/lib/libcrypto/man/X509_check_private_key.3
+++ b/src/lib/libcrypto/man/X509_check_private_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_check_private_key.3,v 1.6 2019/06/06 01:06:59 schwarze Exp $ 1.\" $OpenBSD: X509_check_private_key.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL X509_check_private_key.pod 09ddb878 Jun 5 03:56:07 2017 +0800 2.\" OpenSSL X509_check_private_key.pod 09ddb878 Jun 5 03:56:07 2017 +0800
3.\" 3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: June 6 2019 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt X509_CHECK_PRIVATE_KEY 3 19.Dt X509_CHECK_PRIVATE_KEY 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -23,6 +23,7 @@
23.Nm X509_REQ_check_private_key 23.Nm X509_REQ_check_private_key
24.Nd compare public key components 24.Nd compare public key components
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/x509.h 27.In openssl/x509.h
27.Ft int 28.Ft int
28.Fo X509_check_private_key 29.Fo X509_check_private_key
diff --git a/src/lib/libcrypto/man/X509_check_purpose.3 b/src/lib/libcrypto/man/X509_check_purpose.3
index 8fea6679fc..86ee53f559 100644
--- a/src/lib/libcrypto/man/X509_check_purpose.3
+++ b/src/lib/libcrypto/man/X509_check_purpose.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_check_purpose.3,v 1.12 2024/09/02 08:04:32 tb Exp $ 1.\" $OpenBSD: X509_check_purpose.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 2 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_CHECK_PURPOSE 3 18.Dt X509_CHECK_PURPOSE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm X509_check_purpose 21.Nm X509_check_purpose
22.Nd check intended usage of a public key 22.Nd check intended usage of a public key
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/x509v3.h 25.In openssl/x509v3.h
25.Ft int 26.Ft int
26.Fo X509_check_purpose 27.Fo X509_check_purpose
diff --git a/src/lib/libcrypto/man/X509_cmp.3 b/src/lib/libcrypto/man/X509_cmp.3
index b1cdec1773..e025f5c8c0 100644
--- a/src/lib/libcrypto/man/X509_cmp.3
+++ b/src/lib/libcrypto/man/X509_cmp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_cmp.3,v 1.4 2024/06/07 14:00:09 job Exp $ 1.\" $OpenBSD: X509_cmp.3,v 1.5 2025/06/08 22:37:23 schwarze Exp $
2.\" full merge up to: OpenSSL ea5d4b89 Jun 6 11:42:02 2019 +0800 2.\" full merge up to: OpenSSL ea5d4b89 Jun 6 11:42:02 2019 +0800
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: June 7 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt X509_CMP 3 69.Dt X509_CMP 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -79,10 +79,8 @@
79.Nm X509_CRL_cmp , 79.Nm X509_CRL_cmp ,
80.Nm X509_CRL_match 80.Nm X509_CRL_match
81.Nd compare X.509 certificates and related values 81.Nd compare X.509 certificates and related values
82.\" The function name_cmp() is intentionally undocumented.
83.\" It was a mistake to make it public in the first place,
84.\" and it is no longer part of the public API in OpenSSL 1.1.
85.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libcrypto
86.In openssl/x509.h 84.In openssl/x509.h
87.Ft int 85.Ft int
88.Fo X509_cmp 86.Fo X509_cmp
diff --git a/src/lib/libcrypto/man/X509_cmp_time.3 b/src/lib/libcrypto/man/X509_cmp_time.3
index bb430dfbb7..2ac584ad09 100644
--- a/src/lib/libcrypto/man/X509_cmp_time.3
+++ b/src/lib/libcrypto/man/X509_cmp_time.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_cmp_time.3,v 1.12 2024/03/05 18:30:40 tb Exp $ 1.\" $OpenBSD: X509_cmp_time.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: March 5 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt X509_CMP_TIME 3 69.Dt X509_CMP_TIME 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -76,6 +76,7 @@
76.Nm X509_gmtime_adj 76.Nm X509_gmtime_adj
77.Nd ASN.1 Time utilities 77.Nd ASN.1 Time utilities
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/x509.h 80.In openssl/x509.h
80.Ft int 81.Ft int
81.Fo X509_cmp_time 82.Fo X509_cmp_time
diff --git a/src/lib/libcrypto/man/X509_digest.3 b/src/lib/libcrypto/man/X509_digest.3
index 7627e07731..991d1990b2 100644
--- a/src/lib/libcrypto/man/X509_digest.3
+++ b/src/lib/libcrypto/man/X509_digest.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_digest.3,v 1.8 2019/08/20 13:27:19 schwarze Exp $ 1.\" $OpenBSD: X509_digest.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100 2.\" full merge up to: OpenSSL 1212818e Sep 11 13:22:14 2018 +0100
3.\" 3.\"
4.\" This file was written by Rich Salz <rsalz@openssl.org> 4.\" This file was written by Rich Salz <rsalz@openssl.org>
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 20 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_DIGEST 3 52.Dt X509_DIGEST 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -60,6 +60,7 @@
60.Nm PKCS7_ISSUER_AND_SERIAL_digest 60.Nm PKCS7_ISSUER_AND_SERIAL_digest
61.Nd get digests of various objects 61.Nd get digests of various objects
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/x509.h 64.In openssl/x509.h
64.Ft int 65.Ft int
65.Fo X509_digest 66.Fo X509_digest
diff --git a/src/lib/libcrypto/man/X509_find_by_subject.3 b/src/lib/libcrypto/man/X509_find_by_subject.3
index 98a76a1fca..962eb80854 100644
--- a/src/lib/libcrypto/man/X509_find_by_subject.3
+++ b/src/lib/libcrypto/man/X509_find_by_subject.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_find_by_subject.3,v 1.1 2021/07/04 12:56:27 schwarze Exp $ 1.\" $OpenBSD: X509_find_by_subject.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 4 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_FIND_BY_SUBJECT 3 18.Dt X509_FIND_BY_SUBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509_find_by_issuer_and_serial 22.Nm X509_find_by_issuer_and_serial
23.Nd search an array of X.509 certificates 23.Nd search an array of X.509 certificates
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509.h 26.In openssl/x509.h
26.Ft X509 * 27.Ft X509 *
27.Fo X509_find_by_subject 28.Fo X509_find_by_subject
diff --git a/src/lib/libcrypto/man/X509_get0_notBefore.3 b/src/lib/libcrypto/man/X509_get0_notBefore.3
index 5e5c08b79a..5ac075fe31 100644
--- a/src/lib/libcrypto/man/X509_get0_notBefore.3
+++ b/src/lib/libcrypto/man/X509_get0_notBefore.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get0_notBefore.3,v 1.7 2024/03/05 18:30:40 tb Exp $ 1.\" $OpenBSD: X509_get0_notBefore.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" content checked up to: OpenSSL 27b138e9 May 19 00:16:38 2017 +0000 2.\" content checked up to: OpenSSL 27b138e9 May 19 00:16:38 2017 +0000
3.\" 3.\"
4.\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 5 2024 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt X509_GET0_NOTBEFORE 3 19.Dt X509_GET0_NOTBEFORE 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -39,6 +39,7 @@
39.Nm X509_CRL_set_nextUpdate 39.Nm X509_CRL_set_nextUpdate
40.Nd get and set certificate and CRL validity dates 40.Nd get and set certificate and CRL validity dates
41.Sh SYNOPSIS 41.Sh SYNOPSIS
42.Lb libcrypto
42.In openssl/x509.h 43.In openssl/x509.h
43.Ft const ASN1_TIME * 44.Ft const ASN1_TIME *
44.Fo X509_get0_notBefore 45.Fo X509_get0_notBefore
diff --git a/src/lib/libcrypto/man/X509_get0_signature.3 b/src/lib/libcrypto/man/X509_get0_signature.3
index 2428f411b1..6cebb94e56 100644
--- a/src/lib/libcrypto/man/X509_get0_signature.3
+++ b/src/lib/libcrypto/man/X509_get0_signature.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get0_signature.3,v 1.10 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: X509_get0_signature.3,v 1.12 2025/07/06 09:32:08 tb Exp $
2.\" selective merge up to: 2.\" selective merge up to:
3.\" OpenSSL man3/X509_get0_signature 2f7a2520 Apr 25 17:28:08 2017 +0100 3.\" OpenSSL man3/X509_get0_signature 2f7a2520 Apr 25 17:28:08 2017 +0100
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: April 17 2025 $ 69.Dd $Mdocdate: July 6 2025 $
70.Dt X509_GET0_SIGNATURE 3 70.Dt X509_GET0_SIGNATURE 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -82,6 +82,7 @@
82.Nm X509_get_signature_info 82.Nm X509_get_signature_info
83.Nd signature information 83.Nd signature information
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/x509.h 86.In openssl/x509.h
86.Ft void 87.Ft void
87.Fo X509_get0_signature 88.Fo X509_get0_signature
@@ -278,3 +279,10 @@ In some cases the actual security of the signature is smaller
278because the signing key is less secure. 279because the signing key is less secure.
279For example in a certificate signed using SHA-512 280For example in a certificate signed using SHA-512
280and a 1024-bit RSA key. 281and a 1024-bit RSA key.
282.Sh BUGS
283The signatures of
284.Fn X509_get0_signature ,
285.Fn X509_REQ_get0_signature ,
286and
287.Fn X509_CRL_get0_signature
288are inconsistent.
diff --git a/src/lib/libcrypto/man/X509_get1_email.3 b/src/lib/libcrypto/man/X509_get1_email.3
index c38a604899..020708d227 100644
--- a/src/lib/libcrypto/man/X509_get1_email.3
+++ b/src/lib/libcrypto/man/X509_get1_email.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get1_email.3,v 1.1 2019/08/23 12:23:39 schwarze Exp $ 1.\" $OpenBSD: X509_get1_email.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 23 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_GET1_EMAIL 3 18.Dt X509_GET1_EMAIL 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm X509_email_free 23.Nm X509_email_free
24.Nd utilities for stacks of strings 24.Nd utilities for stacks of strings
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/x509v3.h 27.In openssl/x509v3.h
27.Vt typedef char *OPENSSL_STRING ; 28.Vt typedef char *OPENSSL_STRING ;
28.Ft STACK_OF(OPENSSL_STRING) * 29.Ft STACK_OF(OPENSSL_STRING) *
diff --git a/src/lib/libcrypto/man/X509_get_extension_flags.3 b/src/lib/libcrypto/man/X509_get_extension_flags.3
index e5e773f2e8..1d15be407e 100644
--- a/src/lib/libcrypto/man/X509_get_extension_flags.3
+++ b/src/lib/libcrypto/man/X509_get_extension_flags.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get_extension_flags.3,v 1.5 2025/04/17 14:58:09 tb Exp $ 1.\" $OpenBSD: X509_get_extension_flags.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 361136f4 Sep 1 18:56:58 2015 +0100 2.\" full merge up to: OpenSSL 361136f4 Sep 1 18:56:58 2015 +0100
3.\" selective merge up to: OpenSSL 2b2e3106f Feb 16 15:04:45 2021 +0000 3.\" selective merge up to: OpenSSL 2b2e3106f Feb 16 15:04:45 2021 +0000
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 17 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt X509_GET_EXTENSION_FLAGS 3 53.Dt X509_GET_EXTENSION_FLAGS 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -58,6 +58,7 @@
58.Nm X509_get_extended_key_usage 58.Nm X509_get_extended_key_usage
59.Nd retrieve certificate extension data 59.Nd retrieve certificate extension data
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/x509v3.h 62.In openssl/x509v3.h
62.Ft uint32_t 63.Ft uint32_t
63.Fo X509_get_extension_flags 64.Fo X509_get_extension_flags
diff --git a/src/lib/libcrypto/man/X509_get_pubkey.3 b/src/lib/libcrypto/man/X509_get_pubkey.3
index 0829397982..9af6f49a33 100644
--- a/src/lib/libcrypto/man/X509_get_pubkey.3
+++ b/src/lib/libcrypto/man/X509_get_pubkey.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get_pubkey.3,v 1.13 2022/03/31 17:27:17 naddy Exp $ 1.\" $OpenBSD: X509_get_pubkey.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: March 31 2022 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt X509_GET_PUBKEY 3 69.Dt X509_GET_PUBKEY 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -81,6 +81,7 @@
81.Nm X509_REQ_extract_key 81.Nm X509_REQ_extract_key
82.Nd get or set certificate or certificate request public key 82.Nd get or set certificate or certificate request public key
83.Sh SYNOPSIS 83.Sh SYNOPSIS
84.Lb libcrypto
84.In openssl/x509.h 85.In openssl/x509.h
85.Ft EVP_PKEY * 86.Ft EVP_PKEY *
86.Fo X509_get_pubkey 87.Fo X509_get_pubkey
diff --git a/src/lib/libcrypto/man/X509_get_pubkey_parameters.3 b/src/lib/libcrypto/man/X509_get_pubkey_parameters.3
index 181361477e..b2611210d1 100644
--- a/src/lib/libcrypto/man/X509_get_pubkey_parameters.3
+++ b/src/lib/libcrypto/man/X509_get_pubkey_parameters.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get_pubkey_parameters.3,v 1.2 2021/11/26 13:35:10 schwarze Exp $ 1.\" $OpenBSD: X509_get_pubkey_parameters.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 26 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_GET_PUBKEY_PARAMETERS 3 18.Dt X509_GET_PUBKEY_PARAMETERS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm X509_get_pubkey_parameters 21.Nm X509_get_pubkey_parameters
22.Nd copy public key parameters from a chain 22.Nd copy public key parameters from a chain
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/x509.h 25.In openssl/x509.h
25.Ft int 26.Ft int
26.Fo X509_get_pubkey_parameters 27.Fo X509_get_pubkey_parameters
diff --git a/src/lib/libcrypto/man/X509_get_serialNumber.3 b/src/lib/libcrypto/man/X509_get_serialNumber.3
index 7d757c7a71..56f108f3d7 100644
--- a/src/lib/libcrypto/man/X509_get_serialNumber.3
+++ b/src/lib/libcrypto/man/X509_get_serialNumber.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get_serialNumber.3,v 1.5 2020/06/19 12:01:20 schwarze Exp $ 1.\" $OpenBSD: X509_get_serialNumber.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 19 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_GET_SERIALNUMBER 3 52.Dt X509_GET_SERIALNUMBER 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm X509_set_serialNumber 57.Nm X509_set_serialNumber
58.Nd get or set certificate serial number 58.Nd get or set certificate serial number
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/x509.h 61.In openssl/x509.h
61.Ft ASN1_INTEGER * 62.Ft ASN1_INTEGER *
62.Fo X509_get_serialNumber 63.Fo X509_get_serialNumber
diff --git a/src/lib/libcrypto/man/X509_get_subject_name.3 b/src/lib/libcrypto/man/X509_get_subject_name.3
index fb9611f645..8dc19080f6 100644
--- a/src/lib/libcrypto/man/X509_get_subject_name.3
+++ b/src/lib/libcrypto/man/X509_get_subject_name.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get_subject_name.3,v 1.10 2020/10/21 17:17:44 tb Exp $ 1.\" $OpenBSD: X509_get_subject_name.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: October 21 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_GET_SUBJECT_NAME 3 52.Dt X509_GET_SUBJECT_NAME 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -62,6 +62,7 @@
62.Nm X509_CRL_set_issuer_name 62.Nm X509_CRL_set_issuer_name
63.Nd get and set issuer or subject names 63.Nd get and set issuer or subject names
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libcrypto
65.In openssl/x509.h 66.In openssl/x509.h
66.Ft X509_NAME * 67.Ft X509_NAME *
67.Fo X509_get_subject_name 68.Fo X509_get_subject_name
diff --git a/src/lib/libcrypto/man/X509_get_version.3 b/src/lib/libcrypto/man/X509_get_version.3
index ee46ff7c8c..d539053d81 100644
--- a/src/lib/libcrypto/man/X509_get_version.3
+++ b/src/lib/libcrypto/man/X509_get_version.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_get_version.3,v 1.8 2020/10/21 17:17:44 tb Exp $ 1.\" $OpenBSD: X509_get_version.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: October 21 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_GET_VERSION 3 52.Dt X509_GET_VERSION 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -60,6 +60,7 @@
60.Nm X509_CRL_set_version 60.Nm X509_CRL_set_version
61.Nd get or set certificate, certificate request, or CRL version 61.Nd get or set certificate, certificate request, or CRL version
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/x509.h 64.In openssl/x509.h
64.Ft long 65.Ft long
65.Fo X509_get_version 66.Fo X509_get_version
diff --git a/src/lib/libcrypto/man/X509_keyid_set1.3 b/src/lib/libcrypto/man/X509_keyid_set1.3
index c529fc742b..e1668f976a 100644
--- a/src/lib/libcrypto/man/X509_keyid_set1.3
+++ b/src/lib/libcrypto/man/X509_keyid_set1.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_keyid_set1.3,v 1.2 2021/07/09 14:41:14 tb Exp $ 1.\" $OpenBSD: X509_keyid_set1.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 9 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_KEYID_SET1 3 18.Dt X509_KEYID_SET1 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm X509_alias_get0 24.Nm X509_alias_get0
25.Nd auxiliary certificate data for PKCS#12 25.Nd auxiliary certificate data for PKCS#12
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509.h 28.In openssl/x509.h
28.Ft int 29.Ft int
29.Fo X509_keyid_set1 30.Fo X509_keyid_set1
diff --git a/src/lib/libcrypto/man/X509_load_cert_file.3 b/src/lib/libcrypto/man/X509_load_cert_file.3
index 95a83dd00e..04a666da25 100644
--- a/src/lib/libcrypto/man/X509_load_cert_file.3
+++ b/src/lib/libcrypto/man/X509_load_cert_file.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_load_cert_file.3,v 1.1 2021/11/09 16:23:04 schwarze Exp $ 1.\" $OpenBSD: X509_load_cert_file.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 9 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_LOAD_CERT_FILE 3 18.Dt X509_LOAD_CERT_FILE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm X509_load_cert_crl_file 23.Nm X509_load_cert_crl_file
24.Nd read, decode, and cache certificates and CRLs 24.Nd read, decode, and cache certificates and CRLs
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/x509_vfy.h 27.In openssl/x509_vfy.h
27.Ft int 28.Ft int
28.Fo X509_load_cert_file 29.Fo X509_load_cert_file
diff --git a/src/lib/libcrypto/man/X509_new.3 b/src/lib/libcrypto/man/X509_new.3
index 7b62363d4d..b6140b24b0 100644
--- a/src/lib/libcrypto/man/X509_new.3
+++ b/src/lib/libcrypto/man/X509_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_new.3,v 1.45 2024/09/02 08:04:32 tb Exp $ 1.\" $OpenBSD: X509_new.3,v 1.47 2025/07/16 17:59:10 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: September 2 2024 $ 69.Dd $Mdocdate: July 16 2025 $
70.Dt X509_NEW 3 70.Dt X509_NEW 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -78,6 +78,7 @@
78.Nm X509_chain_up_ref 78.Nm X509_chain_up_ref
79.Nd X.509 certificate object 79.Nd X.509 certificate object
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/x509.h 82.In openssl/x509.h
82.Ft X509 * 83.Ft X509 *
83.Fn X509_new void 84.Fn X509_new void
@@ -230,7 +231,6 @@ if an error occurs.
230.Xr X509_LOOKUP_new 3 , 231.Xr X509_LOOKUP_new 3 ,
231.Xr X509_NAME_new 3 , 232.Xr X509_NAME_new 3 ,
232.Xr X509_OBJECT_new 3 , 233.Xr X509_OBJECT_new 3 ,
233.Xr X509_PKEY_new 3 ,
234.Xr X509_print_ex 3 , 234.Xr X509_print_ex 3 ,
235.Xr X509_PUBKEY_new 3 , 235.Xr X509_PUBKEY_new 3 ,
236.Xr X509_PURPOSE_set 3 , 236.Xr X509_PURPOSE_set 3 ,
diff --git a/src/lib/libcrypto/man/X509_ocspid_print.3 b/src/lib/libcrypto/man/X509_ocspid_print.3
index b9b6c92fbb..7b0493c655 100644
--- a/src/lib/libcrypto/man/X509_ocspid_print.3
+++ b/src/lib/libcrypto/man/X509_ocspid_print.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_ocspid_print.3,v 1.1 2021/08/06 21:45:55 schwarze Exp $ 1.\" $OpenBSD: X509_ocspid_print.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 6 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_OCSPID_PRINT 3 18.Dt X509_OCSPID_PRINT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm X509_ocspid_print 21.Nm X509_ocspid_print
22.Nd pretty-print hashes of subject name and public key 22.Nd pretty-print hashes of subject name and public key
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/x509.h 25.In openssl/x509.h
25.Ft int 26.Ft int
26.Fo X509_ocspid_print 27.Fo X509_ocspid_print
diff --git a/src/lib/libcrypto/man/X509_print_ex.3 b/src/lib/libcrypto/man/X509_print_ex.3
index c769e77c32..627ef25a79 100644
--- a/src/lib/libcrypto/man/X509_print_ex.3
+++ b/src/lib/libcrypto/man/X509_print_ex.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_print_ex.3,v 1.5 2025/03/09 14:02:46 tb Exp $ 1.\" $OpenBSD: X509_print_ex.3,v 1.7 2025/07/01 06:47:56 tb Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 9 2025 $ 17.Dd $Mdocdate: July 1 2025 $
18.Dt X509_PRINT_EX 3 18.Dt X509_PRINT_EX 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.Nm X509_print_fp 25.Nm X509_print_fp
26.Nd pretty-print an X.509 certificate 26.Nd pretty-print an X.509 certificate
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/x509.h 29.In openssl/x509.h
29.Ft int 30.Ft int
30.Fo X509_print_ex 31.Fo X509_print_ex
@@ -132,6 +133,11 @@ with
132.Xr EVP_PKEY_print_public 3 . 133.Xr EVP_PKEY_print_public 3 .
133.Pq Dv X509_FLAG_NO_PUBKEY 134.Pq Dv X509_FLAG_NO_PUBKEY
134.It 135.It
136If an issuer or a subject unique identifier is present, its hex dump
137is printed with
138.Xr X509_signature_dump 3 .
139.Pq Dv X509_FLAG_NO_IDS
140.It
135All X.509 extensions contained in the certificate are printed with 141All X.509 extensions contained in the certificate are printed with
136.Xr X509V3_extensions_print 3 . 142.Xr X509V3_extensions_print 3 .
137.Pq Dv X509_FLAG_NO_EXTENSIONS 143.Pq Dv X509_FLAG_NO_EXTENSIONS
diff --git a/src/lib/libcrypto/man/X509_sign.3 b/src/lib/libcrypto/man/X509_sign.3
index 059d92bac5..9e9df1e98d 100644
--- a/src/lib/libcrypto/man/X509_sign.3
+++ b/src/lib/libcrypto/man/X509_sign.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_sign.3,v 1.11 2024/03/06 02:34:14 tb Exp $ 1.\" $OpenBSD: X509_sign.3,v 1.13 2025/07/11 18:42:51 tb Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 6 2024 $ 51.Dd $Mdocdate: July 11 2025 $
52.Dt X509_SIGN 3 52.Dt X509_SIGN 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -63,6 +63,7 @@
63.Nm X509_CRL_verify 63.Nm X509_CRL_verify
64.Nd sign or verify certificate, certificate request, or CRL signature 64.Nd sign or verify certificate, certificate request, or CRL signature
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libcrypto
66.In openssl/x509.h 67.In openssl/x509.h
67.Ft int 68.Ft int
68.Fo X509_sign 69.Fo X509_sign
@@ -77,8 +78,8 @@
77.Fc 78.Fc
78.Ft int 79.Ft int
79.Fo X509_verify 80.Fo X509_verify
80.Fa "X509 *a" 81.Fa "X509 *x"
81.Fa "EVP_PKEY *r" 82.Fa "EVP_PKEY *pkey"
82.Fc 83.Fc
83.Ft int 84.Ft int
84.Fo X509_REQ_sign 85.Fo X509_REQ_sign
@@ -93,8 +94,8 @@
93.Fc 94.Fc
94.Ft int 95.Ft int
95.Fo X509_REQ_verify 96.Fo X509_REQ_verify
96.Fa "X509_REQ *a" 97.Fa "X509_REQ *x"
97.Fa "EVP_PKEY *r" 98.Fa "EVP_PKEY *pkey"
98.Fc 99.Fc
99.Ft int 100.Ft int
100.Fo X509_CRL_sign 101.Fo X509_CRL_sign
@@ -109,8 +110,8 @@
109.Fc 110.Fc
110.Ft int 111.Ft int
111.Fo X509_CRL_verify 112.Fo X509_CRL_verify
112.Fa "X509_CRL *a" 113.Fa "X509_CRL *x"
113.Fa "EVP_PKEY *r" 114.Fa "EVP_PKEY *pkey"
114.Fc 115.Fc
115.Sh DESCRIPTION 116.Sh DESCRIPTION
116.Fn X509_sign 117.Fn X509_sign
diff --git a/src/lib/libcrypto/man/X509_signature_dump.3 b/src/lib/libcrypto/man/X509_signature_dump.3
index 3333a615bf..c5b9277e0c 100644
--- a/src/lib/libcrypto/man/X509_signature_dump.3
+++ b/src/lib/libcrypto/man/X509_signature_dump.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_signature_dump.3,v 1.3 2024/12/06 12:51:13 schwarze Exp $ 1.\" $OpenBSD: X509_signature_dump.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 6 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509_SIGNATURE_DUMP 3 18.Dt X509_SIGNATURE_DUMP 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509_signature_print 22.Nm X509_signature_print
23.Nd pretty-print ASN.1 strings 23.Nd pretty-print ASN.1 strings
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509.h 26.In openssl/x509.h
26.Ft int 27.Ft int
27.Fo X509_signature_dump 28.Fo X509_signature_dump
diff --git a/src/lib/libcrypto/man/X509_verify_cert.3 b/src/lib/libcrypto/man/X509_verify_cert.3
index 9c085d7780..7897e09f80 100644
--- a/src/lib/libcrypto/man/X509_verify_cert.3
+++ b/src/lib/libcrypto/man/X509_verify_cert.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_verify_cert.3,v 1.8 2019/06/06 01:06:59 schwarze Exp $ 1.\" $OpenBSD: X509_verify_cert.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 6 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509_VERIFY_CERT 3 52.Dt X509_VERIFY_CERT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm X509_verify_cert 55.Nm X509_verify_cert
56.Nd discover and verify X509 certificate chain 56.Nd discover and verify X509 certificate chain
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/x509.h 59.In openssl/x509.h
59.Ft int 60.Ft int
60.Fo X509_verify_cert 61.Fo X509_verify_cert
diff --git a/src/lib/libcrypto/man/X509v3_addr_add_inherit.3 b/src/lib/libcrypto/man/X509v3_addr_add_inherit.3
index 4b2d150c86..d33de1f6a8 100644
--- a/src/lib/libcrypto/man/X509v3_addr_add_inherit.3
+++ b/src/lib/libcrypto/man/X509v3_addr_add_inherit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_addr_add_inherit.3,v 1.11 2023/10/01 22:46:21 tb Exp $ 1.\" $OpenBSD: X509v3_addr_add_inherit.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: October 1 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_ADDR_ADD_INHERIT 3 18.Dt X509V3_ADDR_ADD_INHERIT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.Nm X509v3_addr_is_canonical 25.Nm X509v3_addr_is_canonical
26.Nd RFC 3779 IP address delegation extensions 26.Nd RFC 3779 IP address delegation extensions
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/x509v3.h 29.In openssl/x509v3.h
29.Ft int 30.Ft int
30.Fo X509v3_addr_add_inherit 31.Fo X509v3_addr_add_inherit
diff --git a/src/lib/libcrypto/man/X509v3_addr_get_range.3 b/src/lib/libcrypto/man/X509v3_addr_get_range.3
index e0d83b1162..7ad279d7cc 100644
--- a/src/lib/libcrypto/man/X509v3_addr_get_range.3
+++ b/src/lib/libcrypto/man/X509v3_addr_get_range.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_addr_get_range.3,v 1.2 2023/09/30 14:12:40 schwarze Exp $ 1.\" $OpenBSD: X509v3_addr_get_range.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 30 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_ADDR_GET_RANGE 3 18.Dt X509V3_ADDR_GET_RANGE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509v3_addr_get_range 22.Nm X509v3_addr_get_range
23.Nd parse helpers for the IP address delegation extension 23.Nd parse helpers for the IP address delegation extension
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft unsigned 27.Ft unsigned
27.Fn X509v3_addr_get_afi "const IPAddressFamily *af" 28.Fn X509v3_addr_get_afi "const IPAddressFamily *af"
diff --git a/src/lib/libcrypto/man/X509v3_addr_inherits.3 b/src/lib/libcrypto/man/X509v3_addr_inherits.3
index 8e3cecf7ae..0da24ad10f 100644
--- a/src/lib/libcrypto/man/X509v3_addr_inherits.3
+++ b/src/lib/libcrypto/man/X509v3_addr_inherits.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_addr_inherits.3,v 1.3 2023/09/30 14:21:57 schwarze Exp $ 1.\" $OpenBSD: X509v3_addr_inherits.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 30 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_ADDR_INHERITS 3 18.Dt X509V3_ADDR_INHERITS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509v3_asid_inherits 22.Nm X509v3_asid_inherits
23.Nd RFC 3779 inheritance 23.Nd RFC 3779 inheritance
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft int 27.Ft int
27.Fn X509v3_addr_inherits "IPAddrBlocks *addrblocks" 28.Fn X509v3_addr_inherits "IPAddrBlocks *addrblocks"
diff --git a/src/lib/libcrypto/man/X509v3_addr_subset.3 b/src/lib/libcrypto/man/X509v3_addr_subset.3
index 93714a26fa..5629d9c3cf 100644
--- a/src/lib/libcrypto/man/X509v3_addr_subset.3
+++ b/src/lib/libcrypto/man/X509v3_addr_subset.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_addr_subset.3,v 1.2 2023/09/30 14:24:00 schwarze Exp $ 1.\" $OpenBSD: X509v3_addr_subset.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 30 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_ADDR_SUBSET 3 18.Dt X509V3_ADDR_SUBSET 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm X509v3_asid_subset 22.Nm X509v3_asid_subset
23.Nd RFC 3779 subset relationship 23.Nd RFC 3779 subset relationship
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft int 27.Ft int
27.Fn X509v3_addr_subset "IPAddrBlocks *child" "IPAddrBlocks *parent" 28.Fn X509v3_addr_subset "IPAddrBlocks *child" "IPAddrBlocks *parent"
diff --git a/src/lib/libcrypto/man/X509v3_addr_validate_path.3 b/src/lib/libcrypto/man/X509v3_addr_validate_path.3
index fe6065d599..5bafc6eba4 100644
--- a/src/lib/libcrypto/man/X509v3_addr_validate_path.3
+++ b/src/lib/libcrypto/man/X509v3_addr_validate_path.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_addr_validate_path.3,v 1.5 2023/09/30 19:07:38 tb Exp $ 1.\" $OpenBSD: X509v3_addr_validate_path.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 30 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_ADDR_VALIDATE_PATH 3 18.Dt X509V3_ADDR_VALIDATE_PATH 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm X509v3_asid_validate_resource_set 24.Nm X509v3_asid_validate_resource_set
25.Nd RFC 3779 path validation for IP address and AS number delegation 25.Nd RFC 3779 path validation for IP address and AS number delegation
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509v3.h 28.In openssl/x509v3.h
28.Ft int 29.Ft int
29.Fn X509v3_addr_validate_path "X509_STORE_CTX *ctx" 30.Fn X509v3_addr_validate_path "X509_STORE_CTX *ctx"
diff --git a/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3 b/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
index 81221ca9bc..6378f45ae8 100644
--- a/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
+++ b/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_asid_add_id_or_range.3,v 1.9 2023/09/30 18:16:44 tb Exp $ 1.\" $OpenBSD: X509v3_asid_add_id_or_range.3,v 1.10 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 30 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt X509V3_ASID_ADD_ID_OR_RANGE 3 18.Dt X509V3_ASID_ADD_ID_OR_RANGE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm X509v3_asid_is_canonical 24.Nm X509v3_asid_is_canonical
25.Nd RFC 3779 autonomous system identifier delegation extension 25.Nd RFC 3779 autonomous system identifier delegation extension
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509v3.h 28.In openssl/x509v3.h
28.Ft int 29.Ft int
29.Fo X509v3_asid_add_id_or_range 30.Fo X509v3_asid_add_id_or_range
diff --git a/src/lib/libcrypto/man/X509v3_get_ext_by_NID.3 b/src/lib/libcrypto/man/X509v3_get_ext_by_NID.3
index 8c7c159f80..63f8180151 100644
--- a/src/lib/libcrypto/man/X509v3_get_ext_by_NID.3
+++ b/src/lib/libcrypto/man/X509v3_get_ext_by_NID.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_get_ext_by_NID.3,v 1.15 2024/05/22 09:44:10 tb Exp $ 1.\" $OpenBSD: X509v3_get_ext_by_NID.3,v 1.16 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL fd38836b Jun 20 15:25:43 2018 +0100 2.\" full merge up to: OpenSSL fd38836b Jun 20 15:25:43 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 22 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt X509V3_GET_EXT_BY_NID 3 52.Dt X509V3_GET_EXT_BY_NID 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -82,6 +82,7 @@
82.Nm X509_REVOKED_add_ext 82.Nm X509_REVOKED_add_ext
83.Nd extension stack utility functions 83.Nd extension stack utility functions
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/x509.h 86.In openssl/x509.h
86.Ft int 87.Ft int
87.Fo X509v3_get_ext_count 88.Fo X509v3_get_ext_count
diff --git a/src/lib/libcrypto/man/a2d_ASN1_OBJECT.3 b/src/lib/libcrypto/man/a2d_ASN1_OBJECT.3
index 7d36a54be2..ed5e7b21f6 100644
--- a/src/lib/libcrypto/man/a2d_ASN1_OBJECT.3
+++ b/src/lib/libcrypto/man/a2d_ASN1_OBJECT.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: a2d_ASN1_OBJECT.3,v 1.3 2023/08/09 17:34:39 schwarze Exp $ 1.\" $OpenBSD: a2d_ASN1_OBJECT.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 9 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt A2D_ASN1_OBJECT 3 18.Dt A2D_ASN1_OBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm a2d_ASN1_OBJECT 21.Nm a2d_ASN1_OBJECT
22.Nd DER content octets of an ASN.1 object identifier 22.Nd DER content octets of an ASN.1 object identifier
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libcrypto
24.In openssl/asn1.h 25.In openssl/asn1.h
25.Ft int 26.Ft int
26.Fo a2d_ASN1_OBJECT 27.Fo a2d_ASN1_OBJECT
diff --git a/src/lib/libcrypto/man/a2i_ipadd.3 b/src/lib/libcrypto/man/a2i_ipadd.3
index 1372b2acfd..1fea5e1a05 100644
--- a/src/lib/libcrypto/man/a2i_ipadd.3
+++ b/src/lib/libcrypto/man/a2i_ipadd.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: a2i_ipadd.3,v 1.1 2024/12/27 15:30:17 schwarze Exp $ 1.\" $OpenBSD: a2i_ipadd.3,v 1.2 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 27 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt A2I_IPADD 3 18.Dt A2I_IPADD 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm a2i_IPADDRESS_NC 23.Nm a2i_IPADDRESS_NC
24.Nd parse Internet Protocol addresses into ASN.1 OCTET STRINGs for X.509 24.Nd parse Internet Protocol addresses into ASN.1 OCTET STRINGs for X.509
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libcrypto
26.In openssl/x509v3.h 27.In openssl/x509v3.h
27.Ft int 28.Ft int
28.Fo a2i_ipadd 29.Fo a2i_ipadd
diff --git a/src/lib/libcrypto/man/d2i_ASN1_NULL.3 b/src/lib/libcrypto/man/d2i_ASN1_NULL.3
index 037c9c93e1..06aafc08a2 100644
--- a/src/lib/libcrypto/man/d2i_ASN1_NULL.3
+++ b/src/lib/libcrypto/man/d2i_ASN1_NULL.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_ASN1_NULL.3,v 1.5 2023/09/26 09:36:22 tb Exp $ 1.\" $OpenBSD: d2i_ASN1_NULL.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 26 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_ASN1_NULL 3 18.Dt D2I_ASN1_NULL 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm i2d_ASN1_NULL 22.Nm i2d_ASN1_NULL
23.Nd decode and encode an ASN.1 NULL type 23.Nd decode and encode an ASN.1 NULL type
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/asn1.h 26.In openssl/asn1.h
26.Ft ASN1_NULL * 27.Ft ASN1_NULL *
27.Fo d2i_ASN1_NULL 28.Fo d2i_ASN1_NULL
diff --git a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3
index bbb70ad8c6..3d90c60e0b 100644
--- a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3
+++ b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.15 2025/03/14 21:32:15 tb Exp $ 1.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.16 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017, 2022, 2023 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017, 2022, 2023 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 14 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_ASN1_OBJECT 3 18.Dt D2I_ASN1_OBJECT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm OBJ_length 24.Nm OBJ_length
25.Nd decode and encode ASN.1 object identifiers 25.Nd decode and encode ASN.1 object identifiers
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/asn1.h 28.In openssl/asn1.h
28.Ft ASN1_OBJECT * 29.Ft ASN1_OBJECT *
29.Fo d2i_ASN1_OBJECT 30.Fo d2i_ASN1_OBJECT
diff --git a/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 b/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
index d544af0fe4..bd4b900193 100644
--- a/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
+++ b/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.20 2024/02/13 12:38:43 job Exp $ 1.\" $OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.21 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: February 13 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_ASN1_OCTET_STRING 3 18.Dt D2I_ASN1_OCTET_STRING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -57,6 +57,7 @@
57.Nm i2d_ASN1_TIME 57.Nm i2d_ASN1_TIME
58.Nd decode and encode ASN1_STRING objects 58.Nd decode and encode ASN1_STRING objects
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libcrypto
60.In openssl/asn1.h 61.In openssl/asn1.h
61.Ft ASN1_OCTET_STRING * 62.Ft ASN1_OCTET_STRING *
62.Fo d2i_ASN1_OCTET_STRING 63.Fo d2i_ASN1_OCTET_STRING
diff --git a/src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.3 b/src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.3
index 654f0b1e6b..bd54520005 100644
--- a/src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.3
+++ b/src/lib/libcrypto/man/d2i_ASN1_SEQUENCE_ANY.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_ASN1_SEQUENCE_ANY.3,v 1.3 2021/12/09 19:05:09 schwarze Exp $ 1.\" $OpenBSD: d2i_ASN1_SEQUENCE_ANY.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 9 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_ASN1_SEQUENCE_ANY 3 18.Dt D2I_ASN1_SEQUENCE_ANY 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm i2d_ASN1_SET_ANY 24.Nm i2d_ASN1_SET_ANY
25.Nd decode and encode ASN.1 sequences and sets 25.Nd decode and encode ASN.1 sequences and sets
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/asn1.h 28.In openssl/asn1.h
28.Ft ASN1_SEQUENCE_ANY * 29.Ft ASN1_SEQUENCE_ANY *
29.Fo d2i_ASN1_SEQUENCE_ANY 30.Fo d2i_ASN1_SEQUENCE_ANY
diff --git a/src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.3 b/src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.3
index 413f41e179..de1acfb6e1 100644
--- a/src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.3
+++ b/src/lib/libcrypto/man/d2i_AUTHORITY_KEYID.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_AUTHORITY_KEYID.3,v 1.2 2018/03/21 16:09:51 schwarze Exp $ 1.\" $OpenBSD: d2i_AUTHORITY_KEYID.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 21 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_AUTHORITY_KEYID 3 18.Dt D2I_AUTHORITY_KEYID 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm i2d_AUTHORITY_KEYID 22.Nm i2d_AUTHORITY_KEYID
23.Nd decode and encode X.509 authority key identifiers 23.Nd decode and encode X.509 authority key identifiers
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft AUTHORITY_KEYID * 27.Ft AUTHORITY_KEYID *
27.Fo d2i_AUTHORITY_KEYID 28.Fo d2i_AUTHORITY_KEYID
diff --git a/src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3 b/src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3
index 2964a1f90e..b90c13df06 100644
--- a/src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3
+++ b/src/lib/libcrypto/man/d2i_BASIC_CONSTRAINTS.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_BASIC_CONSTRAINTS.3,v 1.3 2018/03/22 21:08:22 schwarze Exp $ 1.\" $OpenBSD: d2i_BASIC_CONSTRAINTS.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 22 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_BASIC_CONSTRAINTS 3 18.Dt D2I_BASIC_CONSTRAINTS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm i2d_EXTENDED_KEY_USAGE 24.Nm i2d_EXTENDED_KEY_USAGE
25.Nd decode and encode X.509 key usage purposes 25.Nd decode and encode X.509 key usage purposes
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509v3.h 28.In openssl/x509v3.h
28.Ft BASIC_CONSTRAINTS * 29.Ft BASIC_CONSTRAINTS *
29.Fo d2i_BASIC_CONSTRAINTS 30.Fo d2i_BASIC_CONSTRAINTS
diff --git a/src/lib/libcrypto/man/d2i_CMS_ContentInfo.3 b/src/lib/libcrypto/man/d2i_CMS_ContentInfo.3
index 0c61047c42..f4238d664d 100644
--- a/src/lib/libcrypto/man/d2i_CMS_ContentInfo.3
+++ b/src/lib/libcrypto/man/d2i_CMS_ContentInfo.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_CMS_ContentInfo.3,v 1.3 2019/11/02 15:39:46 schwarze Exp $ 1.\" $OpenBSD: d2i_CMS_ContentInfo.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: November 2 2019 $ 16.Dd $Mdocdate: June 8 2025 $
17.Dt D2I_CMS_CONTENTINFO 3 17.Dt D2I_CMS_CONTENTINFO 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
@@ -25,6 +25,7 @@
25.Nm i2d_CMS_ReceiptRequest 25.Nm i2d_CMS_ReceiptRequest
26.Nd decode and encode Cryptographic Message Syntax data 26.Nd decode and encode Cryptographic Message Syntax data
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/cms.h 29.In openssl/cms.h
29.Ft CMS_ContentInfo * 30.Ft CMS_ContentInfo *
30.Fo d2i_CMS_ContentInfo 31.Fo d2i_CMS_ContentInfo
diff --git a/src/lib/libcrypto/man/d2i_DHparams.3 b/src/lib/libcrypto/man/d2i_DHparams.3
index 7fd9878dc0..f3cbd21f13 100644
--- a/src/lib/libcrypto/man/d2i_DHparams.3
+++ b/src/lib/libcrypto/man/d2i_DHparams.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_DHparams.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: d2i_DHparams.3,v 1.9 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: March 27 2018 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt D2I_DHPARAMS 3 54.Dt D2I_DHPARAMS 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -58,6 +58,7 @@
58.Nm i2d_DHparams 58.Nm i2d_DHparams
59.Nd PKCS#3 DH parameter functions 59.Nd PKCS#3 DH parameter functions
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/dh.h 62.In openssl/dh.h
62.Ft DH * 63.Ft DH *
63.Fo d2i_DHparams 64.Fo d2i_DHparams
diff --git a/src/lib/libcrypto/man/d2i_DIST_POINT.3 b/src/lib/libcrypto/man/d2i_DIST_POINT.3
index 34bdb26fb4..0e49dfeeb3 100644
--- a/src/lib/libcrypto/man/d2i_DIST_POINT.3
+++ b/src/lib/libcrypto/man/d2i_DIST_POINT.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_DIST_POINT.3,v 1.4 2018/03/23 04:34:23 schwarze Exp $ 1.\" $OpenBSD: d2i_DIST_POINT.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 23 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_DIST_POINT 3 18.Dt D2I_DIST_POINT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,6 +32,7 @@
32.Nm i2d_AUTHORITY_INFO_ACCESS 32.Nm i2d_AUTHORITY_INFO_ACCESS
33.Nd decode and encode X.509 data access extensions 33.Nd decode and encode X.509 data access extensions
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/x509v3.h 36.In openssl/x509v3.h
36.Ft DIST_POINT * 37.Ft DIST_POINT *
37.Fo d2i_DIST_POINT 38.Fo d2i_DIST_POINT
diff --git a/src/lib/libcrypto/man/d2i_DSAPublicKey.3 b/src/lib/libcrypto/man/d2i_DSAPublicKey.3
index 37ef22e1b9..62dcc45082 100644
--- a/src/lib/libcrypto/man/d2i_DSAPublicKey.3
+++ b/src/lib/libcrypto/man/d2i_DSAPublicKey.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_DSAPublicKey.3,v 1.14 2018/08/26 17:03:32 tb Exp $ 1.\" $OpenBSD: d2i_DSAPublicKey.3,v 1.15 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: August 26 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt D2I_DSAPUBLICKEY 3 53.Dt D2I_DSAPUBLICKEY 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -78,6 +78,7 @@
78.Nm i2d_DSA_SIG 78.Nm i2d_DSA_SIG
79.Nd decode and encode DSA keys 79.Nd decode and encode DSA keys
80.Sh SYNOPSIS 80.Sh SYNOPSIS
81.Lb libcrypto
81.In openssl/dsa.h 82.In openssl/dsa.h
82.Ft DSA * 83.Ft DSA *
83.Fo d2i_DSAPublicKey 84.Fo d2i_DSAPublicKey
diff --git a/src/lib/libcrypto/man/d2i_ECPKParameters.3 b/src/lib/libcrypto/man/d2i_ECPKParameters.3
index 3e1fe1ac70..8e824951d6 100644
--- a/src/lib/libcrypto/man/d2i_ECPKParameters.3
+++ b/src/lib/libcrypto/man/d2i_ECPKParameters.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_ECPKParameters.3,v 1.14 2025/04/25 20:04:09 tb Exp $ 1.\" $OpenBSD: d2i_ECPKParameters.3,v 1.15 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: April 25 2025 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt D2I_ECPKPARAMETERS 3 69.Dt D2I_ECPKPARAMETERS 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -98,6 +98,7 @@
98.Nm i2d_EC_PUBKEY_fp 98.Nm i2d_EC_PUBKEY_fp
99.Nd decode and encode ASN.1 representations of elliptic curve entities 99.Nd decode and encode ASN.1 representations of elliptic curve entities
100.Sh SYNOPSIS 100.Sh SYNOPSIS
101.Lb libcrypto
101.In openssl/ec.h 102.In openssl/ec.h
102.Ft EC_GROUP * 103.Ft EC_GROUP *
103.Fo d2i_ECPKParameters 104.Fo d2i_ECPKParameters
diff --git a/src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3 b/src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3
index c1d61d3b5e..0305ca78a1 100644
--- a/src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3
+++ b/src/lib/libcrypto/man/d2i_ESS_SIGNING_CERT.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_ESS_SIGNING_CERT.3,v 1.2 2018/03/23 04:34:23 schwarze Exp $ 1.\" $OpenBSD: d2i_ESS_SIGNING_CERT.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 23 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_ESS_SIGNING_CERT 3 18.Dt D2I_ESS_SIGNING_CERT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm i2d_ESS_ISSUER_SERIAL 26.Nm i2d_ESS_ISSUER_SERIAL
27.Nd decode and encode signing certificates for S/MIME 27.Nd decode and encode signing certificates for S/MIME
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/ts.h 30.In openssl/ts.h
30.Ft ESS_SIGNING_CERT * 31.Ft ESS_SIGNING_CERT *
31.Fo d2i_ESS_SIGNING_CERT 32.Fo d2i_ESS_SIGNING_CERT
diff --git a/src/lib/libcrypto/man/d2i_GENERAL_NAME.3 b/src/lib/libcrypto/man/d2i_GENERAL_NAME.3
index bfdcc6c67c..557e5ce353 100644
--- a/src/lib/libcrypto/man/d2i_GENERAL_NAME.3
+++ b/src/lib/libcrypto/man/d2i_GENERAL_NAME.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_GENERAL_NAME.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $ 1.\" $OpenBSD: d2i_GENERAL_NAME.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 22 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_GENERAL_NAME 3 18.Dt D2I_GENERAL_NAME 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -28,6 +28,7 @@
28.Nm i2d_OTHERNAME 28.Nm i2d_OTHERNAME
29.Nd decode and encode names for use in X.509 extensions 29.Nd decode and encode names for use in X.509 extensions
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Lb libcrypto
31.In openssl/x509v3.h 32.In openssl/x509v3.h
32.Ft GENERAL_NAME * 33.Ft GENERAL_NAME *
33.Fo d2i_GENERAL_NAME 34.Fo d2i_GENERAL_NAME
diff --git a/src/lib/libcrypto/man/d2i_OCSP_REQUEST.3 b/src/lib/libcrypto/man/d2i_OCSP_REQUEST.3
index 07a990556d..7d27d2b4c1 100644
--- a/src/lib/libcrypto/man/d2i_OCSP_REQUEST.3
+++ b/src/lib/libcrypto/man/d2i_OCSP_REQUEST.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_OCSP_REQUEST.3,v 1.3 2021/03/12 05:18:00 jsg Exp $ 1.\" $OpenBSD: d2i_OCSP_REQUEST.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 12 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_OCSP_REQUEST 3 18.Dt D2I_OCSP_REQUEST 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,6 +32,7 @@
32.Nm i2d_OCSP_SERVICELOC 32.Nm i2d_OCSP_SERVICELOC
33.Nd decode and encode OCSP requests 33.Nd decode and encode OCSP requests
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/ocsp.h 36.In openssl/ocsp.h
36.Ft OCSP_REQUEST * 37.Ft OCSP_REQUEST *
37.Fo d2i_OCSP_REQUEST 38.Fo d2i_OCSP_REQUEST
diff --git a/src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3 b/src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3
index 716e85dc6e..a89c566c12 100644
--- a/src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3
+++ b/src/lib/libcrypto/man/d2i_OCSP_RESPONSE.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_OCSP_RESPONSE.3,v 1.4 2021/03/12 05:18:00 jsg Exp $ 1.\" $OpenBSD: d2i_OCSP_RESPONSE.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 12 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_OCSP_RESPONSE 3 18.Dt D2I_OCSP_RESPONSE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -38,6 +38,7 @@
38.Nm i2d_OCSP_CRLID 38.Nm i2d_OCSP_CRLID
39.Nd decode and encode OCSP responses 39.Nd decode and encode OCSP responses
40.Sh SYNOPSIS 40.Sh SYNOPSIS
41.Lb libcrypto
41.In openssl/ocsp.h 42.In openssl/ocsp.h
42.Ft OCSP_RESPONSE * 43.Ft OCSP_RESPONSE *
43.Fo d2i_OCSP_RESPONSE 44.Fo d2i_OCSP_RESPONSE
diff --git a/src/lib/libcrypto/man/d2i_PKCS12.3 b/src/lib/libcrypto/man/d2i_PKCS12.3
index 55272d1f36..2dda946a3f 100644
--- a/src/lib/libcrypto/man/d2i_PKCS12.3
+++ b/src/lib/libcrypto/man/d2i_PKCS12.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_PKCS12.3,v 1.2 2018/03/21 17:57:48 schwarze Exp $ 1.\" $OpenBSD: d2i_PKCS12.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 21 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_PKCS12 3 18.Dt D2I_PKCS12 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -32,6 +32,7 @@
32.Nm i2d_PKCS12_BAGS 32.Nm i2d_PKCS12_BAGS
33.Nd decode and encode PKCS#12 structures 33.Nd decode and encode PKCS#12 structures
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Lb libcrypto
35.In openssl/pkcs12.h 36.In openssl/pkcs12.h
36.Ft PKCS12 * 37.Ft PKCS12 *
37.Fo d2i_PKCS12 38.Fo d2i_PKCS12
diff --git a/src/lib/libcrypto/man/d2i_PKCS7.3 b/src/lib/libcrypto/man/d2i_PKCS7.3
index e587787465..6d72433b7d 100644
--- a/src/lib/libcrypto/man/d2i_PKCS7.3
+++ b/src/lib/libcrypto/man/d2i_PKCS7.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_PKCS7.3,v 1.7 2023/04/25 18:05:07 tb Exp $ 1.\" $OpenBSD: d2i_PKCS7.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: April 25 2023 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_PKCS7 3 18.Dt D2I_PKCS7 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -44,6 +44,7 @@
44.Nm i2d_PKCS7_SIGN_ENVELOPE 44.Nm i2d_PKCS7_SIGN_ENVELOPE
45.Nd decode and encode PKCS#7 data structures 45.Nd decode and encode PKCS#7 data structures
46.Sh SYNOPSIS 46.Sh SYNOPSIS
47.Lb libcrypto
47.In openssl/pkcs7.h 48.In openssl/pkcs7.h
48.Ft PKCS7 * 49.Ft PKCS7 *
49.Fo d2i_PKCS7 50.Fo d2i_PKCS7
diff --git a/src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3 b/src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3
index 58dd989fae..41ab7ebcba 100644
--- a/src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3
+++ b/src/lib/libcrypto/man/d2i_PKCS8PrivateKey_bio.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_PKCS8PrivateKey_bio.3,v 1.11 2019/06/07 19:28:52 schwarze Exp $ 1.\" $OpenBSD: d2i_PKCS8PrivateKey_bio.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 7 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt D2I_PKCS8PRIVATEKEY_BIO 3 52.Dt D2I_PKCS8PRIVATEKEY_BIO 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -60,6 +60,7 @@
60.Nm i2d_PKCS8PrivateKey_nid_fp 60.Nm i2d_PKCS8PrivateKey_nid_fp
61.Nd PKCS#8 format private key functions 61.Nd PKCS#8 format private key functions
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libcrypto
63.In openssl/evp.h 64.In openssl/evp.h
64.Ft EVP_PKEY * 65.Ft EVP_PKEY *
65.Fo d2i_PKCS8PrivateKey_bio 66.Fo d2i_PKCS8PrivateKey_bio
diff --git a/src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3 b/src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3
index 1ac0f2c308..583fd536f2 100644
--- a/src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3
+++ b/src/lib/libcrypto/man/d2i_PKCS8_PRIV_KEY_INFO.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_PKCS8_PRIV_KEY_INFO.3,v 1.3 2018/03/21 21:18:08 schwarze Exp $ 1.\" $OpenBSD: d2i_PKCS8_PRIV_KEY_INFO.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 21 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_PKCS8_PRIV_KEY_INFO 3 18.Dt D2I_PKCS8_PRIV_KEY_INFO 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm i2d_PKCS8_PRIV_KEY_INFO_fp 26.Nm i2d_PKCS8_PRIV_KEY_INFO_fp
27.Nd decode and encode PKCS#8 private key 27.Nd decode and encode PKCS#8 private key
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/x509.h 30.In openssl/x509.h
30.Ft PKCS8_PRIV_KEY_INFO * 31.Ft PKCS8_PRIV_KEY_INFO *
31.Fo d2i_PKCS8_PRIV_KEY_INFO 32.Fo d2i_PKCS8_PRIV_KEY_INFO
diff --git a/src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.3 b/src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.3
index df8639264c..1c3a215a38 100644
--- a/src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.3
+++ b/src/lib/libcrypto/man/d2i_PKEY_USAGE_PERIOD.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_PKEY_USAGE_PERIOD.3,v 1.2 2018/03/21 16:09:51 schwarze Exp $ 1.\" $OpenBSD: d2i_PKEY_USAGE_PERIOD.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 21 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_PKEY_USAGE_PERIOD 3 18.Dt D2I_PKEY_USAGE_PERIOD 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm i2d_PKEY_USAGE_PERIOD 22.Nm i2d_PKEY_USAGE_PERIOD
23.Nd decode and encode X.509 key usage period extensions 23.Nd decode and encode X.509 key usage period extensions
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft PKEY_USAGE_PERIOD * 27.Ft PKEY_USAGE_PERIOD *
27.Fo d2i_PKEY_USAGE_PERIOD 28.Fo d2i_PKEY_USAGE_PERIOD
diff --git a/src/lib/libcrypto/man/d2i_POLICYINFO.3 b/src/lib/libcrypto/man/d2i_POLICYINFO.3
index bae78b17c7..c335edc1df 100644
--- a/src/lib/libcrypto/man/d2i_POLICYINFO.3
+++ b/src/lib/libcrypto/man/d2i_POLICYINFO.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_POLICYINFO.3,v 1.2 2018/03/21 17:57:48 schwarze Exp $ 1.\" $OpenBSD: d2i_POLICYINFO.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 21 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_POLICYINFO 3 18.Dt D2I_POLICYINFO 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -30,6 +30,7 @@
30.Nm i2d_NOTICEREF 30.Nm i2d_NOTICEREF
31.Nd decode and encode X.509 certificate policies 31.Nd decode and encode X.509 certificate policies
32.Sh SYNOPSIS 32.Sh SYNOPSIS
33.Lb libcrypto
33.In openssl/x509v3.h 34.In openssl/x509v3.h
34.Ft POLICYINFO * 35.Ft POLICYINFO *
35.Fo d2i_POLICYINFO 36.Fo d2i_POLICYINFO
diff --git a/src/lib/libcrypto/man/d2i_PrivateKey.3 b/src/lib/libcrypto/man/d2i_PrivateKey.3
index b544ea0e9a..48f1b93a19 100644
--- a/src/lib/libcrypto/man/d2i_PrivateKey.3
+++ b/src/lib/libcrypto/man/d2i_PrivateKey.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_PrivateKey.3,v 1.11 2024/10/24 21:42:10 tb Exp $ 1.\" $OpenBSD: d2i_PrivateKey.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000 2.\" full merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: October 24 2024 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt D2I_PRIVATEKEY 3 69.Dt D2I_PRIVATEKEY 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -82,6 +82,7 @@
82.Nm i2d_PublicKey 82.Nm i2d_PublicKey
83.Nd decode and encode EVP_PKEY objects 83.Nd decode and encode EVP_PKEY objects
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libcrypto
85.In openssl/evp.h 86.In openssl/evp.h
86.Ft EVP_PKEY * 87.Ft EVP_PKEY *
87.Fo d2i_PrivateKey 88.Fo d2i_PrivateKey
diff --git a/src/lib/libcrypto/man/d2i_RSAPublicKey.3 b/src/lib/libcrypto/man/d2i_RSAPublicKey.3
index d6c376d84b..3f738641df 100644
--- a/src/lib/libcrypto/man/d2i_RSAPublicKey.3
+++ b/src/lib/libcrypto/man/d2i_RSAPublicKey.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_RSAPublicKey.3,v 1.13 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: d2i_RSAPublicKey.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: March 27 2018 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt D2I_RSAPUBLICKEY 3 71.Dt D2I_RSAPUBLICKEY 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -95,6 +95,7 @@
95.Nm i2d_RSA_PUBKEY_fp 95.Nm i2d_RSA_PUBKEY_fp
96.Nd decode and encode RSA keys and parameters 96.Nd decode and encode RSA keys and parameters
97.Sh SYNOPSIS 97.Sh SYNOPSIS
98.Lb libcrypto
98.In openssl/rsa.h 99.In openssl/rsa.h
99.Ft RSA * 100.Ft RSA *
100.Fo d2i_RSAPublicKey 101.Fo d2i_RSAPublicKey
diff --git a/src/lib/libcrypto/man/d2i_TS_REQ.3 b/src/lib/libcrypto/man/d2i_TS_REQ.3
index 9f7c860fa1..87e9a402b8 100644
--- a/src/lib/libcrypto/man/d2i_TS_REQ.3
+++ b/src/lib/libcrypto/man/d2i_TS_REQ.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_TS_REQ.3,v 1.2 2018/03/23 04:34:23 schwarze Exp $ 1.\" $OpenBSD: d2i_TS_REQ.3,v 1.3 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 23 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_TS_REQ 3 18.Dt D2I_TS_REQ 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -48,6 +48,7 @@
48.Nm i2d_TS_MSG_IMPRINT_fp 48.Nm i2d_TS_MSG_IMPRINT_fp
49.Nd decode and encode X.509 time-stamp protocol structures 49.Nd decode and encode X.509 time-stamp protocol structures
50.Sh SYNOPSIS 50.Sh SYNOPSIS
51.Lb libcrypto
51.In openssl/ts.h 52.In openssl/ts.h
52.Ft TS_REQ * 53.Ft TS_REQ *
53.Fo d2i_TS_REQ 54.Fo d2i_TS_REQ
diff --git a/src/lib/libcrypto/man/d2i_X509.3 b/src/lib/libcrypto/man/d2i_X509.3
index 6102e49e0e..2905e49aca 100644
--- a/src/lib/libcrypto/man/d2i_X509.3
+++ b/src/lib/libcrypto/man/d2i_X509.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509.3,v 1.11 2021/10/27 10:35:43 schwarze Exp $ 1.\" $OpenBSD: d2i_X509.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL d2i_X509.pod checked up to: 2.\" OpenSSL d2i_X509.pod checked up to:
3.\" 256989ce4 Jun 19 15:00:32 2020 +0200 3.\" 256989ce4 Jun 19 15:00:32 2020 +0200
4.\" OpenSSL i2d_re_X509_tbs.pod checked up to: 4.\" OpenSSL i2d_re_X509_tbs.pod checked up to:
@@ -71,7 +71,7 @@
71.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 71.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
72.\" OF THE POSSIBILITY OF SUCH DAMAGE. 72.\" OF THE POSSIBILITY OF SUCH DAMAGE.
73.\" 73.\"
74.Dd $Mdocdate: October 27 2021 $ 74.Dd $Mdocdate: June 8 2025 $
75.Dt D2I_X509 3 75.Dt D2I_X509 3
76.Os 76.Os
77.Sh NAME 77.Sh NAME
@@ -94,6 +94,7 @@
94.Nm i2d_re_X509_REQ_tbs 94.Nm i2d_re_X509_REQ_tbs
95.Nd decode and encode X.509 certificates 95.Nd decode and encode X.509 certificates
96.Sh SYNOPSIS 96.Sh SYNOPSIS
97.Lb libcrypto
97.In openssl/x509.h 98.In openssl/x509.h
98.Ft X509 * 99.Ft X509 *
99.Fo d2i_X509 100.Fo d2i_X509
diff --git a/src/lib/libcrypto/man/d2i_X509_ALGOR.3 b/src/lib/libcrypto/man/d2i_X509_ALGOR.3
index 252f3fc344..2691ceda85 100644
--- a/src/lib/libcrypto/man/d2i_X509_ALGOR.3
+++ b/src/lib/libcrypto/man/d2i_X509_ALGOR.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509_ALGOR.3,v 1.11 2025/03/14 21:32:15 tb Exp $ 1.\" $OpenBSD: d2i_X509_ALGOR.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 14 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_X509_ALGOR 3 18.Dt D2I_X509_ALGOR 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm i2d_X509_ALGORS 24.Nm i2d_X509_ALGORS
25.Nd decode and encode algorithm identifiers 25.Nd decode and encode algorithm identifiers
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libcrypto
27.In openssl/x509.h 28.In openssl/x509.h
28.Ft X509_ALGOR * 29.Ft X509_ALGOR *
29.Fo d2i_X509_ALGOR 30.Fo d2i_X509_ALGOR
diff --git a/src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3 b/src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3
index 6b070e5e51..be4924d3e0 100644
--- a/src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3
+++ b/src/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509_ATTRIBUTE.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: d2i_X509_ATTRIBUTE.3,v 1.4 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 27 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_X509_ATTRIBUTE 3 18.Dt D2I_X509_ATTRIBUTE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.\" The type in called "Attribute" with capital "A", not "attribute". 25.\" The type in called "Attribute" with capital "A", not "attribute".
26.Nd decode and encode generic X.501 Attribute 26.Nd decode and encode generic X.501 Attribute
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libcrypto
28.In openssl/x509.h 29.In openssl/x509.h
29.Ft X509_ATTRIBUTE * 30.Ft X509_ATTRIBUTE *
30.Fo d2i_X509_ATTRIBUTE 31.Fo d2i_X509_ATTRIBUTE
diff --git a/src/lib/libcrypto/man/d2i_X509_CRL.3 b/src/lib/libcrypto/man/d2i_X509_CRL.3
index 79c1ed9f8c..040ac0395f 100644
--- a/src/lib/libcrypto/man/d2i_X509_CRL.3
+++ b/src/lib/libcrypto/man/d2i_X509_CRL.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509_CRL.3,v 1.10 2025/03/15 15:17:41 tb Exp $ 1.\" $OpenBSD: d2i_X509_CRL.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 15 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_X509_CRL 3 18.Dt D2I_X509_CRL 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -30,6 +30,7 @@
30.Nm i2d_X509_REVOKED 30.Nm i2d_X509_REVOKED
31.Nd decode and encode X.509 certificate revocation lists 31.Nd decode and encode X.509 certificate revocation lists
32.Sh SYNOPSIS 32.Sh SYNOPSIS
33.Lb libcrypto
33.In openssl/x509.h 34.In openssl/x509.h
34.Ft X509_CRL * 35.Ft X509_CRL *
35.Fo d2i_X509_CRL 36.Fo d2i_X509_CRL
diff --git a/src/lib/libcrypto/man/d2i_X509_EXTENSION.3 b/src/lib/libcrypto/man/d2i_X509_EXTENSION.3
index 46a680c1ba..3e1011d180 100644
--- a/src/lib/libcrypto/man/d2i_X509_EXTENSION.3
+++ b/src/lib/libcrypto/man/d2i_X509_EXTENSION.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509_EXTENSION.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: d2i_X509_EXTENSION.3,v 1.5 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 27 2018 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt D2I_X509_EXTENSION 3 18.Dt D2I_X509_EXTENSION 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.\" The ASN.1 structure is called "Extensions", not "extensions". 26.\" The ASN.1 structure is called "Extensions", not "extensions".
27.Nd decode and encode X.509 Extensions 27.Nd decode and encode X.509 Extensions
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/x509.h 30.In openssl/x509.h
30.Ft X509_EXTENSION * 31.Ft X509_EXTENSION *
31.Fo d2i_X509_EXTENSION 32.Fo d2i_X509_EXTENSION
diff --git a/src/lib/libcrypto/man/d2i_X509_NAME.3 b/src/lib/libcrypto/man/d2i_X509_NAME.3
index f5cafaee97..c8df55f10d 100644
--- a/src/lib/libcrypto/man/d2i_X509_NAME.3
+++ b/src/lib/libcrypto/man/d2i_X509_NAME.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509_NAME.3,v 1.18 2025/03/14 21:32:15 tb Exp $ 1.\" $OpenBSD: d2i_X509_NAME.3,v 1.19 2025/06/08 22:40:30 schwarze Exp $
2.\" checked up to: 2.\" checked up to:
3.\" OpenSSL crypto/d2i_X509_NAME 4692340e Jun 7 15:49:08 2016 -0400 and 3.\" OpenSSL crypto/d2i_X509_NAME 4692340e Jun 7 15:49:08 2016 -0400 and
4.\" OpenSSL man3/X509_NAME_get0_der 99d63d46 Oct 26 13:56:48 2016 -0400 4.\" OpenSSL man3/X509_NAME_get0_der 99d63d46 Oct 26 13:56:48 2016 -0400
@@ -17,7 +17,7 @@
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\" 19.\"
20.Dd $Mdocdate: March 14 2025 $ 20.Dd $Mdocdate: June 8 2025 $
21.Dt D2I_X509_NAME 3 21.Dt D2I_X509_NAME 3
22.Os 22.Os
23.Sh NAME 23.Sh NAME
@@ -34,6 +34,7 @@
34.\" The type is called "Name" with capital "N", not "name". 34.\" The type is called "Name" with capital "N", not "name".
35.Nd decode and encode X.501 Name objects 35.Nd decode and encode X.501 Name objects
36.Sh SYNOPSIS 36.Sh SYNOPSIS
37.Lb libcrypto
37.In openssl/x509.h 38.In openssl/x509.h
38.Ft X509_NAME * 39.Ft X509_NAME *
39.Fo d2i_X509_NAME 40.Fo d2i_X509_NAME
diff --git a/src/lib/libcrypto/man/d2i_X509_REQ.3 b/src/lib/libcrypto/man/d2i_X509_REQ.3
index 95785a2d25..0f113757ee 100644
--- a/src/lib/libcrypto/man/d2i_X509_REQ.3
+++ b/src/lib/libcrypto/man/d2i_X509_REQ.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509_REQ.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: d2i_X509_REQ.3,v 1.8 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 2.\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3.\" 3.\"
4.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 27 2018 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt D2I_X509_REQ 3 19.Dt D2I_X509_REQ 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -29,6 +29,7 @@
29.Nm i2d_X509_REQ_INFO 29.Nm i2d_X509_REQ_INFO
30.Nd decode and encode PKCS#10 certification requests 30.Nd decode and encode PKCS#10 certification requests
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libcrypto
32.In openssl/x509.h 33.In openssl/x509.h
33.Ft X509_REQ * 34.Ft X509_REQ *
34.Fo d2i_X509_REQ 35.Fo d2i_X509_REQ
diff --git a/src/lib/libcrypto/man/d2i_X509_SIG.3 b/src/lib/libcrypto/man/d2i_X509_SIG.3
index c9fbf86633..1700b2d728 100644
--- a/src/lib/libcrypto/man/d2i_X509_SIG.3
+++ b/src/lib/libcrypto/man/d2i_X509_SIG.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_X509_SIG.3,v 1.10 2025/03/14 21:32:15 tb Exp $ 1.\" $OpenBSD: d2i_X509_SIG.3,v 1.11 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 14 2025 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt D2I_X509_SIG 3 19.Dt D2I_X509_SIG 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -29,6 +29,7 @@
29.\" These functions are misnamed. 29.\" These functions are misnamed.
30.Nd decode and encode PKCS#7 digest information 30.Nd decode and encode PKCS#7 digest information
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libcrypto
32.In openssl/x509.h 33.In openssl/x509.h
33.Ft X509_SIG * 34.Ft X509_SIG *
34.Fo d2i_X509_SIG 35.Fo d2i_X509_SIG
diff --git a/src/lib/libcrypto/man/des_read_pw.3 b/src/lib/libcrypto/man/des_read_pw.3
index 7cb35b47f8..2ffe13bbe9 100644
--- a/src/lib/libcrypto/man/des_read_pw.3
+++ b/src/lib/libcrypto/man/des_read_pw.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: des_read_pw.3,v 1.12 2024/08/24 07:48:37 tb Exp $ 1.\" $OpenBSD: des_read_pw.3,v 1.13 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL doc/crypto/des.pod 2.\" full merge up to: OpenSSL doc/crypto/des.pod
3.\" 53934822 Jun 9 16:39:19 2016 -0400 3.\" 53934822 Jun 9 16:39:19 2016 -0400
4.\" 4.\"
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: August 24 2024 $ 69.Dd $Mdocdate: June 8 2025 $
70.Dt DES_READ_PW 3 70.Dt DES_READ_PW 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -76,6 +76,7 @@
76.Nm EVP_get_pw_prompt 76.Nm EVP_get_pw_prompt
77.Nd compatibility user interface functions 77.Nd compatibility user interface functions
78.Sh SYNOPSIS 78.Sh SYNOPSIS
79.Lb libcrypto
79.In openssl/evp.h 80.In openssl/evp.h
80.Ft int 81.Ft int
81.Fo EVP_read_pw_string 82.Fo EVP_read_pw_string
diff --git a/src/lib/libcrypto/man/evp.3 b/src/lib/libcrypto/man/evp.3
index 2c54c0f981..3a7acf1ff8 100644
--- a/src/lib/libcrypto/man/evp.3
+++ b/src/lib/libcrypto/man/evp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: evp.3,v 1.36 2024/12/06 14:27:49 schwarze Exp $ 1.\" $OpenBSD: evp.3,v 1.38 2025/06/11 13:48:54 schwarze Exp $
2.\" full merge up to: OpenSSL man7/evp 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL man7/evp 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>, 4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
@@ -51,13 +51,14 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: December 6 2024 $ 54.Dd $Mdocdate: June 11 2025 $
55.Dt EVP 3 55.Dt EVP 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
58.Nm evp 58.Nm evp
59.Nd high-level cryptographic functions 59.Nd high-level cryptographic functions
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libcrypto
61.In openssl/evp.h 62.In openssl/evp.h
62.Sh DESCRIPTION 63.Sh DESCRIPTION
63The EVP library provides a high-level interface to cryptographic 64The EVP library provides a high-level interface to cryptographic
@@ -75,7 +76,7 @@ in contexts like
75.Xr EVP_SealInit 3 , 76.Xr EVP_SealInit 3 ,
76.Xr PKCS7_encrypt 3 , 77.Xr PKCS7_encrypt 3 ,
77or 78or
78.Xr SMIME_write_ASN1 3 . 79.Xr SMIME_write_PKCS7 3 .
79.Pp 80.Pp
80.Xr EVP_SealInit 3 81.Xr EVP_SealInit 3
81and 82and
diff --git a/src/lib/libcrypto/man/i2a_ASN1_STRING.3 b/src/lib/libcrypto/man/i2a_ASN1_STRING.3
index 7d46474775..c16259e565 100644
--- a/src/lib/libcrypto/man/i2a_ASN1_STRING.3
+++ b/src/lib/libcrypto/man/i2a_ASN1_STRING.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: i2a_ASN1_STRING.3,v 1.5 2024/12/27 15:30:17 schwarze Exp $ 1.\" $OpenBSD: i2a_ASN1_STRING.3,v 1.6 2025/06/08 22:40:30 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 27 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt I2A_ASN1_STRING 3 18.Dt I2A_ASN1_STRING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm a2i_ASN1_ENUMERATED 26.Nm a2i_ASN1_ENUMERATED
27.Nd hexadecimal dump of an ASN.1 string 27.Nd hexadecimal dump of an ASN.1 string
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/asn1.h 30.In openssl/asn1.h
30.Ft int 31.Ft int
31.Fo i2a_ASN1_STRING 32.Fo i2a_ASN1_STRING
diff --git a/src/lib/libcrypto/man/i2d_CMS_bio_stream.3 b/src/lib/libcrypto/man/i2d_CMS_bio_stream.3
index b60468464c..403f7c2906 100644
--- a/src/lib/libcrypto/man/i2d_CMS_bio_stream.3
+++ b/src/lib/libcrypto/man/i2d_CMS_bio_stream.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: i2d_CMS_bio_stream.3,v 1.6 2023/05/01 07:28:11 tb Exp $ 1.\" $OpenBSD: i2d_CMS_bio_stream.3,v 1.7 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 1 2023 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt I2D_CMS_BIO_STREAM 3 52.Dt I2D_CMS_BIO_STREAM 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm i2d_CMS_bio_stream 55.Nm i2d_CMS_bio_stream
56.Nd output CMS_ContentInfo structure in BER format 56.Nd output CMS_ContentInfo structure in BER format
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libcrypto
58.In openssl/cms.h 59.In openssl/cms.h
59.Ft int 60.Ft int
60.Fo i2d_CMS_bio_stream 61.Fo i2d_CMS_bio_stream
diff --git a/src/lib/libcrypto/man/i2d_PKCS7_bio_stream.3 b/src/lib/libcrypto/man/i2d_PKCS7_bio_stream.3
index 7a47ba3026..3636960aa2 100644
--- a/src/lib/libcrypto/man/i2d_PKCS7_bio_stream.3
+++ b/src/lib/libcrypto/man/i2d_PKCS7_bio_stream.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: i2d_PKCS7_bio_stream.3,v 1.11 2023/05/01 07:28:11 tb Exp $ 1.\" $OpenBSD: i2d_PKCS7_bio_stream.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $
2.\" OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: May 1 2023 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt I2D_PKCS7_BIO_STREAM 3 53.Dt I2D_PKCS7_BIO_STREAM 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm i2d_PKCS7_bio_stream 56.Nm i2d_PKCS7_bio_stream
57.Nd output PKCS7 structure in BER format 57.Nd output PKCS7 structure in BER format
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libcrypto
59.In openssl/pkcs7.h 60.In openssl/pkcs7.h
60.Ft int 61.Ft int
61.Fo i2d_PKCS7_bio_stream 62.Fo i2d_PKCS7_bio_stream
diff --git a/src/lib/libcrypto/man/lh_new.3 b/src/lib/libcrypto/man/lh_new.3
index 2550a7d2e7..cc0b3d6b96 100644
--- a/src/lib/libcrypto/man/lh_new.3
+++ b/src/lib/libcrypto/man/lh_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: lh_new.3,v 1.13 2024/03/05 22:15:29 tb Exp $ 1.\" $OpenBSD: lh_new.3,v 1.14 2025/06/08 22:40:30 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL doc/crypto/lhash.pod 1bc74519 May 20 08:11:46 2016 -0400 3.\" OpenSSL doc/crypto/lhash.pod 1bc74519 May 20 08:11:46 2016 -0400
4.\" selective merge up to: 4.\" selective merge up to:
@@ -118,7 +118,7 @@
118.\" copied and put under another distribution licence 118.\" copied and put under another distribution licence
119.\" [including the GNU Public Licence.] 119.\" [including the GNU Public Licence.]
120.\" 120.\"
121.Dd $Mdocdate: March 5 2024 $ 121.Dd $Mdocdate: June 8 2025 $
122.Dt LH_NEW 3 122.Dt LH_NEW 3
123.Os 123.Os
124.Sh NAME 124.Sh NAME
@@ -137,6 +137,7 @@
137.Nm lh_strhash 137.Nm lh_strhash
138.Nd dynamic hash table 138.Nd dynamic hash table
139.Sh SYNOPSIS 139.Sh SYNOPSIS
140.Lb libcrypto
140.In openssl/lhash.h 141.In openssl/lhash.h
141.Fn DECLARE_LHASH_OF <type> 142.Fn DECLARE_LHASH_OF <type>
142.Ft LHASH * 143.Ft LHASH *
diff --git a/src/lib/libcrypto/man/s2i_ASN1_INTEGER.3 b/src/lib/libcrypto/man/s2i_ASN1_INTEGER.3
index a2105bc4bc..16646c69d1 100644
--- a/src/lib/libcrypto/man/s2i_ASN1_INTEGER.3
+++ b/src/lib/libcrypto/man/s2i_ASN1_INTEGER.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: s2i_ASN1_INTEGER.3,v 1.9 2024/12/27 15:30:17 schwarze Exp $ 1.\" $OpenBSD: s2i_ASN1_INTEGER.3,v 1.11 2025/06/13 18:34:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 27 2024 $ 17.Dd $Mdocdate: June 13 2025 $
18.Dt S2I_ASN1_INTEGER 3 18.Dt S2I_ASN1_INTEGER 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,35 +26,36 @@
26.Nm s2i_ASN1_OCTET_STRING 26.Nm s2i_ASN1_OCTET_STRING
27.Nd ASN.1 data type conversion utilities for certificate extensions 27.Nd ASN.1 data type conversion utilities for certificate extensions
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libcrypto
29.In openssl/asn1.h 30.In openssl/asn1.h
30.In openssl/x509v3.h 31.In openssl/x509v3.h
31.Ft "char *" 32.Ft char *
32.Fo i2s_ASN1_ENUMERATED 33.Fo i2s_ASN1_ENUMERATED
33.Fa "X509V3_EXT_METHOD *method" 34.Fa "X509V3_EXT_METHOD *method"
34.Fa "const ASN1_ENUMERATED *a" 35.Fa "const ASN1_ENUMERATED *a"
35.Fc 36.Fc
36.Ft "char *" 37.Ft char *
37.Fo i2s_ASN1_INTEGER 38.Fo i2s_ASN1_INTEGER
38.Fa "X509V3_EXT_METHOD *method" 39.Fa "X509V3_EXT_METHOD *method"
39.Fa "const ASN1_INTEGER *a" 40.Fa "const ASN1_INTEGER *a"
40.Fc 41.Fc
41.Ft "ASN1_INTEGER *" 42.Ft ASN1_INTEGER *
42.Fo s2i_ASN1_INTEGER 43.Fo s2i_ASN1_INTEGER
43.Fa "X509V3_EXT_METHOD *method" 44.Fa "X509V3_EXT_METHOD *method"
44.Fa "const char *value" 45.Fa "const char *value"
45.Fc 46.Fc
46.Ft "char *" 47.Ft char *
47.Fo i2s_ASN1_OCTET_STRING 48.Fo i2s_ASN1_OCTET_STRING
48.Fa "X509V3_EXT_METHOD *method" 49.Fa "X509V3_EXT_METHOD *method"
49.Fa "const ASN1_OCTET_STRING *aos" 50.Fa "const ASN1_OCTET_STRING *aos"
50.Fc 51.Fc
51.Ft "ASN1_OCTET_STRING *" 52.Ft ASN1_OCTET_STRING *
52.Fo s2i_ASN1_OCTET_STRING 53.Fo s2i_ASN1_OCTET_STRING
53.Fa "X509V3_EXT_METHOD *method" 54.Fa "X509V3_EXT_METHOD *method"
54.Fa "X509V3_CTX *ctx" 55.Fa "X509V3_CTX *ctx"
55.Fa "const char *value" 56.Fa "const char *value"
56.Fc 57.Fc
57.Ft "char *" 58.Ft char *
58.Fo i2s_ASN1_ENUMERATED_TABLE 59.Fo i2s_ASN1_ENUMERATED_TABLE
59.Fa "X509V3_EXT_METHOD *method" 60.Fa "X509V3_EXT_METHOD *method"
60.Fa "const ASN1_ENUMERATED *a" 61.Fa "const ASN1_ENUMERATED *a"
diff --git a/src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3 b/src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3
index 36d9f7496b..107a57ae35 100644
--- a/src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3
+++ b/src/lib/libcrypto/man/v2i_ASN1_BIT_STRING.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: v2i_ASN1_BIT_STRING.3,v 1.1 2024/12/24 09:48:56 schwarze Exp $ 1.\" $OpenBSD: v2i_ASN1_BIT_STRING.3,v 1.2 2025/06/08 22:40:31 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 24 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt V2I_ASN1_BIT_STRING 3 18.Dt V2I_ASN1_BIT_STRING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm i2v_ASN1_BIT_STRING 22.Nm i2v_ASN1_BIT_STRING
23.Nd ASN.1 BIT STRING utility functions for certificate extensions 23.Nd ASN.1 BIT STRING utility functions for certificate extensions
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libcrypto
25.In openssl/x509v3.h 26.In openssl/x509v3.h
26.Ft ASN1_BIT_STRING * 27.Ft ASN1_BIT_STRING *
27.Fo v2i_ASN1_BIT_STRING 28.Fo v2i_ASN1_BIT_STRING
diff --git a/src/lib/libcrypto/mlkem/mlkem.c b/src/lib/libcrypto/mlkem/mlkem.c
new file mode 100644
index 0000000000..bf53e5d77a
--- /dev/null
+++ b/src/lib/libcrypto/mlkem/mlkem.c
@@ -0,0 +1,416 @@
1/* $OpenBSD: mlkem.c,v 1.2 2025/08/14 16:04:01 beck Exp $ */
2/*
3 * Copyright (c) 2025, Bob Beck <beck@obtuse.com>
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17#include <stdlib.h>
18
19#include <openssl/mlkem.h>
20#include "mlkem_internal.h"
21
22static inline int
23private_key_is_new(const MLKEM_private_key *key)
24{
25 return (key != NULL &&
26 key->state == MLKEM_PRIVATE_KEY_UNINITIALIZED &&
27 (key->rank == RANK768 || key->rank == RANK1024));
28}
29
30static inline int
31private_key_is_valid(const MLKEM_private_key *key)
32{
33 return (key != NULL &&
34 key->state == MLKEM_PRIVATE_KEY_INITIALIZED &&
35 (key->rank == RANK768 || key->rank == RANK1024));
36}
37
38static inline int
39public_key_is_new(const MLKEM_public_key *key)
40{
41 return (key != NULL &&
42 key->state == MLKEM_PUBLIC_KEY_UNINITIALIZED &&
43 (key->rank == RANK768 || key->rank == RANK1024));
44}
45
46static inline int
47public_key_is_valid(const MLKEM_public_key *key)
48{
49 return (key != NULL &&
50 key->state == MLKEM_PUBLIC_KEY_INITIALIZED &&
51 (key->rank == RANK768 || key->rank == RANK1024));
52}
53
54/*
55 * ML-KEM operations
56 */
57
58int
59MLKEM_generate_key_external_entropy(MLKEM_private_key *private_key,
60 uint8_t **out_encoded_public_key, size_t *out_encoded_public_key_len,
61 const uint8_t *entropy)
62{
63 uint8_t *k = NULL;
64 size_t k_len = 0;
65 int ret = 0;
66
67 if (*out_encoded_public_key != NULL)
68 goto err;
69
70 if (!private_key_is_new(private_key))
71 goto err;
72
73 k_len = MLKEM768_PUBLIC_KEY_BYTES;
74 if (private_key->rank == RANK1024)
75 k_len = MLKEM1024_PUBLIC_KEY_BYTES;
76
77 if ((k = calloc(1, k_len)) == NULL)
78 goto err;
79
80 switch (private_key->rank) {
81 case RANK768:
82 if (!MLKEM768_generate_key_external_entropy(k, private_key,
83 entropy))
84 goto err;
85 break;
86 case RANK1024:
87 if (!MLKEM1024_generate_key_external_entropy(k, private_key,
88 entropy))
89 goto err;
90 break;
91 }
92
93 private_key->state = MLKEM_PRIVATE_KEY_INITIALIZED;
94
95 *out_encoded_public_key = k;
96 *out_encoded_public_key_len = k_len;
97 k = NULL;
98
99 ret = 1;
100
101 err:
102 freezero(k, k_len);
103
104 return ret;
105}
106
107int
108MLKEM_generate_key(MLKEM_private_key *private_key,
109 uint8_t **out_encoded_public_key, size_t *out_encoded_public_key_len,
110 uint8_t **out_optional_seed, size_t *out_optional_seed_len)
111{
112 uint8_t *entropy_buf = NULL;
113 int ret = 0;
114
115 if (*out_encoded_public_key != NULL)
116 goto err;
117
118 if (out_optional_seed != NULL && *out_optional_seed != NULL)
119 goto err;
120
121 if ((entropy_buf = calloc(1, MLKEM_SEED_LENGTH)) == NULL)
122 goto err;
123
124 arc4random_buf(entropy_buf, MLKEM_SEED_LENGTH);
125 if (!MLKEM_generate_key_external_entropy(private_key,
126 out_encoded_public_key, out_encoded_public_key_len,
127 entropy_buf))
128 goto err;
129
130 if (out_optional_seed != NULL) {
131 *out_optional_seed = entropy_buf;
132 *out_optional_seed_len = MLKEM_SEED_LENGTH;
133 entropy_buf = NULL;
134 }
135
136 ret = 1;
137
138 err:
139 freezero(entropy_buf, MLKEM_SEED_LENGTH);
140
141 return ret;
142}
143LCRYPTO_ALIAS(MLKEM_generate_key);
144
145int
146MLKEM_private_key_from_seed(MLKEM_private_key *private_key,
147 const uint8_t *seed, size_t seed_len)
148{
149 int ret = 0;
150
151 if (!private_key_is_new(private_key))
152 goto err;
153
154 if (seed_len != MLKEM_SEED_LENGTH)
155 goto err;
156
157 switch (private_key->rank) {
158 case RANK768:
159 if (!MLKEM768_private_key_from_seed(seed,
160 seed_len, private_key))
161 goto err;
162 break;
163 case RANK1024:
164 if (!MLKEM1024_private_key_from_seed(private_key,
165 seed, seed_len))
166 goto err;
167 break;
168 }
169
170 private_key->state = MLKEM_PRIVATE_KEY_INITIALIZED;
171
172 ret = 1;
173
174 err:
175
176 return ret;
177}
178LCRYPTO_ALIAS(MLKEM_private_key_from_seed);
179
180int
181MLKEM_public_from_private(const MLKEM_private_key *private_key,
182 MLKEM_public_key *public_key)
183{
184 if (!private_key_is_valid(private_key))
185 return 0;
186 if (!public_key_is_new(public_key))
187 return 0;
188 if (public_key->rank != private_key->rank)
189 return 0;
190 switch (private_key->rank) {
191 case RANK768:
192 MLKEM768_public_from_private(private_key, public_key);
193 break;
194 case RANK1024:
195 MLKEM1024_public_from_private(private_key, public_key);
196 break;
197 }
198
199 public_key->state = MLKEM_PUBLIC_KEY_INITIALIZED;
200
201 return 1;
202}
203LCRYPTO_ALIAS(MLKEM_public_from_private);
204
205int
206MLKEM_encap_external_entropy(const MLKEM_public_key *public_key,
207 const uint8_t *entropy, uint8_t **out_ciphertext,
208 size_t *out_ciphertext_len, uint8_t **out_shared_secret,
209 size_t *out_shared_secret_len)
210{
211 uint8_t *secret = NULL;
212 uint8_t *ciphertext = NULL;
213 size_t ciphertext_len = 0;
214 int ret = 0;
215
216 if (*out_ciphertext != NULL)
217 goto err;
218
219 if (*out_shared_secret != NULL)
220 goto err;
221
222 if (!public_key_is_valid(public_key))
223 goto err;
224
225 if ((secret = calloc(1, MLKEM_SHARED_SECRET_LENGTH)) == NULL)
226 goto err;
227
228 ciphertext_len = MLKEM_public_key_ciphertext_length(public_key);
229
230 if ((ciphertext = calloc(1, ciphertext_len)) == NULL)
231 goto err;
232
233 switch (public_key->rank) {
234 case RANK768:
235 MLKEM768_encap_external_entropy(ciphertext, secret, public_key,
236 entropy);
237 break;
238
239 case RANK1024:
240 MLKEM1024_encap_external_entropy(ciphertext, secret, public_key,
241 entropy);
242 break;
243 }
244 *out_ciphertext = ciphertext;
245 *out_ciphertext_len = ciphertext_len;
246 ciphertext = NULL;
247 *out_shared_secret = secret;
248 *out_shared_secret_len = MLKEM_SHARED_SECRET_LENGTH;
249 secret = NULL;
250
251 ret = 1;
252
253 err:
254 freezero(secret, MLKEM_SHARED_SECRET_LENGTH);
255 freezero(ciphertext, ciphertext_len);
256
257 return ret;
258}
259
260int
261MLKEM_encap(const MLKEM_public_key *public_key,
262 uint8_t **out_ciphertext, size_t *out_ciphertext_len,
263 uint8_t **out_shared_secret, size_t *out_shared_secret_len)
264{
265 uint8_t entropy[MLKEM_ENCAP_ENTROPY];
266
267 arc4random_buf(entropy, MLKEM_ENCAP_ENTROPY);
268
269 return MLKEM_encap_external_entropy(public_key, entropy, out_ciphertext,
270 out_ciphertext_len, out_shared_secret, out_shared_secret_len);
271}
272LCRYPTO_ALIAS(MLKEM_encap);
273
274int
275MLKEM_decap(const MLKEM_private_key *private_key,
276 const uint8_t *ciphertext, size_t ciphertext_len,
277 uint8_t **out_shared_secret, size_t *out_shared_secret_len)
278{
279 uint8_t *s = NULL;
280 int ret = 0;
281
282 if (*out_shared_secret != NULL)
283 goto err;
284
285 if (!private_key_is_valid(private_key))
286 goto err;
287
288 if (ciphertext_len != MLKEM_private_key_ciphertext_length(private_key))
289 goto err;
290
291 if ((s = calloc(1, MLKEM_SHARED_SECRET_LENGTH)) == NULL)
292 goto err;
293
294 switch (private_key->rank) {
295 case RANK768:
296 MLKEM768_decap(private_key, ciphertext, ciphertext_len, s);
297 break;
298
299 case RANK1024:
300 MLKEM1024_decap(private_key, ciphertext, ciphertext_len, s);
301 break;
302 }
303
304 *out_shared_secret = s;
305 *out_shared_secret_len = MLKEM_SHARED_SECRET_LENGTH;
306 s = NULL;
307
308 ret = 1;
309
310 err:
311 freezero(s, MLKEM_SHARED_SECRET_LENGTH);
312
313 return ret;
314}
315LCRYPTO_ALIAS(MLKEM_decap);
316
317int
318MLKEM_marshal_public_key(const MLKEM_public_key *public_key, uint8_t **out,
319 size_t *out_len)
320{
321 if (*out != NULL)
322 return 0;
323
324 if (!public_key_is_valid(public_key))
325 return 0;
326
327 switch (public_key->rank) {
328 case RANK768:
329 return MLKEM768_marshal_public_key(public_key, out, out_len);
330 case RANK1024:
331 return MLKEM1024_marshal_public_key(public_key, out, out_len);
332 default:
333 return 0;
334 }
335}
336LCRYPTO_ALIAS(MLKEM_marshal_public_key);
337
338/*
339 * Not exposed publicly, becuase the NIST private key format is gigantisch, and
340 * seeds should be used instead. Used for the NIST tests.
341 */
342int
343MLKEM_marshal_private_key(const MLKEM_private_key *private_key, uint8_t **out,
344 size_t *out_len)
345{
346 if (*out != NULL)
347 return 0;
348
349 if (!private_key_is_valid(private_key))
350 return 0;
351
352 switch (private_key->rank) {
353 case RANK768:
354 return MLKEM768_marshal_private_key(private_key, out, out_len);
355 case RANK1024:
356 return MLKEM1024_marshal_private_key(private_key, out, out_len);
357 default:
358 return 0;
359 }
360}
361
362int
363MLKEM_parse_public_key(MLKEM_public_key *public_key, const uint8_t *in,
364 size_t in_len)
365{
366 if (!public_key_is_new(public_key))
367 return 0;
368
369 if (in_len != MLKEM_public_key_encoded_length(public_key))
370 return 0;
371
372 switch (public_key->rank) {
373 case RANK768:
374 if (!MLKEM768_parse_public_key(in, in_len,
375 public_key))
376 return 0;
377 break;
378 case RANK1024:
379 if (!MLKEM1024_parse_public_key(in, in_len,
380 public_key))
381 return 0;
382 break;
383 }
384
385 public_key->state = MLKEM_PUBLIC_KEY_INITIALIZED;
386
387 return 1;
388}
389LCRYPTO_ALIAS(MLKEM_parse_public_key);
390
391int
392MLKEM_parse_private_key(MLKEM_private_key *private_key, const uint8_t *in,
393 size_t in_len)
394{
395 if (!private_key_is_new(private_key))
396 return 0;
397
398 if (in_len != MLKEM_private_key_encoded_length(private_key))
399 return 0;
400
401 switch (private_key->rank) {
402 case RANK768:
403 if (!MLKEM768_parse_private_key(in, in_len, private_key))
404 return 0;
405 break;
406 case RANK1024:
407 if (!MLKEM1024_parse_private_key(in, in_len, private_key))
408 return 0;
409 break;
410 }
411
412 private_key->state = MLKEM_PRIVATE_KEY_INITIALIZED;
413
414 return 1;
415}
416LCRYPTO_ALIAS(MLKEM_parse_private_key);
diff --git a/src/lib/libcrypto/mlkem/mlkem.h b/src/lib/libcrypto/mlkem/mlkem.h
index 055d92290e..31d4858195 100644
--- a/src/lib/libcrypto/mlkem/mlkem.h
+++ b/src/lib/libcrypto/mlkem/mlkem.h
@@ -1,6 +1,6 @@
1/* $OpenBSD: mlkem.h,v 1.5 2025/03/28 12:17:16 tb Exp $ */ 1/* $OpenBSD: mlkem.h,v 1.7 2025/08/14 15:48:48 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2024, Google Inc. 3 * Copyright (c) 2025 Bob Beck <beck@obtuse.com>
4 * 4 *
5 * Permission to use, copy, modify, and/or distribute this software for any 5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above 6 * purpose with or without fee is hereby granted, provided that the above
@@ -25,258 +25,203 @@
25extern "C" { 25extern "C" {
26#endif 26#endif
27 27
28/* Hack for now */
29struct cbs_st;
30struct cbb_st;
31
32/*
33 * ML-KEM-768
34 *
35 * This implements the Module-Lattice-Based Key-Encapsulation Mechanism from
36 * https://csrc.nist.gov/pubs/fips/204/final
37 */
38
39/* 28/*
40 * MLKEM768_public_key contains a ML-KEM-768 public key. The contents of this 29 * ML-KEM constants
41 * object should never leave the address space since the format is unstable.
42 */ 30 */
43struct MLKEM768_public_key {
44 union {
45 uint8_t bytes[512 * (3 + 9) + 32 + 32];
46 uint16_t alignment;
47 } opaque;
48};
49 31
50/* 32#define RANK768 3
51 * MLKEM768_private_key contains a ML-KEM-768 private key. The contents of this 33#define RANK1024 4
52 * object should never leave the address space since the format is unstable.
53 */
54struct MLKEM768_private_key {
55 union {
56 uint8_t bytes[512 * (3 + 3 + 9) + 32 + 32 + 32];
57 uint16_t alignment;
58 } opaque;
59};
60 34
61/* 35/*
62 * MLKEM768_PUBLIC_KEY_BYTES is the number of bytes in an encoded ML-KEM768 public 36 * ML-KEM keys
63 * key.
64 */ 37 */
65#define MLKEM768_PUBLIC_KEY_BYTES 1184
66 38
67/* MLKEM_SEED_BYTES is the number of bytes in an ML-KEM seed. */ 39typedef struct MLKEM_private_key_st MLKEM_private_key;
68#define MLKEM_SEED_BYTES 64 40typedef struct MLKEM_public_key_st MLKEM_public_key;
69 41
70/* 42/*
71 * MLKEM_SHARED_SECRET_BYTES is the number of bytes in the ML-KEM768 shared 43 * MLKEM_private_key_new allocates a new uninitialized ML-KEM private key for
72 * secret. Although the round-3 specification has a variable-length output, the 44 * |rank|, which must be RANK768 or RANK1024. It returns a pointer to an
73 * final ML-KEM construction is expected to use a fixed 32-byte output. To 45 * allocated structure suitable for holding a generated private key of the
74 * simplify the future transition, we apply the same restriction. 46 * corresponding rank on success, NULL is returned on failure. The caller is
47 * responsible for deallocating the resulting key with |MLKEM_private_key_free|.
75 */ 48 */
76#define MLKEM_SHARED_SECRET_BYTES 32 49MLKEM_private_key *MLKEM_private_key_new(int rank);
77 50
78/* 51/*
79 * MLKEM_generate_key generates a random public/private key pair, writes the 52 * MLKEM_private_key_free zeroes and frees all memory for |key| if |key| is
80 * encoded public key to |out_encoded_public_key| and sets |out_private_key| to 53 * non NULL. If |key| is NULL it does nothing and returns.
81 * the private key. If |optional_out_seed| is not NULL then the seed used to
82 * generate the private key is written to it.
83 */ 54 */
84void MLKEM768_generate_key( 55void MLKEM_private_key_free(MLKEM_private_key *key);
85 uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
86 uint8_t optional_out_seed[MLKEM_SEED_BYTES],
87 struct MLKEM768_private_key *out_private_key);
88 56
89/* 57/*
90 * MLKEM768_private_key_from_seed derives a private key from a seed that was 58 * MLKEM_private_key_encoded_length the number of bytes used by the encoded form
91 * generated by |MLKEM768_generate_key|. It fails and returns 0 if |seed_len| is 59 * of |key|. Thie corresponds to the length of the buffer allocated for the
92 * incorrect, otherwise it writes |*out_private_key| and returns 1. 60 * encoded_public_key from |MLKEM_marshal_private_key|. Zero is returned if
61 * |key| is NULL or has an invalid rank.
93 */ 62 */
94int MLKEM768_private_key_from_seed(struct MLKEM768_private_key *out_private_key, 63size_t MLKEM_private_key_encoded_length(const MLKEM_private_key *key);
95 const uint8_t *seed, size_t seed_len);
96 64
97/* 65/*
98 * MLKEM_public_from_private sets |*out_public_key| to the public key that 66 * MLKEM_private_key_ciphertext_length returns the number of bytes of ciphertext
99 * corresponds to |private_key|. (This is faster than parsing the output of 67 * required to decrypt a shared secret with |key| using |MLKEM_decap|. Zero is
100 * |MLKEM_generate_key| if, for some reason, you need to encapsulate to a key 68 * returned if |key| is NULL or has an invalid rank.
101 * that was just generated.)
102 */ 69 */
103void MLKEM768_public_from_private(struct MLKEM768_public_key *out_public_key, 70size_t MLKEM_private_key_ciphertext_length(const MLKEM_private_key *key);
104 const struct MLKEM768_private_key *private_key);
105
106/* MLKEM768_CIPHERTEXT_BYTES is number of bytes in the ML-KEM768 ciphertext. */
107#define MLKEM768_CIPHERTEXT_BYTES 1088
108 71
109/* 72/*
110 * MLKEM768_encap encrypts a random shared secret for |public_key|, writes the 73 * MLKEM_public_key_new allocates a new uninitialized ML-KEM public key for
111 * ciphertext to |out_ciphertext|, and writes the random shared secret to 74 * |rank|, which must be RANK768 or RANK1024. It returns a pointer to an
112 * |out_shared_secret|. 75 * allocated structure suitable for holding a generated public key of the
76 * corresponding rank on success, NULL is returned on failure. The caller is
77 * responsible for deallocating the resulting key with |MLKEM_public_key_free|.
113 */ 78 */
114void MLKEM768_encap(uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES], 79MLKEM_public_key *MLKEM_public_key_new(int rank);
115 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
116 const struct MLKEM768_public_key *public_key);
117 80
118/* 81/*
119 * MLKEM768_decap decrypts a shared secret from |ciphertext| using |private_key| 82 * MLKEM_public_key_free zeros and deallocates all memory for |key| if |key| is
120 * and writes it to |out_shared_secret|. If |ciphertext_len| is incorrect it 83 * non NULL. If |key| is NULL it does nothing and returns.
121 * returns 0, otherwise it rreturns 1. If |ciphertext| is invalid,
122 * |out_shared_secret| is filled with a key that will always be the same for the
123 * same |ciphertext| and |private_key|, but which appears to be random unless
124 * one has access to |private_key|. These alternatives occur in constant time.
125 * Any subsequent symmetric encryption using |out_shared_secret| must use an
126 * authenticated encryption scheme in order to discover the decapsulation
127 * failure.
128 */ 84 */
129int MLKEM768_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 85void MLKEM_public_key_free(MLKEM_public_key *key);
130 const uint8_t *ciphertext, size_t ciphertext_len,
131 const struct MLKEM768_private_key *private_key);
132
133/* Serialisation of keys. */
134 86
135/* 87/*
136 * MLKEM768_marshal_public_key serializes |public_key| to |out| in the standard 88 * MLKEM_public_key_encoded_length the number of bytes used by the encoded form
137 * format for ML-KEM public keys. It returns one on success or zero on allocation 89 * of |key|. Thie corresponds to the length of the buffer allocated for the
138 * error. 90 * encoded_public_key from |MLKEM_generate_key| or |MLKEM_marshal_public_key|.
91 * Zero is returned if |key| is NULL or has an invalid rank.
139 */ 92 */
140int MLKEM768_marshal_public_key(struct cbb_st *out, 93size_t MLKEM_public_key_encoded_length(const MLKEM_public_key *key);
141 const struct MLKEM768_public_key *public_key);
142 94
143/* 95/*
144 * MLKEM768_parse_public_key parses a public key, in the format generated by 96 * MLKEM_public_key_cipertext_length returns the number of bytes produced as the
145 * |MLKEM_marshal_public_key|, from |in| and writes the result to 97 * ciphertext when encrypting a shared secret with |key| using |MLKEM_encap|. Zero
146 * |out_public_key|. It returns one on success or zero on parse error or if 98 * is returned if |key| is NULL or has an invalid rank.
147 * there are trailing bytes in |in|.
148 */ 99 */
149int MLKEM768_parse_public_key(struct MLKEM768_public_key *out_public_key, 100size_t MLKEM_public_key_ciphertext_length(const MLKEM_public_key *key);
150 struct cbs_st *in);
151 101
152/* 102/*
153 * MLKEM_parse_private_key parses a private key, in the format generated by 103 * ML-KEM operations
154 * |MLKEM_marshal_private_key|, from |in| and writes the result to
155 * |out_private_key|. It returns one on success or zero on parse error or if
156 * there are trailing bytes in |in|. This formate is verbose and should be avoided.
157 * Private keys should be stored as seeds and parsed using |MLKEM768_private_key_from_seed|.
158 */ 104 */
159int MLKEM768_parse_private_key(struct MLKEM768_private_key *out_private_key,
160 struct cbs_st *in);
161 105
162/* 106/*
163 * ML-KEM-1024 107 * MLKEM_generate_key generates a random private/public key pair, initializing
108 * |private_key|. It returns one on success, and zero on failure or error.
109 * |private_key| must be a new uninitialized key. |*out_encoded_public_key| and
110 * |*out_optional_seed|, if provided, must have the value of NULL. On success, a
111 * pointer to the encoded public key of the correct size for |key| is returned
112 * in |out_encoded_public_key|, and the length in bytes of
113 * |*out_encoded_public_key| is returned in |out_encoded_public_key_len|. If
114 * |out_optional_seed| is not NULL, a pointer to the seed used to generate the
115 * private key is returned in |*out_optional_seed| and the length in bytes of
116 * the seed is returned in |*out_optional_seed_len|. The caller is responsible
117 * for freeing the values returned in |out_encoded_public_key|, and
118 * |out_optional_seed|.
164 * 119 *
165 * ML-KEM-1024 also exists. You should prefer ML-KEM-768 where possible. 120 * In the event a private key needs to be saved, The normal best practice is to
121 * save |out_optional_seed| as the private key, along with the ML-KEM rank value.
122 * An MLKEM_private_key of the correct rank can then be constructed using
123 * |MLKEM_private_key_from_seed|.
166 */ 124 */
125int MLKEM_generate_key(MLKEM_private_key *private_key,
126 uint8_t **out_encoded_public_key, size_t *out_encoded_public_key_len,
127 uint8_t **out_optional_seed, size_t *out_optional_seed_len);
167 128
168/* 129/*
169 * MLKEM1024_public_key contains an ML-KEM-1024 public key. The contents of this 130 * MLKEM_private_key_from_seed derives a private key from a seed that was
170 * object should never leave the address space since the format is unstable. 131 * generated by |MLKEM_generate_key| initializing |private_key|. It returns one
171 */ 132 * on success, and zero on failure or error. |private_key| must be a new
172struct MLKEM1024_public_key { 133 * uninitialized key. |seed_len| must be MLKEM_SEED_LENGTH.
173 union { 134 *
174 uint8_t bytes[512 * (4 + 16) + 32 + 32]; 135 * For |private_key| to match the key generated by |MLKEM_generate_key|,
175 uint16_t alignment; 136 * |private_key| must have been created with the same rank as used when generating
176 } opaque; 137 * the key.
177};
178
179/*
180 * MLKEM1024_private_key contains a ML-KEM-1024 private key. The contents of
181 * this object should never leave the address space since the format is
182 * unstable.
183 */
184struct MLKEM1024_private_key {
185 union {
186 uint8_t bytes[512 * (4 + 4 + 16) + 32 + 32 + 32];
187 uint16_t alignment;
188 } opaque;
189};
190
191/*
192 * MLKEM1024_PUBLIC_KEY_BYTES is the number of bytes in an encoded ML-KEM-1024
193 * public key.
194 */
195#define MLKEM1024_PUBLIC_KEY_BYTES 1568
196
197/*
198 * MLKEM1024_generate_key generates a random public/private key pair, writes the
199 * encoded public key to |out_encoded_public_key| and sets |out_private_key| to
200 * the private key. If |optional_out_seed| is not NULL then the seed used to
201 * generate the private key is written to it.
202 */ 138 */
203void MLKEM1024_generate_key( 139int MLKEM_private_key_from_seed(MLKEM_private_key *private_key,
204 uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES], 140 const uint8_t *seed, size_t seed_len);
205 uint8_t optional_out_seed[MLKEM_SEED_BYTES],
206 struct MLKEM1024_private_key *out_private_key);
207 141
208/* 142/*
209 * MLKEM1024_private_key_from_seed derives a private key from a seed that was 143 * MLKEM_public_from_private initializes |public_key| with the public key that
210 * generated by |MLKEM1024_generate_key|. It fails and returns 0 if |seed_len| 144 * corresponds to |private_key|. It returns one on success and zero on
211 * is incorrect, otherwise it writes |*out_private_key| and returns 1. 145 * error. This is faster than parsing the output of |MLKEM_generate_key| if, for
146 * some reason, you need to encapsulate to a key that was just
147 * generated. |private key| must be a new uninitialized key, of the same rank as
148 * |public_key|.
212 */ 149 */
213int MLKEM1024_private_key_from_seed( 150int MLKEM_public_from_private(const MLKEM_private_key *private_key,
214 struct MLKEM1024_private_key *out_private_key, const uint8_t *seed, 151 MLKEM_public_key *public_key);
215 size_t seed_len);
216 152
217/* 153/*
218 * MLKEM1024_public_from_private sets |*out_public_key| to the public key that 154 * MLKEM_encap encrypts a random shared secret for an initialized
219 * corresponds to |private_key|. (This is faster than parsing the output of 155 * |public_key|. It returns one on success, and zero on failure or error. |*out
220 * |MLKEM1024_generate_key| if, for some reason, you need to encapsulate to a 156 * ciphertext| and |*out_shared_secret| must have the value NULL. On success, a
221 * key that was just generated.) 157 * pointer to the ciphertext of the correct size for |key| is returned in
158 * |out_ciphertext|, the length in bytes of |*out_ciphertext| is returned in
159 * |*out_ciphertext_len|, a pointer to the random shared secret is returned in
160 * |out_shared_secret|, and the length in bytes of |*out_shared_secret| is
161 * returned in |*out_ciphtertext_len|. The caller is responsible for zeroing and
162 * freeing the values returned in |out_ciphertext| and |out_shared_secret|
222 */ 163 */
223void MLKEM1024_public_from_private(struct MLKEM1024_public_key *out_public_key, 164int MLKEM_encap(const MLKEM_public_key *public_key,
224 const struct MLKEM1024_private_key *private_key); 165 uint8_t **out_ciphertext, size_t *out_ciphertext_len,
225 166 uint8_t **out_shared_secret, size_t *out_shared_secret_len);
226/* MLKEM1024_CIPHERTEXT_BYTES is number of bytes in the ML-KEM-1024 ciphertext. */
227#define MLKEM1024_CIPHERTEXT_BYTES 1568
228 167
229/* 168/*
230 * MLKEM1024_encap encrypts a random shared secret for |public_key|, writes the 169 * MLKEM_decap decrypts a shared secret from |ciphertext| using an initialized
231 * ciphertext to |out_ciphertext|, and writes the random shared secret to 170 * |private_key|. It returns a pointer to the shared secret|out_shared_secret|
232 * |out_shared_secret|. 171 * and the length in bytes of |*out_shared_secret| in |*out_shared_secret_len|.
233 */ 172 *
234void MLKEM1024_encap(uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES], 173 * If |ciphertext_len| is incorrect for |private_key|, |*out_shared_secret| is
235 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 174 * not NULL, or memory can not be allocated, it returns zero, otherwise it
236 const struct MLKEM1024_public_key *public_key); 175 * returns one. If |ciphertext| is invalid, a pointer is returned in
237 176 * |out_shared_secret| pointing to a key that will always be the same for the
238/* 177 * same |ciphertext| and |private_key|, but which appears to be random unless
239 * MLKEM1024_decap decrypts a shared secret from |ciphertext| using 178 * one has access to |private_key|. These alternatives occur in constant time.
240 * |private_key| and writes it to |out_shared_secret|. If |ciphertext_len| is 179 * Any subsequent symmetric encryption using |out_shared_secret| must use an
241 * incorrect it returns 0, otherwise it returns 1. If |ciphertext| is invalid 180 * authenticated encryption scheme in order to discover the decapsulation
242 * (but of the correct length), |out_shared_secret| is filled with a key that 181 * failure. The caller is responsible for zeroing and freeing the value returned
243 * will always be the same for the same |ciphertext| and |private_key|, but 182 * in |out_shared_secret|.
244 * which appears to be random unless one has access to |private_key|. These
245 * alternatives occur in constant time. Any subsequent symmetric encryption
246 * using |out_shared_secret| must use an authenticated encryption scheme in
247 * order to discover the decapsulation failure.
248 */ 183 */
249int MLKEM1024_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 184int MLKEM_decap(const MLKEM_private_key *private_key,
250 const uint8_t *ciphertext, size_t ciphertext_len, 185 const uint8_t *ciphertext, size_t ciphertext_len,
251 const struct MLKEM1024_private_key *private_key); 186 uint8_t **out_shared_secret, size_t *out_shared_secret_len);
187
188/* Serialization of ML-KEM keys. */
252 189
253/* 190/*
254 * Serialisation of ML-KEM-1024 keys. 191 * MLKEM_marshal_public_key serializes an initialized |public_key| in the
255 * MLKEM1024_marshal_public_key serializes |public_key| to |out| in the standard 192 * standard format for ML-KEM public keys. It returns one on success or zero on
256 * format for ML-KEM-1024 public keys. It returns one on success or zero on 193 * allocation error or failure. |*out| must have the value NULL. On success a
257 * allocation error. 194 * pointer is returned in |out| to the encoded public key matching |public_key|,
195 * and a pointer to the length in bytes of the encoded public key is stored in
196 * |out_len|. The caller is responsible for freeing the values returned in
197 * |out|.
258 */ 198 */
259int MLKEM1024_marshal_public_key(struct cbb_st *out, 199int MLKEM_marshal_public_key(const MLKEM_public_key *public_key, uint8_t **out,
260 const struct MLKEM1024_public_key *public_key); 200 size_t *out_len);
261 201
262/* 202/*
263 * MLKEM1024_parse_public_key parses a public key, in the format generated by 203 * MLKEM_parse_public_key parses a public key, in the format generated by
264 * |MLKEM1024_marshal_public_key|, from |in| and writes the result to 204 * |MLKEM_marshal_public_key|, from |in|. It returns one on success or zero on
265 * |out_public_key|. It returns one on success or zero on parse error or if 205 * error or failure. |public_key| must be a new uninitialized key. |in_len| must
266 * there are trailing bytes in |in|. 206 * be the correct length for the encoded format of |public_key. On success
207 * |public_key| is initialized to the value parsed from |in|.
267 */ 208 */
268int MLKEM1024_parse_public_key(struct MLKEM1024_public_key *out_public_key, 209int MLKEM_parse_public_key(MLKEM_public_key *public_key, const uint8_t *in,
269 struct cbs_st *in); 210 size_t in_len);
270 211
271/* 212/*
272 * MLKEM1024_parse_private_key parses a private key, in NIST's format for 213 * MLKEM_parse_private_key parses a private key, in the format generated by
273 * private keys, from |in| and writes the result to |out_private_key|. It 214 * |MLKEM_marshal_private_key|, from |in|. It returns one on success or zero on
274 * returns one on success or zero on parse error or if there are trailing bytes 215 * error or failure. |private_key| must be a new uninitialized key. |in_len|
275 * in |in|. This format is verbose and should be avoided. Private keys should be 216 * must be the correct length for the encoded format of |private_key. On success
276 * stored as seeds and parsed using |MLKEM1024_private_key_from_seed|. 217 * |private_key| is initialized to the value parsed from |in|.
218 *
219 * This format is wastefully verbose and should be avoided. Private keys should
220 * be stored as seeds from |MLKEM_generate_key|, and then parsed using
221 * |MLKEM_private_key_from_seed|.
277 */ 222 */
278int MLKEM1024_parse_private_key(struct MLKEM1024_private_key *out_private_key, 223int MLKEM_parse_private_key(MLKEM_private_key *private_key, const uint8_t *in,
279 struct cbs_st *in); 224 size_t in_len);
280 225
281#if defined(__cplusplus) 226#if defined(__cplusplus)
282} 227}
diff --git a/src/lib/libcrypto/mlkem/mlkem1024.c b/src/lib/libcrypto/mlkem/mlkem1024.c
index f6fccdf6a8..8f4f41f8ff 100644
--- a/src/lib/libcrypto/mlkem/mlkem1024.c
+++ b/src/lib/libcrypto/mlkem/mlkem1024.c
@@ -1,7 +1,7 @@
1/* $OpenBSD: mlkem1024.c,v 1.6 2025/01/03 08:19:24 tb Exp $ */ 1/* $OpenBSD: mlkem1024.c,v 1.12 2025/08/14 15:48:48 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2024, Google Inc. 3 * Copyright (c) 2024, Google Inc.
4 * Copyright (c) 2024, Bob Beck <beck@obtuse.com> 4 * Copyright (c) 2024, 2025 Bob Beck <beck@obtuse.com>
5 * 5 *
6 * Permission to use, copy, modify, and/or distribute this software for any 6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -20,18 +20,14 @@
20#include <stdlib.h> 20#include <stdlib.h>
21#include <string.h> 21#include <string.h>
22 22
23#include "bytestring.h" 23#include <openssl/mlkem.h>
24#include "mlkem.h"
25 24
25#include "bytestring.h"
26#include "sha3_internal.h" 26#include "sha3_internal.h"
27#include "mlkem_internal.h" 27#include "mlkem_internal.h"
28#include "constant_time.h" 28#include "constant_time.h"
29#include "crypto_internal.h" 29#include "crypto_internal.h"
30 30
31/* Remove later */
32#undef LCRYPTO_ALIAS
33#define LCRYPTO_ALIAS(A)
34
35/* 31/*
36 * See 32 * See
37 * https://csrc.nist.gov/pubs/fips/203/final 33 * https://csrc.nist.gov/pubs/fips/203/final
@@ -80,7 +76,6 @@ kdf(uint8_t out[MLKEM_SHARED_SECRET_BYTES], const uint8_t failure_secret[32],
80} 76}
81 77
82#define DEGREE 256 78#define DEGREE 256
83#define RANK1024 4
84 79
85static const size_t kBarrettMultiplier = 5039; 80static const size_t kBarrettMultiplier = 5039;
86static const unsigned kBarrettShift = 24; 81static const unsigned kBarrettShift = 24;
@@ -612,6 +607,19 @@ vector_encode(uint8_t *out, const vector *a, int bits)
612 } 607 }
613} 608}
614 609
610/* Encodes an entire vector as above, but adding it to a CBB */
611static int
612vector_encode_cbb(CBB *cbb, const vector *a, int bits)
613{
614 uint8_t *encoded_vector;
615
616 if (!CBB_add_space(cbb, &encoded_vector, kEncodedVectorSize))
617 return 0;
618 vector_encode(encoded_vector, a, bits);
619
620 return 1;
621}
622
615/* 623/*
616 * scalar_decode parses |DEGREE * bits| bits from |in| into |DEGREE| values in 624 * scalar_decode parses |DEGREE * bits| bits from |in| into |DEGREE| values in
617 * |out|. It returns one on success and zero if any parsed value is >= 625 * |out|. It returns one on success and zero if any parsed value is >=
@@ -793,10 +801,14 @@ struct public_key {
793 matrix m; 801 matrix m;
794}; 802};
795 803
804CTASSERT(sizeof(struct MLKEM1024_public_key) == sizeof(struct public_key));
805
796static struct public_key * 806static struct public_key *
797public_key_1024_from_external(const struct MLKEM1024_public_key *external) 807public_key_1024_from_external(const MLKEM_public_key *external)
798{ 808{
799 return (struct public_key *)external; 809 if (external->rank != RANK1024)
810 return NULL;
811 return (struct public_key *)external->key_1024;
800} 812}
801 813
802struct private_key { 814struct private_key {
@@ -805,33 +817,36 @@ struct private_key {
805 uint8_t fo_failure_secret[32]; 817 uint8_t fo_failure_secret[32];
806}; 818};
807 819
820CTASSERT(sizeof(struct MLKEM1024_private_key) == sizeof(struct private_key));
821
808static struct private_key * 822static struct private_key *
809private_key_1024_from_external(const struct MLKEM1024_private_key *external) 823private_key_1024_from_external(const MLKEM_private_key *external)
810{ 824{
811 return (struct private_key *)external; 825 if (external->rank != RANK1024)
826 return NULL;
827 return (struct private_key *)external->key_1024;
812} 828}
813 829
814/* 830/*
815 * Calls |MLKEM1024_generate_key_external_entropy| with random bytes from 831 * Calls |MLKEM1024_generate_key_external_entropy| with random bytes from
816 * |RAND_bytes|. 832 * |RAND_bytes|.
817 */ 833 */
818void 834int
819MLKEM1024_generate_key(uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES], 835MLKEM1024_generate_key(uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES],
820 uint8_t optional_out_seed[MLKEM_SEED_BYTES], 836 uint8_t optional_out_seed[MLKEM_SEED_BYTES],
821 struct MLKEM1024_private_key *out_private_key) 837 MLKEM_private_key *out_private_key)
822{ 838{
823 uint8_t entropy_buf[MLKEM_SEED_BYTES]; 839 uint8_t entropy_buf[MLKEM_SEED_BYTES];
824 uint8_t *entropy = optional_out_seed != NULL ? optional_out_seed : 840 uint8_t *entropy = optional_out_seed != NULL ? optional_out_seed :
825 entropy_buf; 841 entropy_buf;
826 842
827 arc4random_buf(entropy, MLKEM_SEED_BYTES); 843 arc4random_buf(entropy, MLKEM_SEED_BYTES);
828 MLKEM1024_generate_key_external_entropy(out_encoded_public_key, 844 return MLKEM1024_generate_key_external_entropy(out_encoded_public_key,
829 out_private_key, entropy); 845 out_private_key, entropy);
830} 846}
831LCRYPTO_ALIAS(MLKEM1024_generate_key);
832 847
833int 848int
834MLKEM1024_private_key_from_seed(struct MLKEM1024_private_key *out_private_key, 849MLKEM1024_private_key_from_seed(MLKEM_private_key *out_private_key,
835 const uint8_t *seed, size_t seed_len) 850 const uint8_t *seed, size_t seed_len)
836{ 851{
837 uint8_t public_key_bytes[MLKEM1024_PUBLIC_KEY_BYTES]; 852 uint8_t public_key_bytes[MLKEM1024_PUBLIC_KEY_BYTES];
@@ -839,32 +854,22 @@ MLKEM1024_private_key_from_seed(struct MLKEM1024_private_key *out_private_key,
839 if (seed_len != MLKEM_SEED_BYTES) { 854 if (seed_len != MLKEM_SEED_BYTES) {
840 return 0; 855 return 0;
841 } 856 }
842 MLKEM1024_generate_key_external_entropy(public_key_bytes, 857 return MLKEM1024_generate_key_external_entropy(public_key_bytes,
843 out_private_key, seed); 858 out_private_key, seed);
844
845 return 1;
846} 859}
847LCRYPTO_ALIAS(MLKEM1024_private_key_from_seed);
848 860
849static int 861static int
850mlkem_marshal_public_key(CBB *out, const struct public_key *pub) 862mlkem_marshal_public_key(CBB *out, const struct public_key *pub)
851{ 863{
852 uint8_t *vector_output; 864 if (!vector_encode_cbb(out, &pub->t, kLog2Prime))
853
854 if (!CBB_add_space(out, &vector_output, kEncodedVectorSize)) {
855 return 0;
856 }
857 vector_encode(vector_output, &pub->t, kLog2Prime);
858 if (!CBB_add_bytes(out, pub->rho, sizeof(pub->rho))) {
859 return 0; 865 return 0;
860 } 866 return CBB_add_bytes(out, pub->rho, sizeof(pub->rho));
861 return 1;
862} 867}
863 868
864void 869int
865MLKEM1024_generate_key_external_entropy( 870MLKEM1024_generate_key_external_entropy(
866 uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES], 871 uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES],
867 struct MLKEM1024_private_key *out_private_key, 872 MLKEM_private_key *out_private_key,
868 const uint8_t entropy[MLKEM_SEED_BYTES]) 873 const uint8_t entropy[MLKEM_SEED_BYTES])
869{ 874{
870 struct private_key *priv = private_key_1024_from_external( 875 struct private_key *priv = private_key_1024_from_external(
@@ -875,7 +880,9 @@ MLKEM1024_generate_key_external_entropy(
875 uint8_t hashed[64]; 880 uint8_t hashed[64];
876 vector error; 881 vector error;
877 CBB cbb; 882 CBB cbb;
883 int ret = 0;
878 884
885 memset(&cbb, 0, sizeof(CBB));
879 memcpy(augmented_seed, entropy, 32); 886 memcpy(augmented_seed, entropy, 32);
880 augmented_seed[32] = RANK1024; 887 augmented_seed[32] = RANK1024;
881 hash_g(hashed, augmented_seed, 33); 888 hash_g(hashed, augmented_seed, 33);
@@ -890,21 +897,28 @@ MLKEM1024_generate_key_external_entropy(
890 matrix_mult_transpose(&priv->pub.t, &priv->pub.m, &priv->s); 897 matrix_mult_transpose(&priv->pub.t, &priv->pub.m, &priv->s);
891 vector_add(&priv->pub.t, &error); 898 vector_add(&priv->pub.t, &error);
892 899
893 /* XXX - error checking. */ 900 if (!CBB_init_fixed(&cbb, out_encoded_public_key,
894 CBB_init_fixed(&cbb, out_encoded_public_key, MLKEM1024_PUBLIC_KEY_BYTES); 901 MLKEM1024_PUBLIC_KEY_BYTES))
895 if (!mlkem_marshal_public_key(&cbb, &priv->pub)) { 902 goto err;
896 abort(); 903
897 } 904 if (!mlkem_marshal_public_key(&cbb, &priv->pub))
898 CBB_cleanup(&cbb); 905 goto err;
899 906
900 hash_h(priv->pub.public_key_hash, out_encoded_public_key, 907 hash_h(priv->pub.public_key_hash, out_encoded_public_key,
901 MLKEM1024_PUBLIC_KEY_BYTES); 908 MLKEM1024_PUBLIC_KEY_BYTES);
902 memcpy(priv->fo_failure_secret, entropy + 32, 32); 909 memcpy(priv->fo_failure_secret, entropy + 32, 32);
910
911 ret = 1;
912
913 err:
914 CBB_cleanup(&cbb);
915
916 return ret;
903} 917}
904 918
905void 919void
906MLKEM1024_public_from_private(struct MLKEM1024_public_key *out_public_key, 920MLKEM1024_public_from_private(const MLKEM_private_key *private_key,
907 const struct MLKEM1024_private_key *private_key) 921 MLKEM_public_key *out_public_key)
908{ 922{
909 struct public_key *const pub = public_key_1024_from_external( 923 struct public_key *const pub = public_key_1024_from_external(
910 out_public_key); 924 out_public_key);
@@ -913,7 +927,6 @@ MLKEM1024_public_from_private(struct MLKEM1024_public_key *out_public_key,
913 927
914 *pub = priv->pub; 928 *pub = priv->pub;
915} 929}
916LCRYPTO_ALIAS(MLKEM1024_public_from_private);
917 930
918/* 931/*
919 * Encrypts a message with given randomness to the ciphertext in |out|. Without 932 * Encrypts a message with given randomness to the ciphertext in |out|. Without
@@ -955,9 +968,9 @@ encrypt_cpa(uint8_t out[MLKEM1024_CIPHERTEXT_BYTES],
955 968
956/* Calls MLKEM1024_encap_external_entropy| with random bytes */ 969/* Calls MLKEM1024_encap_external_entropy| with random bytes */
957void 970void
958MLKEM1024_encap(uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES], 971MLKEM1024_encap(const MLKEM_public_key *public_key,
959 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 972 uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES],
960 const struct MLKEM1024_public_key *public_key) 973 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES])
961{ 974{
962 uint8_t entropy[MLKEM_ENCAP_ENTROPY]; 975 uint8_t entropy[MLKEM_ENCAP_ENTROPY];
963 976
@@ -965,14 +978,13 @@ MLKEM1024_encap(uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES],
965 MLKEM1024_encap_external_entropy(out_ciphertext, out_shared_secret, 978 MLKEM1024_encap_external_entropy(out_ciphertext, out_shared_secret,
966 public_key, entropy); 979 public_key, entropy);
967} 980}
968LCRYPTO_ALIAS(MLKEM1024_encap);
969 981
970/* See section 6.2 of the spec. */ 982/* See section 6.2 of the spec. */
971void 983void
972MLKEM1024_encap_external_entropy( 984MLKEM1024_encap_external_entropy(
973 uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES], 985 uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES],
974 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 986 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
975 const struct MLKEM1024_public_key *public_key, 987 const MLKEM_public_key *public_key,
976 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]) 988 const uint8_t entropy[MLKEM_ENCAP_ENTROPY])
977{ 989{
978 const struct public_key *pub = public_key_1024_from_external(public_key); 990 const struct public_key *pub = public_key_1024_from_external(public_key);
@@ -1008,10 +1020,10 @@ decrypt_cpa(uint8_t out[32], const struct private_key *priv,
1008 1020
1009/* See section 6.3 */ 1021/* See section 6.3 */
1010int 1022int
1011MLKEM1024_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 1023MLKEM1024_decap(const MLKEM_private_key *private_key,
1012 const uint8_t *ciphertext, size_t ciphertext_len, 1024 const uint8_t *ciphertext, size_t ciphertext_len,
1013 const struct MLKEM1024_private_key *private_key) 1025 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES])
1014{ 1026 {
1015 const struct private_key *priv = private_key_1024_from_external( 1027 const struct private_key *priv = private_key_1024_from_external(
1016 private_key); 1028 private_key);
1017 uint8_t expected_ciphertext[MLKEM1024_CIPHERTEXT_BYTES]; 1029 uint8_t expected_ciphertext[MLKEM1024_CIPHERTEXT_BYTES];
@@ -1042,16 +1054,29 @@ MLKEM1024_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
1042 1054
1043 return 1; 1055 return 1;
1044} 1056}
1045LCRYPTO_ALIAS(MLKEM1024_decap);
1046 1057
1047int 1058int
1048MLKEM1024_marshal_public_key(CBB *out, 1059MLKEM1024_marshal_public_key(const MLKEM_public_key *public_key,
1049 const struct MLKEM1024_public_key *public_key) 1060 uint8_t **output, size_t *output_len)
1050{ 1061{
1051 return mlkem_marshal_public_key(out, 1062 int ret = 0;
1052 public_key_1024_from_external(public_key)); 1063 CBB cbb;
1064
1065 if (!CBB_init(&cbb, MLKEM1024_PUBLIC_KEY_BYTES))
1066 goto err;
1067 if (!mlkem_marshal_public_key(&cbb,
1068 public_key_1024_from_external(public_key)))
1069 goto err;
1070 if (!CBB_finish(&cbb, output, output_len))
1071 goto err;
1072
1073 ret = 1;
1074
1075 err:
1076 CBB_cleanup(&cbb);
1077
1078 return ret;
1053} 1079}
1054LCRYPTO_ALIAS(MLKEM1024_marshal_public_key);
1055 1080
1056/* 1081/*
1057 * mlkem_parse_public_key_no_hash parses |in| into |pub| but doesn't calculate 1082 * mlkem_parse_public_key_no_hash parses |in| into |pub| but doesn't calculate
@@ -1062,10 +1087,11 @@ mlkem_parse_public_key_no_hash(struct public_key *pub, CBS *in)
1062{ 1087{
1063 CBS t_bytes; 1088 CBS t_bytes;
1064 1089
1065 if (!CBS_get_bytes(in, &t_bytes, kEncodedVectorSize) || 1090 if (!CBS_get_bytes(in, &t_bytes, kEncodedVectorSize))
1066 !vector_decode(&pub->t, CBS_data(&t_bytes), kLog2Prime)) {
1067 return 0; 1091 return 0;
1068 } 1092 if (!vector_decode(&pub->t, CBS_data(&t_bytes), kLog2Prime))
1093 return 0;
1094
1069 memcpy(pub->rho, CBS_data(in), sizeof(pub->rho)); 1095 memcpy(pub->rho, CBS_data(in), sizeof(pub->rho));
1070 if (!CBS_skip(in, sizeof(pub->rho))) 1096 if (!CBS_skip(in, sizeof(pub->rho)))
1071 return 0; 1097 return 0;
@@ -1074,66 +1100,84 @@ mlkem_parse_public_key_no_hash(struct public_key *pub, CBS *in)
1074} 1100}
1075 1101
1076int 1102int
1077MLKEM1024_parse_public_key(struct MLKEM1024_public_key *public_key, CBS *in) 1103MLKEM1024_parse_public_key(const uint8_t *input, size_t input_len,
1104 MLKEM_public_key *public_key)
1078{ 1105{
1079 struct public_key *pub = public_key_1024_from_external(public_key); 1106 struct public_key *pub = public_key_1024_from_external(public_key);
1080 CBS orig_in = *in; 1107 CBS cbs;
1081 1108
1082 if (!mlkem_parse_public_key_no_hash(pub, in) || 1109 CBS_init(&cbs, input, input_len);
1083 CBS_len(in) != 0) { 1110 if (!mlkem_parse_public_key_no_hash(pub, &cbs))
1084 return 0; 1111 return 0;
1085 } 1112 if (CBS_len(&cbs) != 0)
1086 hash_h(pub->public_key_hash, CBS_data(&orig_in), CBS_len(&orig_in)); 1113 return 0;
1114
1115 hash_h(pub->public_key_hash, input, input_len);
1116
1087 return 1; 1117 return 1;
1088} 1118}
1089LCRYPTO_ALIAS(MLKEM1024_parse_public_key);
1090 1119
1091int 1120int
1092MLKEM1024_marshal_private_key(CBB *out, 1121MLKEM1024_marshal_private_key(const MLKEM_private_key *private_key,
1093 const struct MLKEM1024_private_key *private_key) 1122 uint8_t **out_private_key, size_t *out_private_key_len)
1094{ 1123{
1095 const struct private_key *const priv = private_key_1024_from_external( 1124 const struct private_key *const priv = private_key_1024_from_external(
1096 private_key); 1125 private_key);
1097 uint8_t *s_output; 1126 CBB cbb;
1127 int ret = 0;
1098 1128
1099 if (!CBB_add_space(out, &s_output, kEncodedVectorSize)) { 1129 if (!CBB_init(&cbb, MLKEM1024_PRIVATE_KEY_BYTES))
1100 return 0; 1130 goto err;
1101 } 1131
1102 vector_encode(s_output, &priv->s, kLog2Prime); 1132 if (!vector_encode_cbb(&cbb, &priv->s, kLog2Prime))
1103 if (!mlkem_marshal_public_key(out, &priv->pub) || 1133 goto err;
1104 !CBB_add_bytes(out, priv->pub.public_key_hash, 1134 if (!mlkem_marshal_public_key(&cbb, &priv->pub))
1105 sizeof(priv->pub.public_key_hash)) || 1135 goto err;
1106 !CBB_add_bytes(out, priv->fo_failure_secret, 1136 if (!CBB_add_bytes(&cbb, priv->pub.public_key_hash,
1107 sizeof(priv->fo_failure_secret))) { 1137 sizeof(priv->pub.public_key_hash)))
1108 return 0; 1138 goto err;
1109 } 1139 if (!CBB_add_bytes(&cbb, priv->fo_failure_secret,
1110 return 1; 1140 sizeof(priv->fo_failure_secret)))
1141 goto err;
1142
1143 if (!CBB_finish(&cbb, out_private_key, out_private_key_len))
1144 goto err;
1145
1146 ret = 1;
1147
1148 err:
1149 CBB_cleanup(&cbb);
1150
1151 return ret;
1111} 1152}
1112 1153
1113int 1154int
1114MLKEM1024_parse_private_key(struct MLKEM1024_private_key *out_private_key, 1155MLKEM1024_parse_private_key(const uint8_t *input, size_t input_len,
1115 CBS *in) 1156 MLKEM_private_key *out_private_key)
1116{ 1157{
1117 struct private_key *const priv = private_key_1024_from_external( 1158 struct private_key *const priv = private_key_1024_from_external(
1118 out_private_key); 1159 out_private_key);
1119 CBS s_bytes; 1160 CBS cbs, s_bytes;
1161
1162 CBS_init(&cbs, input, input_len);
1120 1163
1121 if (!CBS_get_bytes(in, &s_bytes, kEncodedVectorSize) || 1164 if (!CBS_get_bytes(&cbs, &s_bytes, kEncodedVectorSize))
1122 !vector_decode(&priv->s, CBS_data(&s_bytes), kLog2Prime) ||
1123 !mlkem_parse_public_key_no_hash(&priv->pub, in)) {
1124 return 0; 1165 return 0;
1125 } 1166 if (!vector_decode(&priv->s, CBS_data(&s_bytes), kLog2Prime))
1126 memcpy(priv->pub.public_key_hash, CBS_data(in), 1167 return 0;
1168 if (!mlkem_parse_public_key_no_hash(&priv->pub, &cbs))
1169 return 0;
1170
1171 memcpy(priv->pub.public_key_hash, CBS_data(&cbs),
1127 sizeof(priv->pub.public_key_hash)); 1172 sizeof(priv->pub.public_key_hash));
1128 if (!CBS_skip(in, sizeof(priv->pub.public_key_hash))) 1173 if (!CBS_skip(&cbs, sizeof(priv->pub.public_key_hash)))
1129 return 0; 1174 return 0;
1130 memcpy(priv->fo_failure_secret, CBS_data(in), 1175 memcpy(priv->fo_failure_secret, CBS_data(&cbs),
1131 sizeof(priv->fo_failure_secret)); 1176 sizeof(priv->fo_failure_secret));
1132 if (!CBS_skip(in, sizeof(priv->fo_failure_secret))) 1177 if (!CBS_skip(&cbs, sizeof(priv->fo_failure_secret)))
1133 return 0; 1178 return 0;
1134 if (CBS_len(in) != 0) 1179 if (CBS_len(&cbs) != 0)
1135 return 0; 1180 return 0;
1136 1181
1137 return 1; 1182 return 1;
1138} 1183}
1139LCRYPTO_ALIAS(MLKEM1024_parse_private_key);
diff --git a/src/lib/libcrypto/mlkem/mlkem768.c b/src/lib/libcrypto/mlkem/mlkem768.c
index bacde0c0b7..1a44b9413f 100644
--- a/src/lib/libcrypto/mlkem/mlkem768.c
+++ b/src/lib/libcrypto/mlkem/mlkem768.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mlkem768.c,v 1.7 2025/01/03 08:19:24 tb Exp $ */ 1/* $OpenBSD: mlkem768.c,v 1.13 2025/08/14 15:48:48 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2024, Google Inc. 3 * Copyright (c) 2024, Google Inc.
4 * Copyright (c) 2024, Bob Beck <beck@obtuse.com> 4 * Copyright (c) 2024, Bob Beck <beck@obtuse.com>
@@ -19,19 +19,16 @@
19#include <assert.h> 19#include <assert.h>
20#include <stdlib.h> 20#include <stdlib.h>
21#include <string.h> 21#include <string.h>
22#include <stdio.h>
22 23
23#include "bytestring.h" 24#include <openssl/mlkem.h>
24#include "mlkem.h"
25 25
26#include "bytestring.h"
26#include "sha3_internal.h" 27#include "sha3_internal.h"
27#include "mlkem_internal.h" 28#include "mlkem_internal.h"
28#include "constant_time.h" 29#include "constant_time.h"
29#include "crypto_internal.h" 30#include "crypto_internal.h"
30 31
31/* Remove later */
32#undef LCRYPTO_ALIAS
33#define LCRYPTO_ALIAS(A)
34
35/* 32/*
36 * See 33 * See
37 * https://csrc.nist.gov/pubs/fips/203/final 34 * https://csrc.nist.gov/pubs/fips/203/final
@@ -80,7 +77,6 @@ kdf(uint8_t out[MLKEM_SHARED_SECRET_BYTES], const uint8_t failure_secret[32],
80} 77}
81 78
82#define DEGREE 256 79#define DEGREE 256
83#define RANK768 3
84 80
85static const size_t kBarrettMultiplier = 5039; 81static const size_t kBarrettMultiplier = 5039;
86static const unsigned kBarrettShift = 24; 82static const unsigned kBarrettShift = 24;
@@ -89,6 +85,7 @@ static const int kLog2Prime = 12;
89static const uint16_t kHalfPrime = (/*kPrime=*/3329 - 1) / 2; 85static const uint16_t kHalfPrime = (/*kPrime=*/3329 - 1) / 2;
90static const int kDU768 = 10; 86static const int kDU768 = 10;
91static const int kDV768 = 4; 87static const int kDV768 = 4;
88
92/* 89/*
93 * kInverseDegree is 128^-1 mod 3329; 128 because kPrime does not have a 512th 90 * kInverseDegree is 128^-1 mod 3329; 128 because kPrime does not have a 512th
94 * root of unity. 91 * root of unity.
@@ -611,6 +608,19 @@ vector_encode(uint8_t *out, const vector *a, int bits)
611 } 608 }
612} 609}
613 610
611/* Encodes an entire vector as above, but adding it to a CBB */
612static int
613vector_encode_cbb(CBB *cbb, const vector *a, int bits)
614{
615 uint8_t *encoded_vector;
616
617 if (!CBB_add_space(cbb, &encoded_vector, kEncodedVectorSize))
618 return 0;
619 vector_encode(encoded_vector, a, bits);
620
621 return 1;
622}
623
614/* 624/*
615 * scalar_decode parses |DEGREE * bits| bits from |in| into |DEGREE| values in 625 * scalar_decode parses |DEGREE * bits| bits from |in| into |DEGREE| values in
616 * |out|. It returns one on success and zero if any parsed value is >= 626 * |out|. It returns one on success and zero if any parsed value is >=
@@ -792,10 +802,14 @@ struct public_key {
792 matrix m; 802 matrix m;
793}; 803};
794 804
805CTASSERT(sizeof(struct MLKEM768_public_key) == sizeof(struct public_key));
806
795static struct public_key * 807static struct public_key *
796public_key_768_from_external(const struct MLKEM768_public_key *external) 808public_key_768_from_external(const MLKEM_public_key *external)
797{ 809{
798 return (struct public_key *)external; 810 if (external->rank != RANK768)
811 return NULL;
812 return (struct public_key *)external->key_768;
799} 813}
800 814
801struct private_key { 815struct private_key {
@@ -804,66 +818,60 @@ struct private_key {
804 uint8_t fo_failure_secret[32]; 818 uint8_t fo_failure_secret[32];
805}; 819};
806 820
821CTASSERT(sizeof(struct MLKEM768_private_key) == sizeof(struct private_key));
822
807static struct private_key * 823static struct private_key *
808private_key_768_from_external(const struct MLKEM768_private_key *external) 824private_key_768_from_external(const MLKEM_private_key *external)
809{ 825{
810 return (struct private_key *)external; 826 if (external->rank != RANK768)
827 return NULL;
828 return (struct private_key *)external->key_768;
811} 829}
812 830
813/* 831/*
814 * Calls |MLKEM768_generate_key_external_entropy| with random bytes from 832 * Calls |MLKEM768_generate_key_external_entropy| with random bytes from
815 * |RAND_bytes|. 833 * |RAND_bytes|.
816 */ 834 */
817void 835int
818MLKEM768_generate_key(uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES], 836MLKEM768_generate_key(uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
819 uint8_t optional_out_seed[MLKEM_SEED_BYTES], 837 uint8_t optional_out_seed[MLKEM_SEED_BYTES],
820 struct MLKEM768_private_key *out_private_key) 838 MLKEM_private_key *out_private_key)
821{ 839{
822 uint8_t entropy_buf[MLKEM_SEED_BYTES]; 840 uint8_t entropy_buf[MLKEM_SEED_BYTES];
823 uint8_t *entropy = optional_out_seed != NULL ? optional_out_seed : 841 uint8_t *entropy = optional_out_seed != NULL ? optional_out_seed :
824 entropy_buf; 842 entropy_buf;
825 843
826 arc4random_buf(entropy, MLKEM_SEED_BYTES); 844 arc4random_buf(entropy, MLKEM_SEED_BYTES);
827 MLKEM768_generate_key_external_entropy(out_encoded_public_key, 845 return MLKEM768_generate_key_external_entropy(out_encoded_public_key,
828 out_private_key, entropy); 846 out_private_key, entropy);
829} 847}
830LCRYPTO_ALIAS(MLKEM768_generate_key);
831 848
832int 849int
833MLKEM768_private_key_from_seed(struct MLKEM768_private_key *out_private_key, 850MLKEM768_private_key_from_seed(const uint8_t *seed, size_t seed_len,
834 const uint8_t *seed, size_t seed_len) 851 MLKEM_private_key *out_private_key)
835{ 852{
853 /* XXX stack */
836 uint8_t public_key_bytes[MLKEM768_PUBLIC_KEY_BYTES]; 854 uint8_t public_key_bytes[MLKEM768_PUBLIC_KEY_BYTES];
837 855
838 if (seed_len != MLKEM_SEED_BYTES) { 856 if (seed_len != MLKEM_SEED_BYTES) {
839 return 0; 857 return 0;
840 } 858 }
841 MLKEM768_generate_key_external_entropy(public_key_bytes, 859 return MLKEM768_generate_key_external_entropy(public_key_bytes,
842 out_private_key, seed); 860 out_private_key, seed);
843
844 return 1;
845} 861}
846LCRYPTO_ALIAS(MLKEM768_private_key_from_seed);
847 862
848static int 863static int
849mlkem_marshal_public_key(CBB *out, const struct public_key *pub) 864mlkem_marshal_public_key(CBB *out, const struct public_key *pub)
850{ 865{
851 uint8_t *vector_output; 866 if (!vector_encode_cbb(out, &pub->t, kLog2Prime))
852
853 if (!CBB_add_space(out, &vector_output, kEncodedVectorSize)) {
854 return 0;
855 }
856 vector_encode(vector_output, &pub->t, kLog2Prime);
857 if (!CBB_add_bytes(out, pub->rho, sizeof(pub->rho))) {
858 return 0; 867 return 0;
859 } 868 return CBB_add_bytes(out, pub->rho, sizeof(pub->rho));
860 return 1;
861} 869}
862 870
863void 871int
864MLKEM768_generate_key_external_entropy( 872MLKEM768_generate_key_external_entropy(
865 uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES], 873 uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
866 struct MLKEM768_private_key *out_private_key, 874 MLKEM_private_key *out_private_key,
867 const uint8_t entropy[MLKEM_SEED_BYTES]) 875 const uint8_t entropy[MLKEM_SEED_BYTES])
868{ 876{
869 struct private_key *priv = private_key_768_from_external( 877 struct private_key *priv = private_key_768_from_external(
@@ -874,7 +882,9 @@ MLKEM768_generate_key_external_entropy(
874 uint8_t hashed[64]; 882 uint8_t hashed[64];
875 vector error; 883 vector error;
876 CBB cbb; 884 CBB cbb;
885 int ret = 0;
877 886
887 memset(&cbb, 0, sizeof(CBB));
878 memcpy(augmented_seed, entropy, 32); 888 memcpy(augmented_seed, entropy, 32);
879 augmented_seed[32] = RANK768; 889 augmented_seed[32] = RANK768;
880 hash_g(hashed, augmented_seed, 33); 890 hash_g(hashed, augmented_seed, 33);
@@ -889,22 +899,28 @@ MLKEM768_generate_key_external_entropy(
889 matrix_mult_transpose(&priv->pub.t, &priv->pub.m, &priv->s); 899 matrix_mult_transpose(&priv->pub.t, &priv->pub.m, &priv->s);
890 vector_add(&priv->pub.t, &error); 900 vector_add(&priv->pub.t, &error);
891 901
892 /* XXX - error checking */ 902 if (!CBB_init_fixed(&cbb, out_encoded_public_key,
893 CBB_init_fixed(&cbb, out_encoded_public_key, MLKEM768_PUBLIC_KEY_BYTES); 903 MLKEM768_PUBLIC_KEY_BYTES))
894 if (!mlkem_marshal_public_key(&cbb, &priv->pub)) { 904 goto err;
895 abort(); 905
896 } 906 if (!mlkem_marshal_public_key(&cbb, &priv->pub))
897 CBB_cleanup(&cbb); 907 goto err;
898 908
899 hash_h(priv->pub.public_key_hash, out_encoded_public_key, 909 hash_h(priv->pub.public_key_hash, out_encoded_public_key,
900 MLKEM768_PUBLIC_KEY_BYTES); 910 MLKEM768_PUBLIC_KEY_BYTES);
901 memcpy(priv->fo_failure_secret, entropy + 32, 32); 911 memcpy(priv->fo_failure_secret, entropy + 32, 32);
912
913 ret = 1;
914
915 err:
916 CBB_cleanup(&cbb);
917
918 return ret;
902} 919}
903 920
904void 921void
905MLKEM768_public_from_private(struct MLKEM768_public_key *out_public_key, 922MLKEM768_public_from_private(const MLKEM_private_key *private_key,
906 const struct MLKEM768_private_key *private_key) 923 MLKEM_public_key *out_public_key) {
907{
908 struct public_key *const pub = public_key_768_from_external( 924 struct public_key *const pub = public_key_768_from_external(
909 out_public_key); 925 out_public_key);
910 const struct private_key *const priv = private_key_768_from_external( 926 const struct private_key *const priv = private_key_768_from_external(
@@ -912,7 +928,6 @@ MLKEM768_public_from_private(struct MLKEM768_public_key *out_public_key,
912 928
913 *pub = priv->pub; 929 *pub = priv->pub;
914} 930}
915LCRYPTO_ALIAS(MLKEM768_public_from_private);
916 931
917/* 932/*
918 * Encrypts a message with given randomness to the ciphertext in |out|. Without 933 * Encrypts a message with given randomness to the ciphertext in |out|. Without
@@ -954,24 +969,23 @@ encrypt_cpa(uint8_t out[MLKEM768_CIPHERTEXT_BYTES],
954 969
955/* Calls MLKEM768_encap_external_entropy| with random bytes */ 970/* Calls MLKEM768_encap_external_entropy| with random bytes */
956void 971void
957MLKEM768_encap(uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES], 972MLKEM768_encap(const MLKEM_public_key *public_key,
958 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 973 uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES],
959 const struct MLKEM768_public_key *public_key) 974 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES])
960{ 975{
961 uint8_t entropy[MLKEM_ENCAP_ENTROPY]; 976 uint8_t entropy[MLKEM_ENCAP_ENTROPY];
962 977
963 arc4random_buf(entropy, MLKEM_ENCAP_ENTROPY); 978 arc4random_buf(entropy, MLKEM_ENCAP_ENTROPY);
964 MLKEM768_encap_external_entropy(out_ciphertext, out_shared_secret, 979 MLKEM768_encap_external_entropy(out_ciphertext,
965 public_key, entropy); 980 out_shared_secret, public_key, entropy);
966} 981}
967LCRYPTO_ALIAS(MLKEM768_encap);
968 982
969/* See section 6.2 of the spec. */ 983/* See section 6.2 of the spec. */
970void 984void
971MLKEM768_encap_external_entropy( 985MLKEM768_encap_external_entropy(
972 uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES], 986 uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES],
973 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 987 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
974 const struct MLKEM768_public_key *public_key, 988 const MLKEM_public_key *public_key,
975 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]) 989 const uint8_t entropy[MLKEM_ENCAP_ENTROPY])
976{ 990{
977 const struct public_key *pub = public_key_768_from_external(public_key); 991 const struct public_key *pub = public_key_768_from_external(public_key);
@@ -1007,9 +1021,8 @@ decrypt_cpa(uint8_t out[32], const struct private_key *priv,
1007 1021
1008/* See section 6.3 */ 1022/* See section 6.3 */
1009int 1023int
1010MLKEM768_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 1024MLKEM768_decap(const MLKEM_private_key *private_key, const uint8_t *ciphertext,
1011 const uint8_t *ciphertext, size_t ciphertext_len, 1025 size_t ciphertext_len, uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES])
1012 const struct MLKEM768_private_key *private_key)
1013{ 1026{
1014 const struct private_key *priv = private_key_768_from_external( 1027 const struct private_key *priv = private_key_768_from_external(
1015 private_key); 1028 private_key);
@@ -1041,16 +1054,29 @@ MLKEM768_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
1041 1054
1042 return 1; 1055 return 1;
1043} 1056}
1044LCRYPTO_ALIAS(MLKEM768_decap);
1045 1057
1046int 1058int
1047MLKEM768_marshal_public_key(CBB *out, 1059MLKEM768_marshal_public_key(const MLKEM_public_key *public_key,
1048 const struct MLKEM768_public_key *public_key) 1060 uint8_t **output, size_t *output_len)
1049{ 1061{
1050 return mlkem_marshal_public_key(out, 1062 int ret = 0;
1051 public_key_768_from_external(public_key)); 1063 CBB cbb;
1064
1065 if (!CBB_init(&cbb, MLKEM768_PUBLIC_KEY_BYTES))
1066 goto err;
1067 if (!mlkem_marshal_public_key(&cbb,
1068 public_key_768_from_external(public_key)))
1069 goto err;
1070 if (!CBB_finish(&cbb, output, output_len))
1071 goto err;
1072
1073 ret = 1;
1074
1075 err:
1076 CBB_cleanup(&cbb);
1077
1078 return ret;
1052} 1079}
1053LCRYPTO_ALIAS(MLKEM768_marshal_public_key);
1054 1080
1055/* 1081/*
1056 * mlkem_parse_public_key_no_hash parses |in| into |pub| but doesn't calculate 1082 * mlkem_parse_public_key_no_hash parses |in| into |pub| but doesn't calculate
@@ -1061,10 +1087,11 @@ mlkem_parse_public_key_no_hash(struct public_key *pub, CBS *in)
1061{ 1087{
1062 CBS t_bytes; 1088 CBS t_bytes;
1063 1089
1064 if (!CBS_get_bytes(in, &t_bytes, kEncodedVectorSize) || 1090 if (!CBS_get_bytes(in, &t_bytes, kEncodedVectorSize))
1065 !vector_decode(&pub->t, CBS_data(&t_bytes), kLog2Prime)) {
1066 return 0; 1091 return 0;
1067 } 1092 if (!vector_decode(&pub->t, CBS_data(&t_bytes), kLog2Prime))
1093 return 0;
1094
1068 memcpy(pub->rho, CBS_data(in), sizeof(pub->rho)); 1095 memcpy(pub->rho, CBS_data(in), sizeof(pub->rho));
1069 if (!CBS_skip(in, sizeof(pub->rho))) 1096 if (!CBS_skip(in, sizeof(pub->rho)))
1070 return 0; 1097 return 0;
@@ -1073,66 +1100,84 @@ mlkem_parse_public_key_no_hash(struct public_key *pub, CBS *in)
1073} 1100}
1074 1101
1075int 1102int
1076MLKEM768_parse_public_key(struct MLKEM768_public_key *public_key, CBS *in) 1103MLKEM768_parse_public_key(const uint8_t *input, size_t input_len,
1104 MLKEM_public_key *public_key)
1077{ 1105{
1078 struct public_key *pub = public_key_768_from_external(public_key); 1106 struct public_key *pub = public_key_768_from_external(public_key);
1079 CBS orig_in = *in; 1107 CBS cbs;
1080 1108
1081 if (!mlkem_parse_public_key_no_hash(pub, in) || 1109 CBS_init(&cbs, input, input_len);
1082 CBS_len(in) != 0) { 1110 if (!mlkem_parse_public_key_no_hash(pub, &cbs))
1083 return 0; 1111 return 0;
1084 } 1112 if (CBS_len(&cbs) != 0)
1085 hash_h(pub->public_key_hash, CBS_data(&orig_in), CBS_len(&orig_in)); 1113 return 0;
1114
1115 hash_h(pub->public_key_hash, input, input_len);
1116
1086 return 1; 1117 return 1;
1087} 1118}
1088LCRYPTO_ALIAS(MLKEM768_parse_public_key);
1089 1119
1090int 1120int
1091MLKEM768_marshal_private_key(CBB *out, 1121MLKEM768_marshal_private_key(const MLKEM_private_key *private_key,
1092 const struct MLKEM768_private_key *private_key) 1122 uint8_t **out_private_key, size_t *out_private_key_len)
1093{ 1123{
1094 const struct private_key *const priv = private_key_768_from_external( 1124 const struct private_key *const priv = private_key_768_from_external(
1095 private_key); 1125 private_key);
1096 uint8_t *s_output; 1126 CBB cbb;
1127 int ret = 0;
1097 1128
1098 if (!CBB_add_space(out, &s_output, kEncodedVectorSize)) { 1129 if (!CBB_init(&cbb, MLKEM768_PRIVATE_KEY_BYTES))
1099 return 0; 1130 goto err;
1100 } 1131
1101 vector_encode(s_output, &priv->s, kLog2Prime); 1132 if (!vector_encode_cbb(&cbb, &priv->s, kLog2Prime))
1102 if (!mlkem_marshal_public_key(out, &priv->pub) || 1133 goto err;
1103 !CBB_add_bytes(out, priv->pub.public_key_hash, 1134 if (!mlkem_marshal_public_key(&cbb, &priv->pub))
1104 sizeof(priv->pub.public_key_hash)) || 1135 goto err;
1105 !CBB_add_bytes(out, priv->fo_failure_secret, 1136 if (!CBB_add_bytes(&cbb, priv->pub.public_key_hash,
1106 sizeof(priv->fo_failure_secret))) { 1137 sizeof(priv->pub.public_key_hash)))
1107 return 0; 1138 goto err;
1108 } 1139 if (!CBB_add_bytes(&cbb, priv->fo_failure_secret,
1109 return 1; 1140 sizeof(priv->fo_failure_secret)))
1141 goto err;
1142
1143 if (!CBB_finish(&cbb, out_private_key, out_private_key_len))
1144 goto err;
1145
1146 ret = 1;
1147
1148 err:
1149 CBB_cleanup(&cbb);
1150
1151 return ret;
1110} 1152}
1111 1153
1112int 1154int
1113MLKEM768_parse_private_key(struct MLKEM768_private_key *out_private_key, 1155MLKEM768_parse_private_key(const uint8_t *input, size_t input_len,
1114 CBS *in) 1156 MLKEM_private_key *out_private_key)
1115{ 1157{
1116 struct private_key *const priv = private_key_768_from_external( 1158 struct private_key *const priv = private_key_768_from_external(
1117 out_private_key); 1159 out_private_key);
1118 CBS s_bytes; 1160 CBS cbs, s_bytes;
1161
1162 CBS_init(&cbs, input, input_len);
1119 1163
1120 if (!CBS_get_bytes(in, &s_bytes, kEncodedVectorSize) || 1164 if (!CBS_get_bytes(&cbs, &s_bytes, kEncodedVectorSize))
1121 !vector_decode(&priv->s, CBS_data(&s_bytes), kLog2Prime) ||
1122 !mlkem_parse_public_key_no_hash(&priv->pub, in)) {
1123 return 0; 1165 return 0;
1124 } 1166 if (!vector_decode(&priv->s, CBS_data(&s_bytes), kLog2Prime))
1125 memcpy(priv->pub.public_key_hash, CBS_data(in), 1167 return 0;
1168 if (!mlkem_parse_public_key_no_hash(&priv->pub, &cbs))
1169 return 0;
1170
1171 memcpy(priv->pub.public_key_hash, CBS_data(&cbs),
1126 sizeof(priv->pub.public_key_hash)); 1172 sizeof(priv->pub.public_key_hash));
1127 if (!CBS_skip(in, sizeof(priv->pub.public_key_hash))) 1173 if (!CBS_skip(&cbs, sizeof(priv->pub.public_key_hash)))
1128 return 0; 1174 return 0;
1129 memcpy(priv->fo_failure_secret, CBS_data(in), 1175 memcpy(priv->fo_failure_secret, CBS_data(&cbs),
1130 sizeof(priv->fo_failure_secret)); 1176 sizeof(priv->fo_failure_secret));
1131 if (!CBS_skip(in, sizeof(priv->fo_failure_secret))) 1177 if (!CBS_skip(&cbs, sizeof(priv->fo_failure_secret)))
1132 return 0; 1178 return 0;
1133 if (CBS_len(in) != 0) 1179 if (CBS_len(&cbs) != 0)
1134 return 0; 1180 return 0;
1135 1181
1136 return 1; 1182 return 1;
1137} 1183}
1138LCRYPTO_ALIAS(MLKEM768_parse_private_key);
diff --git a/src/lib/libcrypto/mlkem/mlkem_internal.h b/src/lib/libcrypto/mlkem/mlkem_internal.h
index d3f325932f..776f8aac17 100644
--- a/src/lib/libcrypto/mlkem/mlkem_internal.h
+++ b/src/lib/libcrypto/mlkem/mlkem_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: mlkem_internal.h,v 1.4 2024/12/19 23:52:26 tb Exp $ */ 1/* $OpenBSD: mlkem_internal.h,v 1.8 2025/08/14 15:48:48 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2023, Google Inc. 3 * Copyright (c) 2023, Google Inc.
4 * 4 *
@@ -26,6 +26,253 @@ extern "C" {
26#endif 26#endif
27 27
28__BEGIN_HIDDEN_DECLS 28__BEGIN_HIDDEN_DECLS
29/*
30 * MLKEM_SEED_LENGTH is the number of bytes in an ML-KEM seed. An ML-KEM
31 * seed is normally used to represent a private key.
32 */
33#define MLKEM_SEED_LENGTH 64
34
35/*
36 * MLKEM_SHARED_SECRET_LENGTH is the number of bytes in an ML-KEM shared
37 * secret.
38 */
39#define MLKEM_SHARED_SECRET_LENGTH 32
40
41/*
42 * |MLKEM_encap_external_entropy| behaves exactly like the public |MLKEM_encap|
43 * with the entropy provided by the caller. It is directly called internally
44 * and by tests.
45 */
46int
47MLKEM_encap_external_entropy(const MLKEM_public_key *public_key,
48 const uint8_t *entropy, uint8_t **out_ciphertext,
49 size_t *out_ciphertext_len, uint8_t **out_shared_secret,
50 size_t *out_shared_secret_len);
51
52/*
53 * |MLKEM_generate_key_external_entropy| behaves exactly like the public
54 * |MLKEM_generate_key| with the entropy provided by the caller.
55 * It is directly called internally and by tests.
56 */
57int
58MLKEM_generate_key_external_entropy(MLKEM_private_key *private_key,
59 uint8_t **out_encoded_public_key, size_t *out_encoded_public_key_len,
60 const uint8_t *entropy);
61/*
62 * Marshals a private key to encoded format, used for NIST tests.
63 */
64int MLKEM_marshal_private_key(const MLKEM_private_key *private_key,
65 uint8_t **out, size_t *out_len);
66
67/*
68 * ML-KEM-768
69 *
70 * This implements the Module-Lattice-Based Key-Encapsulation Mechanism from
71 * https://csrc.nist.gov/pubs/fips/204/final
72 */
73
74/*
75 * MLKEM768_PUBLIC_KEY_BYTES is the number of bytes in an encoded ML-KEM768 public
76 * key.
77 */
78#define MLKEM768_PUBLIC_KEY_BYTES 1184
79
80/* MLKEM_SEED_BYTES is the number of bytes in an ML-KEM seed. */
81#define MLKEM_SEED_BYTES 64
82
83/*
84 * MLKEM_SHARED_SECRET_BYTES is the number of bytes in the ML-KEM768 shared
85 * secret. Although the round-3 specification has a variable-length output, the
86 * final ML-KEM construction is expected to use a fixed 32-byte output. To
87 * simplify the future transition, we apply the same restriction.
88 */
89#define MLKEM_SHARED_SECRET_BYTES 32
90
91/*
92 * MLKEM_generate_key generates a random public/private key pair, writes the
93 * encoded public key to |out_encoded_public_key| and sets |out_private_key| to
94 * the private key. If |optional_out_seed| is not NULL then the seed used to
95 * generate the private key is written to it.
96 */
97int MLKEM768_generate_key(
98 uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
99 uint8_t optional_out_seed[MLKEM_SEED_BYTES],
100 MLKEM_private_key *out_private_key);
101
102/*
103 * MLKEM768_private_key_from_seed derives a private key from a seed that was
104 * generated by |MLKEM768_generate_key|. It fails and returns 0 if |seed_len| is
105 * incorrect, otherwise it writes |*out_private_key| and returns 1.
106 */
107int MLKEM768_private_key_from_seed(const uint8_t *seed, size_t seed_len,
108 MLKEM_private_key *out_private_key);
109
110/*
111 * MLKEM_public_from_private sets |*out_public_key| to the public key that
112 * corresponds to |private_key|. (This is faster than parsing the output of
113 * |MLKEM_generate_key| if, for some reason, you need to encapsulate to a key
114 * that was just generated.)
115 */
116void MLKEM768_public_from_private(const MLKEM_private_key *private_key,
117 MLKEM_public_key *out_public_key);
118
119/* MLKEM768_CIPHERTEXT_BYTES is number of bytes in the ML-KEM768 ciphertext. */
120#define MLKEM768_CIPHERTEXT_BYTES 1088
121
122/*
123 * MLKEM768_encap encrypts a random shared secret for |public_key|, writes the
124 * ciphertext to |out_ciphertext|, and writes the random shared secret to
125 * |out_shared_secret|.
126 */
127void MLKEM768_encap(const MLKEM_public_key *public_key,
128 uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES],
129 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES]);
130
131/*
132 * MLKEM768_decap decrypts a shared secret from |ciphertext| using |private_key|
133 * and writes it to |out_shared_secret|. If |ciphertext_len| is incorrect it
134 * returns 0, otherwise it rreturns 1. If |ciphertext| is invalid,
135 * |out_shared_secret| is filled with a key that will always be the same for the
136 * same |ciphertext| and |private_key|, but which appears to be random unless
137 * one has access to |private_key|. These alternatives occur in constant time.
138 * Any subsequent symmetric encryption using |out_shared_secret| must use an
139 * authenticated encryption scheme in order to discover the decapsulation
140 * failure.
141 */
142int MLKEM768_decap(const MLKEM_private_key *private_key,
143 const uint8_t *ciphertext, size_t ciphertext_len,
144 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES]);
145
146/* Serialisation of keys. */
147
148/*
149 * MLKEM768_marshal_public_key serializes |public_key| to |out| in the standard
150 * format for ML-KEM public keys. It returns one on success or zero on allocation
151 * error.
152 */
153int MLKEM768_marshal_public_key(const MLKEM_public_key *public_key,
154 uint8_t **output, size_t *output_len);
155
156/*
157 * MLKEM768_parse_public_key parses a public key, in the format generated by
158 * |MLKEM_marshal_public_key|, from |in| and writes the result to
159 * |out_public_key|. It returns one on success or zero on parse error or if
160 * there are trailing bytes in |in|.
161 */
162int MLKEM768_parse_public_key(const uint8_t *input, size_t input_len,
163 MLKEM_public_key *out_public_key);
164
165/*
166 * MLKEM_parse_private_key parses a private key, in the format generated by
167 * |MLKEM_marshal_private_key|, from |in| and writes the result to
168 * |out_private_key|. It returns one on success or zero on parse error or if
169 * there are trailing bytes in |in|. This formate is verbose and should be avoided.
170 * Private keys should be stored as seeds and parsed using |MLKEM768_private_key_from_seed|.
171 */
172int MLKEM768_parse_private_key(const uint8_t *input, size_t input_len,
173 MLKEM_private_key *out_private_key);
174
175/*
176 * ML-KEM-1024
177 *
178 * ML-KEM-1024 also exists. You should prefer ML-KEM-768 where possible.
179 */
180
181/*
182 * MLKEM1024_PUBLIC_KEY_BYTES is the number of bytes in an encoded ML-KEM-1024
183 * public key.
184 */
185#define MLKEM1024_PUBLIC_KEY_BYTES 1568
186
187/*
188 * MLKEM1024_generate_key generates a random public/private key pair, writes the
189 * encoded public key to |out_encoded_public_key| and sets |out_private_key| to
190 * the private key. If |optional_out_seed| is not NULL then the seed used to
191 * generate the private key is written to it.
192 */
193int MLKEM1024_generate_key(
194 uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES],
195 uint8_t optional_out_seed[MLKEM_SEED_BYTES],
196 MLKEM_private_key *out_private_key);
197
198/*
199 * MLKEM1024_private_key_from_seed derives a private key from a seed that was
200 * generated by |MLKEM1024_generate_key|. It fails and returns 0 if |seed_len|
201 * is incorrect, otherwise it writes |*out_private_key| and returns 1.
202 */
203int MLKEM1024_private_key_from_seed(
204 MLKEM_private_key *out_private_key, const uint8_t *seed,
205 size_t seed_len);
206
207/*
208 * MLKEM1024_public_from_private sets |*out_public_key| to the public key that
209 * corresponds to |private_key|. (This is faster than parsing the output of
210 * |MLKEM1024_generate_key| if, for some reason, you need to encapsulate to a
211 * key that was just generated.)
212 */
213void MLKEM1024_public_from_private(const MLKEM_private_key *private_key,
214 MLKEM_public_key *out_public_key);
215
216/* MLKEM1024_CIPHERTEXT_BYTES is number of bytes in the ML-KEM-1024 ciphertext. */
217#define MLKEM1024_CIPHERTEXT_BYTES 1568
218
219/*
220 * MLKEM1024_encap encrypts a random shared secret for |public_key|, writes the
221 * ciphertext to |out_ciphertext|, and writes the random shared secret to
222 * |out_shared_secret|.
223 */
224void MLKEM1024_encap(const MLKEM_public_key *public_key,
225 uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES],
226 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES]);
227
228
229/*
230 * MLKEM1024_decap decrypts a shared secret from |ciphertext| using
231 * |private_key| and writes it to |out_shared_secret|. If |ciphertext_len| is
232 * incorrect it returns 0, otherwise it returns 1. If |ciphertext| is invalid
233 * (but of the correct length), |out_shared_secret| is filled with a key that
234 * will always be the same for the same |ciphertext| and |private_key|, but
235 * which appears to be random unless one has access to |private_key|. These
236 * alternatives occur in constant time. Any subsequent symmetric encryption
237 * using |out_shared_secret| must use an authenticated encryption scheme in
238 * order to discover the decapsulation failure.
239 */
240int MLKEM1024_decap(const MLKEM_private_key *private_key,
241 const uint8_t *ciphertext, size_t ciphertext_len,
242 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES]);
243
244/*
245 * Serialisation of ML-KEM-1024 keys.
246 * MLKEM1024_marshal_public_key serializes |public_key| to |out| in the standard
247 * format for ML-KEM-1024 public keys. It returns one on success or zero on
248 * allocation error.
249 */
250int MLKEM1024_marshal_public_key(const MLKEM_public_key *public_key,
251 uint8_t **output, size_t *output_len);
252
253
254/*
255 * MLKEM1024_parse_public_key parses a public key, in the format generated by
256 * |MLKEM1024_marshal_public_key|, from |in| and writes the result to
257 * |out_public_key|. It returns one on success or zero on parse error or if
258 * there are trailing bytes in |in|.
259 */
260int MLKEM1024_parse_public_key(const uint8_t *input, size_t input_len,
261 MLKEM_public_key *out_public_key);
262
263
264/*
265 * MLKEM1024_parse_private_key parses a private key, in NIST's format for
266 * private keys, from |in| and writes the result to |out_private_key|. It
267 * returns one on success or zero on parse error or if there are trailing bytes
268 * in |in|. This format is verbose and should be avoided. Private keys should be
269 * stored as seeds and parsed using |MLKEM1024_private_key_from_seed|.
270 */
271int MLKEM1024_parse_private_key(const uint8_t *input, size_t input_len,
272 MLKEM_private_key *out_private_key);
273
274
275/* XXXX Truly internal stuff below, also in need of de-duping */
29 276
30/* 277/*
31 * MLKEM_ENCAP_ENTROPY is the number of bytes of uniformly random entropy 278 * MLKEM_ENCAP_ENTROPY is the number of bytes of uniformly random entropy
@@ -35,15 +282,58 @@ __BEGIN_HIDDEN_DECLS
35#define MLKEM_ENCAP_ENTROPY 32 282#define MLKEM_ENCAP_ENTROPY 32
36 283
37/* 284/*
285 * MLKEM768_public_key contains a ML-KEM-768 public key. The contents of this
286 * object should never leave the address space since the format is unstable.
287 */
288struct MLKEM768_public_key {
289 union {
290 uint8_t bytes[512 * (3 + 9) + 32 + 32];
291 uint16_t alignment;
292 } opaque;
293};
294
295/*
296 * MLKEM768_private_key contains a ML-KEM-768 private key. The contents of this
297 * object should never leave the address space since the format is unstable.
298 */
299struct MLKEM768_private_key {
300 union {
301 uint8_t bytes[512 * (3 + 3 + 9) + 32 + 32 + 32];
302 uint16_t alignment;
303 } opaque;
304};
305
306/* Public opaque ML-KEM key structures. */
307
308#define MLKEM_PUBLIC_KEY_UNINITIALIZED 1
309#define MLKEM_PUBLIC_KEY_INITIALIZED 2
310#define MLKEM_PRIVATE_KEY_UNINITIALIZED 3
311#define MLKEM_PRIVATE_KEY_INITIALIZED 4
312
313struct MLKEM_public_key_st {
314 uint16_t rank;
315 int state;
316 struct MLKEM768_public_key *key_768;
317 struct MLKEM1024_public_key *key_1024;
318};
319
320struct MLKEM_private_key_st {
321 uint16_t rank;
322 int state;
323 struct MLKEM768_private_key *key_768;
324 struct MLKEM1024_private_key *key_1024;
325};
326
327/*
38 * MLKEM768_generate_key_external_entropy is a deterministic function to create a 328 * MLKEM768_generate_key_external_entropy is a deterministic function to create a
39 * pair of ML-KEM 768 keys, using the supplied entropy. The entropy needs to be 329 * pair of ML-KEM 768 keys, using the supplied entropy. The entropy needs to be
40 * uniformly random generated. This function is should only be used for tests, 330 * uniformly random generated. This function is should only be used for tests,
41 * regular callers should use the non-deterministic |MLKEM_generate_key| 331 * regular callers should use the non-deterministic |MLKEM_generate_key|
42 * directly. 332 * directly.
43 */ 333 */
44void MLKEM768_generate_key_external_entropy( 334int MLKEM768_generate_key_external_entropy(
45 uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES], 335 uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES],
46 struct MLKEM768_private_key *out_private_key, 336 MLKEM_private_key *out_private_key,
47 const uint8_t entropy[MLKEM_SEED_BYTES]); 337 const uint8_t entropy[MLKEM_SEED_BYTES]);
48 338
49/* 339/*
@@ -57,11 +347,11 @@ void MLKEM768_generate_key_external_entropy(
57 * format for ML-KEM private keys. It returns one on success or zero on 347 * format for ML-KEM private keys. It returns one on success or zero on
58 * allocation error. 348 * allocation error.
59 */ 349 */
60int MLKEM768_marshal_private_key(CBB *out, 350int MLKEM768_marshal_private_key(const MLKEM_private_key *private_key,
61 const struct MLKEM768_private_key *private_key); 351 uint8_t **out_private_key, size_t *out_private_key_len);
62 352
63/* 353/*
64 * MLKEM_encap_external_entropy behaves like |MLKEM_encap|, but uses 354 * MLKEM768_encap_external_entropy behaves like |MLKEM768_encap|, but uses
65 * |MLKEM_ENCAP_ENTROPY| bytes of |entropy| for randomization. The decapsulating 355 * |MLKEM_ENCAP_ENTROPY| bytes of |entropy| for randomization. The decapsulating
66 * side will be able to recover |entropy| in full. This function should only be 356 * side will be able to recover |entropy| in full. This function should only be
67 * used for tests, regular callers should use the non-deterministic 357 * used for tests, regular callers should use the non-deterministic
@@ -70,9 +360,34 @@ int MLKEM768_marshal_private_key(CBB *out,
70void MLKEM768_encap_external_entropy( 360void MLKEM768_encap_external_entropy(
71 uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES], 361 uint8_t out_ciphertext[MLKEM768_CIPHERTEXT_BYTES],
72 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 362 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
73 const struct MLKEM768_public_key *public_key, 363 const MLKEM_public_key *public_key,
74 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]); 364 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]);
75 365
366
367/*
368 * MLKEM1024_public_key contains an ML-KEM-1024 public key. The contents of this
369 * object should never leave the address space since the format is unstable.
370 */
371struct MLKEM1024_public_key {
372 union {
373 uint8_t bytes[512 * (4 + 16) + 32 + 32];
374 uint16_t alignment;
375 } opaque;
376};
377
378/*
379 * MLKEM1024_private_key contains a ML-KEM-1024 private key. The contents of
380 * this object should never leave the address space since the format is
381 * unstable.
382 */
383struct MLKEM1024_private_key {
384 union {
385 uint8_t bytes[512 * (4 + 4 + 16) + 32 + 32 + 32];
386 uint16_t alignment;
387 } opaque;
388};
389
390
76/* 391/*
77 * MLKEM1024_generate_key_external_entropy is a deterministic function to create a 392 * MLKEM1024_generate_key_external_entropy is a deterministic function to create a
78 * pair of ML-KEM 1024 keys, using the supplied entropy. The entropy needs to be 393 * pair of ML-KEM 1024 keys, using the supplied entropy. The entropy needs to be
@@ -80,9 +395,9 @@ void MLKEM768_encap_external_entropy(
80 * regular callers should use the non-deterministic |MLKEM_generate_key| 395 * regular callers should use the non-deterministic |MLKEM_generate_key|
81 * directly. 396 * directly.
82 */ 397 */
83void MLKEM1024_generate_key_external_entropy( 398int MLKEM1024_generate_key_external_entropy(
84 uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES], 399 uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES],
85 struct MLKEM1024_private_key *out_private_key, 400 MLKEM_private_key *out_private_key,
86 const uint8_t entropy[MLKEM_SEED_BYTES]); 401 const uint8_t entropy[MLKEM_SEED_BYTES]);
87 402
88/* 403/*
@@ -96,8 +411,9 @@ void MLKEM1024_generate_key_external_entropy(
96 * standard format for ML-KEM private keys. It returns one on success or zero on 411 * standard format for ML-KEM private keys. It returns one on success or zero on
97 * allocation error. 412 * allocation error.
98 */ 413 */
99int MLKEM1024_marshal_private_key(CBB *out, 414int MLKEM1024_marshal_private_key(
100 const struct MLKEM1024_private_key *private_key); 415 const MLKEM_private_key *private_key, uint8_t **out_private_key,
416 size_t *out_private_key_len);
101 417
102/* 418/*
103 * MLKEM_encap_external_entropy behaves like |MLKEM_encap|, but uses 419 * MLKEM_encap_external_entropy behaves like |MLKEM_encap|, but uses
@@ -109,7 +425,7 @@ int MLKEM1024_marshal_private_key(CBB *out,
109void MLKEM1024_encap_external_entropy( 425void MLKEM1024_encap_external_entropy(
110 uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES], 426 uint8_t out_ciphertext[MLKEM1024_CIPHERTEXT_BYTES],
111 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], 427 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
112 const struct MLKEM1024_public_key *public_key, 428 const MLKEM_public_key *public_key,
113 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]); 429 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]);
114 430
115__END_HIDDEN_DECLS 431__END_HIDDEN_DECLS
diff --git a/src/lib/libcrypto/mlkem/mlkem_key.c b/src/lib/libcrypto/mlkem/mlkem_key.c
new file mode 100644
index 0000000000..051d8f2b88
--- /dev/null
+++ b/src/lib/libcrypto/mlkem/mlkem_key.c
@@ -0,0 +1,200 @@
1/* $OpenBSD: mlkem_key.c,v 1.1 2025/08/14 15:48:48 beck Exp $ */
2/*
3 * Copyright (c) 2025 Bob Beck <beck@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <stdlib.h>
19#include <string.h>
20
21#include <openssl/mlkem.h>
22
23#include "mlkem_internal.h"
24
25MLKEM_private_key *
26MLKEM_private_key_new(int rank)
27{
28 struct MLKEM1024_private_key *key_1024 = NULL;
29 struct MLKEM768_private_key *key_768 = NULL;
30 MLKEM_private_key *key = NULL;
31 MLKEM_private_key *ret = NULL;
32
33 if ((key = calloc(1, sizeof(MLKEM_private_key))) == NULL)
34 goto err;
35
36 switch (rank) {
37 case RANK768:
38 if ((key_768 = calloc(1, sizeof(*key_768))) ==
39 NULL)
40 goto err;
41 key->key_768 = key_768;
42 break;
43 case RANK1024:
44 if ((key_1024 = calloc(1, sizeof(*key_1024))) ==
45 NULL)
46 goto err;
47 key->key_1024 = key_1024;
48 break;
49 default:
50 goto err;
51 }
52 key->rank = rank;
53 key->state = MLKEM_PRIVATE_KEY_UNINITIALIZED;
54
55 ret = key;
56 key= NULL;
57
58 err:
59 MLKEM_private_key_free(key);
60
61 return ret;
62}
63LCRYPTO_ALIAS(MLKEM_private_key_new);
64
65void
66MLKEM_private_key_free(MLKEM_private_key *key)
67{
68 if (key == NULL)
69 return;
70
71 freezero(key->key_768, sizeof(*key->key_768));
72 freezero(key->key_1024, sizeof(*key->key_1024));
73 freezero(key, sizeof(*key));
74}
75LCRYPTO_ALIAS(MLKEM_private_key_free);
76
77size_t
78MLKEM_private_key_encoded_length(const MLKEM_private_key *key)
79{
80 if (key == NULL)
81 return 0;
82
83 switch (key->rank) {
84 case RANK768:
85 return MLKEM768_PRIVATE_KEY_BYTES;
86 case RANK1024:
87 return MLKEM1024_PRIVATE_KEY_BYTES;
88 default:
89 return 0;
90 }
91 return 0;
92}
93LCRYPTO_ALIAS(MLKEM_private_key_encoded_length);
94
95size_t
96MLKEM_private_key_ciphertext_length(const MLKEM_private_key *key)
97{
98 if (key == NULL)
99 return 0;
100
101 switch (key->rank) {
102 case RANK768:
103 return MLKEM768_CIPHERTEXT_BYTES;
104 case RANK1024:
105 return MLKEM1024_CIPHERTEXT_BYTES;
106 default:
107 return 0;
108 }
109 return 0;
110}
111LCRYPTO_ALIAS(MLKEM_private_key_ciphertext_length);
112
113MLKEM_public_key *
114MLKEM_public_key_new(int rank)
115{
116 struct MLKEM1024_public_key *key_1024 = NULL;
117 struct MLKEM768_public_key *key_768 = NULL;
118 MLKEM_public_key *key = NULL;
119 MLKEM_public_key *ret = NULL;
120
121 if ((key = calloc(1, sizeof(MLKEM_public_key))) == NULL)
122 goto err;
123
124 switch (rank) {
125 case RANK768:
126 if ((key_768 = calloc(1, sizeof(*key_768))) ==
127 NULL)
128 goto err;
129 key->key_768 = key_768;
130 break;
131 case RANK1024:
132 if ((key_1024 = calloc(1, sizeof(*key_1024))) ==
133 NULL)
134 goto err;
135 key->key_1024 = key_1024;
136 break;
137 default:
138 goto err;
139 }
140
141 key->rank = rank;
142 key->state = MLKEM_PUBLIC_KEY_UNINITIALIZED;
143
144 ret = key;
145 key = NULL;
146
147 err:
148 MLKEM_public_key_free(key);
149
150 return ret;
151}
152LCRYPTO_ALIAS(MLKEM_public_key_new);
153
154void
155MLKEM_public_key_free(MLKEM_public_key *key)
156{
157 if (key == NULL)
158 return;
159
160 freezero(key->key_768, sizeof(*key->key_768));
161 freezero(key->key_1024, sizeof(*key->key_1024));
162 freezero(key, sizeof(*key));
163}
164LCRYPTO_ALIAS(MLKEM_public_key_free);
165
166size_t
167MLKEM_public_key_encoded_length(const MLKEM_public_key *key)
168{
169 if (key == NULL)
170 return 0;
171
172 switch (key->rank) {
173 case RANK768:
174 return MLKEM768_PUBLIC_KEY_BYTES;
175 case RANK1024:
176 return MLKEM1024_PUBLIC_KEY_BYTES;
177 default:
178 return 0;
179 }
180 return 0;
181}
182LCRYPTO_ALIAS(MLKEM_public_key_encoded_length);
183
184size_t
185MLKEM_public_key_ciphertext_length(const MLKEM_public_key *key)
186{
187 if (key == NULL)
188 return 0;
189
190 switch (key->rank) {
191 case RANK768:
192 return MLKEM768_CIPHERTEXT_BYTES;
193 case RANK1024:
194 return MLKEM1024_CIPHERTEXT_BYTES;
195 default:
196 return 0;
197 }
198 return 0;
199}
200LCRYPTO_ALIAS(MLKEM_public_key_ciphertext_length);
diff --git a/src/lib/libcrypto/modes/asm/ghash-x86.pl b/src/lib/libcrypto/modes/asm/ghash-x86.pl
index 47833582b6..395c680cc5 100644
--- a/src/lib/libcrypto/modes/asm/ghash-x86.pl
+++ b/src/lib/libcrypto/modes/asm/ghash-x86.pl
@@ -119,8 +119,7 @@ require "x86asm.pl";
119 119
120&asm_init($ARGV[0],"ghash-x86.pl",$x86only = $ARGV[$#ARGV] eq "386"); 120&asm_init($ARGV[0],"ghash-x86.pl",$x86only = $ARGV[$#ARGV] eq "386");
121 121
122$sse2=0; 122$sse2=1;
123for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
124 123
125($Zhh,$Zhl,$Zlh,$Zll) = ("ebp","edx","ecx","ebx"); 124($Zhh,$Zhl,$Zlh,$Zll) = ("ebp","edx","ecx","ebx");
126$inp = "edi"; 125$inp = "edi";
diff --git a/src/lib/libcrypto/modes/ccm128.c b/src/lib/libcrypto/modes/ccm128.c
index 0f592dd9e5..e27681ee62 100644
--- a/src/lib/libcrypto/modes/ccm128.c
+++ b/src/lib/libcrypto/modes/ccm128.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ccm128.c,v 1.10 2025/04/21 16:01:18 jsing Exp $ */ 1/* $OpenBSD: ccm128.c,v 1.12 2025/05/18 09:21:29 bcook Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -61,7 +61,7 @@ CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
61 unsigned int M, unsigned int L, void *key, block128_f block) 61 unsigned int M, unsigned int L, void *key, block128_f block)
62{ 62{
63 memset(ctx->nonce.c, 0, sizeof(ctx->nonce.c)); 63 memset(ctx->nonce.c, 0, sizeof(ctx->nonce.c));
64 ctx->nonce.c[0] = ((u8)(L - 1) & 7) | (u8)(((M - 2)/2) & 7) << 3; 64 ctx->nonce.c[0] = ((uint8_t)(L - 1) & 7) | (uint8_t)(((M - 2)/2) & 7) << 3;
65 ctx->blocks = 0; 65 ctx->blocks = 0;
66 ctx->block = block; 66 ctx->block = block;
67 ctx->key = key; 67 ctx->key = key;
@@ -81,17 +81,17 @@ CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx,
81 return -1; /* nonce is too short */ 81 return -1; /* nonce is too short */
82 82
83 if (sizeof(mlen) == 8 && L >= 3) { 83 if (sizeof(mlen) == 8 && L >= 3) {
84 ctx->nonce.c[8] = (u8)(mlen >> (56 % (sizeof(mlen)*8))); 84 ctx->nonce.c[8] = (uint8_t)(mlen >> (56 % (sizeof(mlen)*8)));
85 ctx->nonce.c[9] = (u8)(mlen >> (48 % (sizeof(mlen)*8))); 85 ctx->nonce.c[9] = (uint8_t)(mlen >> (48 % (sizeof(mlen)*8)));
86 ctx->nonce.c[10] = (u8)(mlen >> (40 % (sizeof(mlen)*8))); 86 ctx->nonce.c[10] = (uint8_t)(mlen >> (40 % (sizeof(mlen)*8)));
87 ctx->nonce.c[11] = (u8)(mlen >> (32 % (sizeof(mlen)*8))); 87 ctx->nonce.c[11] = (uint8_t)(mlen >> (32 % (sizeof(mlen)*8)));
88 } else 88 } else
89 ctx->nonce.u[1] = 0; 89 ctx->nonce.u[1] = 0;
90 90
91 ctx->nonce.c[12] = (u8)(mlen >> 24); 91 ctx->nonce.c[12] = (uint8_t)(mlen >> 24);
92 ctx->nonce.c[13] = (u8)(mlen >> 16); 92 ctx->nonce.c[13] = (uint8_t)(mlen >> 16);
93 ctx->nonce.c[14] = (u8)(mlen >> 8); 93 ctx->nonce.c[14] = (uint8_t)(mlen >> 8);
94 ctx->nonce.c[15] = (u8)mlen; 94 ctx->nonce.c[15] = (uint8_t)mlen;
95 95
96 ctx->nonce.c[0] &= ~0x40; /* clear Adata flag */ 96 ctx->nonce.c[0] &= ~0x40; /* clear Adata flag */
97 memcpy(&ctx->nonce.c[1], nonce, 14 - L); 97 memcpy(&ctx->nonce.c[1], nonce, 14 - L);
@@ -116,29 +116,29 @@ CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx,
116 ctx->blocks++; 116 ctx->blocks++;
117 117
118 if (alen < (0x10000 - 0x100)) { 118 if (alen < (0x10000 - 0x100)) {
119 ctx->cmac.c[0] ^= (u8)(alen >> 8); 119 ctx->cmac.c[0] ^= (uint8_t)(alen >> 8);
120 ctx->cmac.c[1] ^= (u8)alen; 120 ctx->cmac.c[1] ^= (uint8_t)alen;
121 i = 2; 121 i = 2;
122 } else if (sizeof(alen) == 8 && 122 } else if (sizeof(alen) == 8 &&
123 alen >= (size_t)1 << (32 % (sizeof(alen)*8))) { 123 alen >= (size_t)1 << (32 % (sizeof(alen)*8))) {
124 ctx->cmac.c[0] ^= 0xFF; 124 ctx->cmac.c[0] ^= 0xFF;
125 ctx->cmac.c[1] ^= 0xFF; 125 ctx->cmac.c[1] ^= 0xFF;
126 ctx->cmac.c[2] ^= (u8)(alen >> (56 % (sizeof(alen)*8))); 126 ctx->cmac.c[2] ^= (uint8_t)(alen >> (56 % (sizeof(alen)*8)));
127 ctx->cmac.c[3] ^= (u8)(alen >> (48 % (sizeof(alen)*8))); 127 ctx->cmac.c[3] ^= (uint8_t)(alen >> (48 % (sizeof(alen)*8)));
128 ctx->cmac.c[4] ^= (u8)(alen >> (40 % (sizeof(alen)*8))); 128 ctx->cmac.c[4] ^= (uint8_t)(alen >> (40 % (sizeof(alen)*8)));
129 ctx->cmac.c[5] ^= (u8)(alen >> (32 % (sizeof(alen)*8))); 129 ctx->cmac.c[5] ^= (uint8_t)(alen >> (32 % (sizeof(alen)*8)));
130 ctx->cmac.c[6] ^= (u8)(alen >> 24); 130 ctx->cmac.c[6] ^= (uint8_t)(alen >> 24);
131 ctx->cmac.c[7] ^= (u8)(alen >> 16); 131 ctx->cmac.c[7] ^= (uint8_t)(alen >> 16);
132 ctx->cmac.c[8] ^= (u8)(alen >> 8); 132 ctx->cmac.c[8] ^= (uint8_t)(alen >> 8);
133 ctx->cmac.c[9] ^= (u8)alen; 133 ctx->cmac.c[9] ^= (uint8_t)alen;
134 i = 10; 134 i = 10;
135 } else { 135 } else {
136 ctx->cmac.c[0] ^= 0xFF; 136 ctx->cmac.c[0] ^= 0xFF;
137 ctx->cmac.c[1] ^= 0xFE; 137 ctx->cmac.c[1] ^= 0xFE;
138 ctx->cmac.c[2] ^= (u8)(alen >> 24); 138 ctx->cmac.c[2] ^= (uint8_t)(alen >> 24);
139 ctx->cmac.c[3] ^= (u8)(alen >> 16); 139 ctx->cmac.c[3] ^= (uint8_t)(alen >> 16);
140 ctx->cmac.c[4] ^= (u8)(alen >> 8); 140 ctx->cmac.c[4] ^= (uint8_t)(alen >> 8);
141 ctx->cmac.c[5] ^= (u8)alen; 141 ctx->cmac.c[5] ^= (uint8_t)alen;
142 i = 6; 142 i = 6;
143 } 143 }
144 144
@@ -160,7 +160,7 @@ static void
160ctr64_inc(unsigned char *counter) 160ctr64_inc(unsigned char *counter)
161{ 161{
162 unsigned int n = 8; 162 unsigned int n = 8;
163 u8 c; 163 uint8_t c;
164 164
165 counter += 8; 165 counter += 8;
166 do { 166 do {
@@ -184,8 +184,8 @@ CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
184 block128_f block = ctx->block; 184 block128_f block = ctx->block;
185 void *key = ctx->key; 185 void *key = ctx->key;
186 union { 186 union {
187 u64 u[2]; 187 uint64_t u[2];
188 u8 c[16]; 188 uint8_t c[16];
189 } scratch; 189 } scratch;
190 190
191 if (!(flags0 & 0x40)) 191 if (!(flags0 & 0x40))
@@ -211,16 +211,16 @@ CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
211 while (len >= 16) { 211 while (len >= 16) {
212#ifdef __STRICT_ALIGNMENT 212#ifdef __STRICT_ALIGNMENT
213 union { 213 union {
214 u64 u[2]; 214 uint64_t u[2];
215 u8 c[16]; 215 uint8_t c[16];
216 } temp; 216 } temp;
217 217
218 memcpy(temp.c, inp, 16); 218 memcpy(temp.c, inp, 16);
219 ctx->cmac.u[0] ^= temp.u[0]; 219 ctx->cmac.u[0] ^= temp.u[0];
220 ctx->cmac.u[1] ^= temp.u[1]; 220 ctx->cmac.u[1] ^= temp.u[1];
221#else 221#else
222 ctx->cmac.u[0] ^= ((u64 *)inp)[0]; 222 ctx->cmac.u[0] ^= ((uint64_t *)inp)[0];
223 ctx->cmac.u[1] ^= ((u64 *)inp)[1]; 223 ctx->cmac.u[1] ^= ((uint64_t *)inp)[1];
224#endif 224#endif
225 (*block)(ctx->cmac.c, ctx->cmac.c, key); 225 (*block)(ctx->cmac.c, ctx->cmac.c, key);
226 (*block)(ctx->nonce.c, scratch.c, key); 226 (*block)(ctx->nonce.c, scratch.c, key);
@@ -230,8 +230,8 @@ CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
230 temp.u[1] ^= scratch.u[1]; 230 temp.u[1] ^= scratch.u[1];
231 memcpy(out, temp.c, 16); 231 memcpy(out, temp.c, 16);
232#else 232#else
233 ((u64 *)out)[0] = scratch.u[0] ^ ((u64 *)inp)[0]; 233 ((uint64_t *)out)[0] = scratch.u[0] ^ ((uint64_t *)inp)[0];
234 ((u64 *)out)[1] = scratch.u[1] ^ ((u64 *)inp)[1]; 234 ((uint64_t *)out)[1] = scratch.u[1] ^ ((uint64_t *)inp)[1];
235#endif 235#endif
236 inp += 16; 236 inp += 16;
237 out += 16; 237 out += 16;
@@ -271,8 +271,8 @@ CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
271 block128_f block = ctx->block; 271 block128_f block = ctx->block;
272 void *key = ctx->key; 272 void *key = ctx->key;
273 union { 273 union {
274 u64 u[2]; 274 uint64_t u[2];
275 u8 c[16]; 275 uint8_t c[16];
276 } scratch; 276 } scratch;
277 277
278 if (!(flags0 & 0x40)) 278 if (!(flags0 & 0x40))
@@ -293,8 +293,8 @@ CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
293 while (len >= 16) { 293 while (len >= 16) {
294#ifdef __STRICT_ALIGNMENT 294#ifdef __STRICT_ALIGNMENT
295 union { 295 union {
296 u64 u[2]; 296 uint64_t u[2];
297 u8 c[16]; 297 uint8_t c[16];
298 } temp; 298 } temp;
299#endif 299#endif
300 (*block)(ctx->nonce.c, scratch.c, key); 300 (*block)(ctx->nonce.c, scratch.c, key);
@@ -305,10 +305,10 @@ CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
305 ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]); 305 ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]);
306 memcpy(out, scratch.c, 16); 306 memcpy(out, scratch.c, 16);
307#else 307#else
308 ctx->cmac.u[0] ^= (((u64 *)out)[0] = scratch.u[0] ^ 308 ctx->cmac.u[0] ^= (((uint64_t *)out)[0] = scratch.u[0] ^
309 ((u64 *)inp)[0]); 309 ((uint64_t *)inp)[0]);
310 ctx->cmac.u[1] ^= (((u64 *)out)[1] = scratch.u[1] ^ 310 ctx->cmac.u[1] ^= (((uint64_t *)out)[1] = scratch.u[1] ^
311 ((u64 *)inp)[1]); 311 ((uint64_t *)inp)[1]);
312#endif 312#endif
313 (*block)(ctx->cmac.c, ctx->cmac.c, key); 313 (*block)(ctx->cmac.c, ctx->cmac.c, key);
314 314
@@ -363,8 +363,8 @@ CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx,
363 block128_f block = ctx->block; 363 block128_f block = ctx->block;
364 void *key = ctx->key; 364 void *key = ctx->key;
365 union { 365 union {
366 u64 u[2]; 366 uint64_t u[2];
367 u8 c[16]; 367 uint8_t c[16];
368 } scratch; 368 } scratch;
369 369
370 if (!(flags0 & 0x40)) 370 if (!(flags0 & 0x40))
@@ -430,8 +430,8 @@ CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx,
430 block128_f block = ctx->block; 430 block128_f block = ctx->block;
431 void *key = ctx->key; 431 void *key = ctx->key;
432 union { 432 union {
433 u64 u[2]; 433 uint64_t u[2];
434 u8 c[16]; 434 uint8_t c[16];
435 } scratch; 435 } scratch;
436 436
437 if (!(flags0 & 0x40)) 437 if (!(flags0 & 0x40))
diff --git a/src/lib/libcrypto/modes/ctr128.c b/src/lib/libcrypto/modes/ctr128.c
index 30563ed6e3..87d9abb355 100644
--- a/src/lib/libcrypto/modes/ctr128.c
+++ b/src/lib/libcrypto/modes/ctr128.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ctr128.c,v 1.17 2025/04/23 10:09:08 jsing Exp $ */ 1/* $OpenBSD: ctr128.c,v 1.18 2025/05/18 09:05:59 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2008 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -63,8 +63,8 @@
63static void 63static void
64ctr128_inc(unsigned char *counter) 64ctr128_inc(unsigned char *counter)
65{ 65{
66 u32 n = 16; 66 uint32_t n = 16;
67 u8 c; 67 uint8_t c;
68 68
69 do { 69 do {
70 --n; 70 --n;
@@ -175,8 +175,8 @@ LCRYPTO_ALIAS(CRYPTO_ctr128_encrypt);
175static void 175static void
176ctr96_inc(unsigned char *counter) 176ctr96_inc(unsigned char *counter)
177{ 177{
178 u32 n = 12; 178 uint32_t n = 12;
179 u8 c; 179 uint8_t c;
180 180
181 do { 181 do {
182 --n; 182 --n;
@@ -223,7 +223,7 @@ CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
223 * overflow, which is then handled by limiting the 223 * overflow, which is then handled by limiting the
224 * amount of blocks to the exact overflow point... 224 * amount of blocks to the exact overflow point...
225 */ 225 */
226 ctr32 += (u32)blocks; 226 ctr32 += (uint32_t)blocks;
227 if (ctr32 < blocks) { 227 if (ctr32 < blocks) {
228 blocks -= ctr32; 228 blocks -= ctr32;
229 ctr32 = 0; 229 ctr32 = 0;
diff --git a/src/lib/libcrypto/modes/gcm128.c b/src/lib/libcrypto/modes/gcm128.c
index 21ba9eef57..b6874296e0 100644
--- a/src/lib/libcrypto/modes/gcm128.c
+++ b/src/lib/libcrypto/modes/gcm128.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gcm128.c,v 1.35 2025/04/25 12:08:53 jsing Exp $ */ 1/* $OpenBSD: gcm128.c,v 1.54 2025/06/28 12:39:10 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -55,184 +55,12 @@
55#include "crypto_internal.h" 55#include "crypto_internal.h"
56#include "modes_local.h" 56#include "modes_local.h"
57 57
58#define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16)) 58void
59#define REDUCE1BIT(V) \ 59gcm_init_4bit(u128 Htable[16], uint64_t H[2])
60 do { \
61 if (sizeof(size_t)==8) { \
62 u64 T = U64(0xe100000000000000) & (0-(V.lo&1)); \
63 V.lo = (V.hi<<63)|(V.lo>>1); \
64 V.hi = (V.hi>>1 )^T; \
65 } else { \
66 u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); \
67 V.lo = (V.hi<<63)|(V.lo>>1); \
68 V.hi = (V.hi>>1 )^((u64)T<<32); \
69 } \
70 } while(0)
71
72/*
73 * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should
74 * never be set to 8. 8 is effectively reserved for testing purposes.
75 * TABLE_BITS>1 are lookup-table-driven implementations referred to as
76 * "Shoup's" in GCM specification. In other words OpenSSL does not cover
77 * whole spectrum of possible table driven implementations. Why? In
78 * non-"Shoup's" case memory access pattern is segmented in such manner,
79 * that it's trivial to see that cache timing information can reveal
80 * fair portion of intermediate hash value. Given that ciphertext is
81 * always available to attacker, it's possible for him to attempt to
82 * deduce secret parameter H and if successful, tamper with messages
83 * [which is nothing but trivial in CTR mode]. In "Shoup's" case it's
84 * not as trivial, but there is no reason to believe that it's resistant
85 * to cache-timing attack. And the thing about "8-bit" implementation is
86 * that it consumes 16 (sixteen) times more memory, 4KB per individual
87 * key + 1KB shared. Well, on pros side it should be twice as fast as
88 * "4-bit" version. And for gcc-generated x86[_64] code, "8-bit" version
89 * was observed to run ~75% faster, closer to 100% for commercial
90 * compilers... Yet "4-bit" procedure is preferred, because it's
91 * believed to provide better security-performance balance and adequate
92 * all-round performance. "All-round" refers to things like:
93 *
94 * - shorter setup time effectively improves overall timing for
95 * handling short messages;
96 * - larger table allocation can become unbearable because of VM
97 * subsystem penalties (for example on Windows large enough free
98 * results in VM working set trimming, meaning that consequent
99 * malloc would immediately incur working set expansion);
100 * - larger table has larger cache footprint, which can affect
101 * performance of other code paths (not necessarily even from same
102 * thread in Hyper-Threading world);
103 *
104 * Value of 1 is not appropriate for performance reasons.
105 */
106#if TABLE_BITS==8
107
108static void
109gcm_init_8bit(u128 Htable[256], u64 H[2])
110{
111 int i, j;
112 u128 V;
113
114 Htable[0].hi = 0;
115 Htable[0].lo = 0;
116 V.hi = H[0];
117 V.lo = H[1];
118
119 for (Htable[128] = V, i = 64; i > 0; i >>= 1) {
120 REDUCE1BIT(V);
121 Htable[i] = V;
122 }
123
124 for (i = 2; i < 256; i <<= 1) {
125 u128 *Hi = Htable + i, H0 = *Hi;
126 for (j = 1; j < i; ++j) {
127 Hi[j].hi = H0.hi ^ Htable[j].hi;
128 Hi[j].lo = H0.lo ^ Htable[j].lo;
129 }
130 }
131}
132
133static void
134gcm_gmult_8bit(u64 Xi[2], const u128 Htable[256])
135{
136 u128 Z = { 0, 0};
137 const u8 *xi = (const u8 *)Xi + 15;
138 size_t rem, n = *xi;
139 static const size_t rem_8bit[256] = {
140 PACK(0x0000), PACK(0x01C2), PACK(0x0384), PACK(0x0246),
141 PACK(0x0708), PACK(0x06CA), PACK(0x048C), PACK(0x054E),
142 PACK(0x0E10), PACK(0x0FD2), PACK(0x0D94), PACK(0x0C56),
143 PACK(0x0918), PACK(0x08DA), PACK(0x0A9C), PACK(0x0B5E),
144 PACK(0x1C20), PACK(0x1DE2), PACK(0x1FA4), PACK(0x1E66),
145 PACK(0x1B28), PACK(0x1AEA), PACK(0x18AC), PACK(0x196E),
146 PACK(0x1230), PACK(0x13F2), PACK(0x11B4), PACK(0x1076),
147 PACK(0x1538), PACK(0x14FA), PACK(0x16BC), PACK(0x177E),
148 PACK(0x3840), PACK(0x3982), PACK(0x3BC4), PACK(0x3A06),
149 PACK(0x3F48), PACK(0x3E8A), PACK(0x3CCC), PACK(0x3D0E),
150 PACK(0x3650), PACK(0x3792), PACK(0x35D4), PACK(0x3416),
151 PACK(0x3158), PACK(0x309A), PACK(0x32DC), PACK(0x331E),
152 PACK(0x2460), PACK(0x25A2), PACK(0x27E4), PACK(0x2626),
153 PACK(0x2368), PACK(0x22AA), PACK(0x20EC), PACK(0x212E),
154 PACK(0x2A70), PACK(0x2BB2), PACK(0x29F4), PACK(0x2836),
155 PACK(0x2D78), PACK(0x2CBA), PACK(0x2EFC), PACK(0x2F3E),
156 PACK(0x7080), PACK(0x7142), PACK(0x7304), PACK(0x72C6),
157 PACK(0x7788), PACK(0x764A), PACK(0x740C), PACK(0x75CE),
158 PACK(0x7E90), PACK(0x7F52), PACK(0x7D14), PACK(0x7CD6),
159 PACK(0x7998), PACK(0x785A), PACK(0x7A1C), PACK(0x7BDE),
160 PACK(0x6CA0), PACK(0x6D62), PACK(0x6F24), PACK(0x6EE6),
161 PACK(0x6BA8), PACK(0x6A6A), PACK(0x682C), PACK(0x69EE),
162 PACK(0x62B0), PACK(0x6372), PACK(0x6134), PACK(0x60F6),
163 PACK(0x65B8), PACK(0x647A), PACK(0x663C), PACK(0x67FE),
164 PACK(0x48C0), PACK(0x4902), PACK(0x4B44), PACK(0x4A86),
165 PACK(0x4FC8), PACK(0x4E0A), PACK(0x4C4C), PACK(0x4D8E),
166 PACK(0x46D0), PACK(0x4712), PACK(0x4554), PACK(0x4496),
167 PACK(0x41D8), PACK(0x401A), PACK(0x425C), PACK(0x439E),
168 PACK(0x54E0), PACK(0x5522), PACK(0x5764), PACK(0x56A6),
169 PACK(0x53E8), PACK(0x522A), PACK(0x506C), PACK(0x51AE),
170 PACK(0x5AF0), PACK(0x5B32), PACK(0x5974), PACK(0x58B6),
171 PACK(0x5DF8), PACK(0x5C3A), PACK(0x5E7C), PACK(0x5FBE),
172 PACK(0xE100), PACK(0xE0C2), PACK(0xE284), PACK(0xE346),
173 PACK(0xE608), PACK(0xE7CA), PACK(0xE58C), PACK(0xE44E),
174 PACK(0xEF10), PACK(0xEED2), PACK(0xEC94), PACK(0xED56),
175 PACK(0xE818), PACK(0xE9DA), PACK(0xEB9C), PACK(0xEA5E),
176 PACK(0xFD20), PACK(0xFCE2), PACK(0xFEA4), PACK(0xFF66),
177 PACK(0xFA28), PACK(0xFBEA), PACK(0xF9AC), PACK(0xF86E),
178 PACK(0xF330), PACK(0xF2F2), PACK(0xF0B4), PACK(0xF176),
179 PACK(0xF438), PACK(0xF5FA), PACK(0xF7BC), PACK(0xF67E),
180 PACK(0xD940), PACK(0xD882), PACK(0xDAC4), PACK(0xDB06),
181 PACK(0xDE48), PACK(0xDF8A), PACK(0xDDCC), PACK(0xDC0E),
182 PACK(0xD750), PACK(0xD692), PACK(0xD4D4), PACK(0xD516),
183 PACK(0xD058), PACK(0xD19A), PACK(0xD3DC), PACK(0xD21E),
184 PACK(0xC560), PACK(0xC4A2), PACK(0xC6E4), PACK(0xC726),
185 PACK(0xC268), PACK(0xC3AA), PACK(0xC1EC), PACK(0xC02E),
186 PACK(0xCB70), PACK(0xCAB2), PACK(0xC8F4), PACK(0xC936),
187 PACK(0xCC78), PACK(0xCDBA), PACK(0xCFFC), PACK(0xCE3E),
188 PACK(0x9180), PACK(0x9042), PACK(0x9204), PACK(0x93C6),
189 PACK(0x9688), PACK(0x974A), PACK(0x950C), PACK(0x94CE),
190 PACK(0x9F90), PACK(0x9E52), PACK(0x9C14), PACK(0x9DD6),
191 PACK(0x9898), PACK(0x995A), PACK(0x9B1C), PACK(0x9ADE),
192 PACK(0x8DA0), PACK(0x8C62), PACK(0x8E24), PACK(0x8FE6),
193 PACK(0x8AA8), PACK(0x8B6A), PACK(0x892C), PACK(0x88EE),
194 PACK(0x83B0), PACK(0x8272), PACK(0x8034), PACK(0x81F6),
195 PACK(0x84B8), PACK(0x857A), PACK(0x873C), PACK(0x86FE),
196 PACK(0xA9C0), PACK(0xA802), PACK(0xAA44), PACK(0xAB86),
197 PACK(0xAEC8), PACK(0xAF0A), PACK(0xAD4C), PACK(0xAC8E),
198 PACK(0xA7D0), PACK(0xA612), PACK(0xA454), PACK(0xA596),
199 PACK(0xA0D8), PACK(0xA11A), PACK(0xA35C), PACK(0xA29E),
200 PACK(0xB5E0), PACK(0xB422), PACK(0xB664), PACK(0xB7A6),
201 PACK(0xB2E8), PACK(0xB32A), PACK(0xB16C), PACK(0xB0AE),
202 PACK(0xBBF0), PACK(0xBA32), PACK(0xB874), PACK(0xB9B6),
203 PACK(0xBCF8), PACK(0xBD3A), PACK(0xBF7C), PACK(0xBEBE) };
204
205 while (1) {
206 Z.hi ^= Htable[n].hi;
207 Z.lo ^= Htable[n].lo;
208
209 if ((u8 *)Xi == xi)
210 break;
211
212 n = *(--xi);
213
214 rem = (size_t)Z.lo & 0xff;
215 Z.lo = (Z.hi << 56)|(Z.lo >> 8);
216 Z.hi = (Z.hi >> 8);
217#if SIZE_MAX == 0xffffffffffffffff
218 Z.hi ^= rem_8bit[rem];
219#else
220 Z.hi ^= (u64)rem_8bit[rem] << 32;
221#endif
222 }
223
224 Xi[0] = htobe64(Z.hi);
225 Xi[1] = htobe64(Z.lo);
226}
227#define GCM_MUL(ctx,Xi) gcm_gmult_8bit(ctx->Xi.u,ctx->Htable)
228
229#elif TABLE_BITS==4
230
231static void
232gcm_init_4bit(u128 Htable[16], u64 H[2])
233{ 60{
234 u128 V; 61 u128 V;
235 int i; 62 uint64_t T;
63 int i;
236 64
237 Htable[0].hi = 0; 65 Htable[0].hi = 0;
238 Htable[0].lo = 0; 66 Htable[0].lo = 0;
@@ -240,57 +68,41 @@ gcm_init_4bit(u128 Htable[16], u64 H[2])
240 V.lo = H[1]; 68 V.lo = H[1];
241 69
242 for (Htable[8] = V, i = 4; i > 0; i >>= 1) { 70 for (Htable[8] = V, i = 4; i > 0; i >>= 1) {
243 REDUCE1BIT(V); 71 T = U64(0xe100000000000000) & (0 - (V.lo & 1));
72 V.lo = (V.hi << 63) | (V.lo >> 1);
73 V.hi = (V.hi >> 1 ) ^ T;
244 Htable[i] = V; 74 Htable[i] = V;
245 } 75 }
246 76
247 for (i = 2; i < 16; i <<= 1) { 77 for (i = 2; i < 16; i <<= 1) {
248 u128 *Hi = Htable + i; 78 u128 *Hi = Htable + i;
249 int j; 79 int j;
250 for (V = *Hi, j = 1; j < i; ++j) { 80 for (V = *Hi, j = 1; j < i; j++) {
251 Hi[j].hi = V.hi ^ Htable[j].hi; 81 Hi[j].hi = V.hi ^ Htable[j].hi;
252 Hi[j].lo = V.lo ^ Htable[j].lo; 82 Hi[j].lo = V.lo ^ Htable[j].lo;
253 } 83 }
254 } 84 }
255
256#if defined(GHASH_ASM) && (defined(__arm__) || defined(__arm))
257 /*
258 * ARM assembler expects specific dword order in Htable.
259 */
260 {
261 int j;
262#if BYTE_ORDER == LITTLE_ENDIAN
263 for (j = 0; j < 16; ++j) {
264 V = Htable[j];
265 Htable[j].hi = V.lo;
266 Htable[j].lo = V.hi;
267 }
268#else /* BIG_ENDIAN */
269 for (j = 0; j < 16; ++j) {
270 V = Htable[j];
271 Htable[j].hi = V.lo << 32|V.lo >> 32;
272 Htable[j].lo = V.hi << 32|V.hi >> 32;
273 }
274#endif
275 }
276#endif
277} 85}
278 86
279#ifndef GHASH_ASM 87#ifdef GHASH_ASM
280static const size_t rem_4bit[16] = { 88void gcm_gmult_4bit(uint64_t Xi[2], const u128 Htable[16]);
281 PACK(0x0000), PACK(0x1C20), PACK(0x3840), PACK(0x2460), 89void gcm_ghash_4bit(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
282 PACK(0x7080), PACK(0x6CA0), PACK(0x48C0), PACK(0x54E0), 90 size_t len);
283 PACK(0xE100), PACK(0xFD20), PACK(0xD940), PACK(0xC560), 91
284 PACK(0x9180), PACK(0x8DA0), PACK(0xA9C0), PACK(0xB5E0) }; 92#else
93static const uint16_t rem_4bit[16] = {
94 0x0000, 0x1c20, 0x3840, 0x2460, 0x7080, 0x6ca0, 0x48c0, 0x54e0,
95 0xe100, 0xfd20, 0xd940, 0xc560, 0x9180, 0x8da0, 0xa9c0, 0xb5e0,
96};
285 97
286static void 98static void
287gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16]) 99gcm_gmult_4bit(uint64_t Xi[2], const u128 Htable[16])
288{ 100{
289 u128 Z; 101 u128 Z;
290 int cnt = 15; 102 int cnt = 15;
291 size_t rem, nlo, nhi; 103 size_t rem, nlo, nhi;
292 104
293 nlo = ((const u8 *)Xi)[15]; 105 nlo = ((const uint8_t *)Xi)[15];
294 nhi = nlo >> 4; 106 nhi = nlo >> 4;
295 nlo &= 0xf; 107 nlo &= 0xf;
296 108
@@ -301,29 +113,21 @@ gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16])
301 rem = (size_t)Z.lo & 0xf; 113 rem = (size_t)Z.lo & 0xf;
302 Z.lo = (Z.hi << 60)|(Z.lo >> 4); 114 Z.lo = (Z.hi << 60)|(Z.lo >> 4);
303 Z.hi = (Z.hi >> 4); 115 Z.hi = (Z.hi >> 4);
304#if SIZE_MAX == 0xffffffffffffffff 116 Z.hi ^= (uint64_t)rem_4bit[rem] << 48;
305 Z.hi ^= rem_4bit[rem];
306#else
307 Z.hi ^= (u64)rem_4bit[rem] << 32;
308#endif
309 Z.hi ^= Htable[nhi].hi; 117 Z.hi ^= Htable[nhi].hi;
310 Z.lo ^= Htable[nhi].lo; 118 Z.lo ^= Htable[nhi].lo;
311 119
312 if (--cnt < 0) 120 if (--cnt < 0)
313 break; 121 break;
314 122
315 nlo = ((const u8 *)Xi)[cnt]; 123 nlo = ((const uint8_t *)Xi)[cnt];
316 nhi = nlo >> 4; 124 nhi = nlo >> 4;
317 nlo &= 0xf; 125 nlo &= 0xf;
318 126
319 rem = (size_t)Z.lo & 0xf; 127 rem = (size_t)Z.lo & 0xf;
320 Z.lo = (Z.hi << 60)|(Z.lo >> 4); 128 Z.lo = (Z.hi << 60)|(Z.lo >> 4);
321 Z.hi = (Z.hi >> 4); 129 Z.hi = (Z.hi >> 4);
322#if SIZE_MAX == 0xffffffffffffffff 130 Z.hi ^= (uint64_t)rem_4bit[rem] << 48;
323 Z.hi ^= rem_4bit[rem];
324#else
325 Z.hi ^= (u64)rem_4bit[rem] << 32;
326#endif
327 Z.hi ^= Htable[nlo].hi; 131 Z.hi ^= Htable[nlo].hi;
328 Z.lo ^= Htable[nlo].lo; 132 Z.lo ^= Htable[nlo].lo;
329 } 133 }
@@ -332,25 +136,17 @@ gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16])
332 Xi[1] = htobe64(Z.lo); 136 Xi[1] = htobe64(Z.lo);
333} 137}
334 138
335/*
336 * Streamed gcm_mult_4bit, see CRYPTO_gcm128_[en|de]crypt for
337 * details... Compiler-generated code doesn't seem to give any
338 * performance improvement, at least not on x86[_64]. It's here
339 * mostly as reference and a placeholder for possible future
340 * non-trivial optimization[s]...
341 */
342static void 139static void
343gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16], 140gcm_ghash_4bit(uint64_t Xi[2], const u128 Htable[16],
344 const u8 *inp, size_t len) 141 const uint8_t *inp, size_t len)
345{ 142{
346 u128 Z; 143 u128 Z;
347 int cnt; 144 int cnt;
348 size_t rem, nlo, nhi; 145 size_t rem, nlo, nhi;
349 146
350#if 1
351 do { 147 do {
352 cnt = 15; 148 cnt = 15;
353 nlo = ((const u8 *)Xi)[15]; 149 nlo = ((const uint8_t *)Xi)[15];
354 nlo ^= inp[15]; 150 nlo ^= inp[15];
355 nhi = nlo >> 4; 151 nhi = nlo >> 4;
356 nlo &= 0xf; 152 nlo &= 0xf;
@@ -362,18 +158,14 @@ gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16],
362 rem = (size_t)Z.lo & 0xf; 158 rem = (size_t)Z.lo & 0xf;
363 Z.lo = (Z.hi << 60)|(Z.lo >> 4); 159 Z.lo = (Z.hi << 60)|(Z.lo >> 4);
364 Z.hi = (Z.hi >> 4); 160 Z.hi = (Z.hi >> 4);
365#if SIZE_MAX == 0xffffffffffffffff 161 Z.hi ^= (uint64_t)rem_4bit[rem] << 48;
366 Z.hi ^= rem_4bit[rem];
367#else
368 Z.hi ^= (u64)rem_4bit[rem] << 32;
369#endif
370 Z.hi ^= Htable[nhi].hi; 162 Z.hi ^= Htable[nhi].hi;
371 Z.lo ^= Htable[nhi].lo; 163 Z.lo ^= Htable[nhi].lo;
372 164
373 if (--cnt < 0) 165 if (--cnt < 0)
374 break; 166 break;
375 167
376 nlo = ((const u8 *)Xi)[cnt]; 168 nlo = ((const uint8_t *)Xi)[cnt];
377 nlo ^= inp[cnt]; 169 nlo ^= inp[cnt];
378 nhi = nlo >> 4; 170 nhi = nlo >> 4;
379 nlo &= 0xf; 171 nlo &= 0xf;
@@ -381,205 +173,40 @@ gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16],
381 rem = (size_t)Z.lo & 0xf; 173 rem = (size_t)Z.lo & 0xf;
382 Z.lo = (Z.hi << 60)|(Z.lo >> 4); 174 Z.lo = (Z.hi << 60)|(Z.lo >> 4);
383 Z.hi = (Z.hi >> 4); 175 Z.hi = (Z.hi >> 4);
384#if SIZE_MAX == 0xffffffffffffffff 176 Z.hi ^= (uint64_t)rem_4bit[rem] << 48;
385 Z.hi ^= rem_4bit[rem];
386#else
387 Z.hi ^= (u64)rem_4bit[rem] << 32;
388#endif
389 Z.hi ^= Htable[nlo].hi; 177 Z.hi ^= Htable[nlo].hi;
390 Z.lo ^= Htable[nlo].lo; 178 Z.lo ^= Htable[nlo].lo;
391 } 179 }
392#else
393 /*
394 * Extra 256+16 bytes per-key plus 512 bytes shared tables
395 * [should] give ~50% improvement... One could have PACK()-ed
396 * the rem_8bit even here, but the priority is to minimize
397 * cache footprint...
398 */
399 u128 Hshr4[16]; /* Htable shifted right by 4 bits */
400 u8 Hshl4[16]; /* Htable shifted left by 4 bits */
401 static const unsigned short rem_8bit[256] = {
402 0x0000, 0x01C2, 0x0384, 0x0246, 0x0708, 0x06CA, 0x048C, 0x054E,
403 0x0E10, 0x0FD2, 0x0D94, 0x0C56, 0x0918, 0x08DA, 0x0A9C, 0x0B5E,
404 0x1C20, 0x1DE2, 0x1FA4, 0x1E66, 0x1B28, 0x1AEA, 0x18AC, 0x196E,
405 0x1230, 0x13F2, 0x11B4, 0x1076, 0x1538, 0x14FA, 0x16BC, 0x177E,
406 0x3840, 0x3982, 0x3BC4, 0x3A06, 0x3F48, 0x3E8A, 0x3CCC, 0x3D0E,
407 0x3650, 0x3792, 0x35D4, 0x3416, 0x3158, 0x309A, 0x32DC, 0x331E,
408 0x2460, 0x25A2, 0x27E4, 0x2626, 0x2368, 0x22AA, 0x20EC, 0x212E,
409 0x2A70, 0x2BB2, 0x29F4, 0x2836, 0x2D78, 0x2CBA, 0x2EFC, 0x2F3E,
410 0x7080, 0x7142, 0x7304, 0x72C6, 0x7788, 0x764A, 0x740C, 0x75CE,
411 0x7E90, 0x7F52, 0x7D14, 0x7CD6, 0x7998, 0x785A, 0x7A1C, 0x7BDE,
412 0x6CA0, 0x6D62, 0x6F24, 0x6EE6, 0x6BA8, 0x6A6A, 0x682C, 0x69EE,
413 0x62B0, 0x6372, 0x6134, 0x60F6, 0x65B8, 0x647A, 0x663C, 0x67FE,
414 0x48C0, 0x4902, 0x4B44, 0x4A86, 0x4FC8, 0x4E0A, 0x4C4C, 0x4D8E,
415 0x46D0, 0x4712, 0x4554, 0x4496, 0x41D8, 0x401A, 0x425C, 0x439E,
416 0x54E0, 0x5522, 0x5764, 0x56A6, 0x53E8, 0x522A, 0x506C, 0x51AE,
417 0x5AF0, 0x5B32, 0x5974, 0x58B6, 0x5DF8, 0x5C3A, 0x5E7C, 0x5FBE,
418 0xE100, 0xE0C2, 0xE284, 0xE346, 0xE608, 0xE7CA, 0xE58C, 0xE44E,
419 0xEF10, 0xEED2, 0xEC94, 0xED56, 0xE818, 0xE9DA, 0xEB9C, 0xEA5E,
420 0xFD20, 0xFCE2, 0xFEA4, 0xFF66, 0xFA28, 0xFBEA, 0xF9AC, 0xF86E,
421 0xF330, 0xF2F2, 0xF0B4, 0xF176, 0xF438, 0xF5FA, 0xF7BC, 0xF67E,
422 0xD940, 0xD882, 0xDAC4, 0xDB06, 0xDE48, 0xDF8A, 0xDDCC, 0xDC0E,
423 0xD750, 0xD692, 0xD4D4, 0xD516, 0xD058, 0xD19A, 0xD3DC, 0xD21E,
424 0xC560, 0xC4A2, 0xC6E4, 0xC726, 0xC268, 0xC3AA, 0xC1EC, 0xC02E,
425 0xCB70, 0xCAB2, 0xC8F4, 0xC936, 0xCC78, 0xCDBA, 0xCFFC, 0xCE3E,
426 0x9180, 0x9042, 0x9204, 0x93C6, 0x9688, 0x974A, 0x950C, 0x94CE,
427 0x9F90, 0x9E52, 0x9C14, 0x9DD6, 0x9898, 0x995A, 0x9B1C, 0x9ADE,
428 0x8DA0, 0x8C62, 0x8E24, 0x8FE6, 0x8AA8, 0x8B6A, 0x892C, 0x88EE,
429 0x83B0, 0x8272, 0x8034, 0x81F6, 0x84B8, 0x857A, 0x873C, 0x86FE,
430 0xA9C0, 0xA802, 0xAA44, 0xAB86, 0xAEC8, 0xAF0A, 0xAD4C, 0xAC8E,
431 0xA7D0, 0xA612, 0xA454, 0xA596, 0xA0D8, 0xA11A, 0xA35C, 0xA29E,
432 0xB5E0, 0xB422, 0xB664, 0xB7A6, 0xB2E8, 0xB32A, 0xB16C, 0xB0AE,
433 0xBBF0, 0xBA32, 0xB874, 0xB9B6, 0xBCF8, 0xBD3A, 0xBF7C, 0xBEBE };
434 /*
435 * This pre-processing phase slows down procedure by approximately
436 * same time as it makes each loop spin faster. In other words
437 * single block performance is approximately same as straightforward
438 * "4-bit" implementation, and then it goes only faster...
439 */
440 for (cnt = 0; cnt < 16; ++cnt) {
441 Z.hi = Htable[cnt].hi;
442 Z.lo = Htable[cnt].lo;
443 Hshr4[cnt].lo = (Z.hi << 60)|(Z.lo >> 4);
444 Hshr4[cnt].hi = (Z.hi >> 4);
445 Hshl4[cnt] = (u8)(Z.lo << 4);
446 }
447
448 do {
449 for (Z.lo = 0, Z.hi = 0, cnt = 15; cnt; --cnt) {
450 nlo = ((const u8 *)Xi)[cnt];
451 nlo ^= inp[cnt];
452 nhi = nlo >> 4;
453 nlo &= 0xf;
454
455 Z.hi ^= Htable[nlo].hi;
456 Z.lo ^= Htable[nlo].lo;
457
458 rem = (size_t)Z.lo & 0xff;
459
460 Z.lo = (Z.hi << 56)|(Z.lo >> 8);
461 Z.hi = (Z.hi >> 8);
462
463 Z.hi ^= Hshr4[nhi].hi;
464 Z.lo ^= Hshr4[nhi].lo;
465 Z.hi ^= (u64)rem_8bit[rem ^ Hshl4[nhi]] << 48;
466 }
467
468 nlo = ((const u8 *)Xi)[0];
469 nlo ^= inp[0];
470 nhi = nlo >> 4;
471 nlo &= 0xf;
472
473 Z.hi ^= Htable[nlo].hi;
474 Z.lo ^= Htable[nlo].lo;
475
476 rem = (size_t)Z.lo & 0xf;
477
478 Z.lo = (Z.hi << 60)|(Z.lo >> 4);
479 Z.hi = (Z.hi >> 4);
480
481 Z.hi ^= Htable[nhi].hi;
482 Z.lo ^= Htable[nhi].lo;
483 Z.hi ^= ((u64)rem_8bit[rem << 4]) << 48;
484#endif
485 180
486 Xi[0] = htobe64(Z.hi); 181 Xi[0] = htobe64(Z.hi);
487 Xi[1] = htobe64(Z.lo); 182 Xi[1] = htobe64(Z.lo);
488 } while (inp += 16, len -= 16); 183 } while (inp += 16, len -= 16);
489} 184}
490#else
491void gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16]);
492void gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16], const u8 *inp,
493 size_t len);
494#endif 185#endif
495 186
496#define GCM_MUL(ctx,Xi) gcm_gmult_4bit(ctx->Xi.u,ctx->Htable) 187static inline void
497#define GHASH(ctx,in,len) gcm_ghash_4bit((ctx)->Xi.u,(ctx)->Htable,in,len) 188gcm_mul(GCM128_CONTEXT *ctx, uint64_t u[2])
498/* GHASH_CHUNK is "stride parameter" missioned to mitigate cache
499 * trashing effect. In other words idea is to hash data while it's
500 * still in L1 cache after encryption pass... */
501#define GHASH_CHUNK (3*1024)
502
503#else /* TABLE_BITS */
504
505static void
506gcm_gmult_1bit(u64 Xi[2], const u64 H[2])
507{ 189{
508 u128 V, Z = { 0, 0 }; 190 ctx->gmult(u, ctx->Htable);
509 u64 X;
510 int i, j;
511
512 V.hi = H[0]; /* H is in host byte order, no byte swapping */
513 V.lo = H[1];
514
515 for (j = 0; j < 2; j++) {
516 X = be64toh(Xi[j]);
517
518 for (i = 0; i < 64; i++) {
519 u64 M = 0 - (X >> 63);
520 Z.hi ^= V.hi & M;
521 Z.lo ^= V.lo & M;
522 X <<= 1;
523
524 REDUCE1BIT(V);
525 }
526 }
527
528 Xi[0] = htobe64(Z.hi);
529 Xi[1] = htobe64(Z.lo);
530} 191}
531#define GCM_MUL(ctx,Xi) gcm_gmult_1bit(ctx->Xi.u,ctx->H.u)
532
533#endif
534
535#if defined(GHASH_ASM) && \
536 (defined(__i386) || defined(__i386__) || \
537 defined(__x86_64) || defined(__x86_64__) || \
538 defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
539#include "x86_arch.h"
540#endif
541
542#if TABLE_BITS==4 && defined(GHASH_ASM)
543# if (defined(__i386) || defined(__i386__) || \
544 defined(__x86_64) || defined(__x86_64__) || \
545 defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
546# define GHASH_ASM_X86_OR_64
547# define GCM_FUNCREF_4BIT
548
549void gcm_init_clmul(u128 Htable[16], const u64 Xi[2]);
550void gcm_gmult_clmul(u64 Xi[2], const u128 Htable[16]);
551void gcm_ghash_clmul(u64 Xi[2], const u128 Htable[16], const u8 *inp,
552 size_t len);
553 192
554# if defined(__i386) || defined(__i386__) || defined(_M_IX86) 193static inline void
555# define GHASH_ASM_X86 194gcm_ghash(GCM128_CONTEXT *ctx, const uint8_t *in, size_t len)
556void gcm_gmult_4bit_mmx(u64 Xi[2], const u128 Htable[16]); 195{
557void gcm_ghash_4bit_mmx(u64 Xi[2], const u128 Htable[16], const u8 *inp, 196 ctx->ghash(ctx->Xi.u, ctx->Htable, in, len);
558 size_t len); 197}
559 198
560void gcm_gmult_4bit_x86(u64 Xi[2], const u128 Htable[16]); 199#ifdef HAVE_GCM128_INIT
561void gcm_ghash_4bit_x86(u64 Xi[2], const u128 Htable[16], const u8 *inp, 200void gcm128_init(GCM128_CONTEXT *ctx);
562 size_t len);
563# endif
564# elif defined(__arm__) || defined(__arm)
565# include "arm_arch.h"
566# if __ARM_ARCH__>=7 && !defined(__STRICT_ALIGNMENT)
567# define GHASH_ASM_ARM
568# define GCM_FUNCREF_4BIT
569void gcm_gmult_neon(u64 Xi[2], const u128 Htable[16]);
570void gcm_ghash_neon(u64 Xi[2], const u128 Htable[16], const u8 *inp,
571 size_t len);
572# endif
573# endif
574#endif
575 201
576#ifdef GCM_FUNCREF_4BIT 202#else
577# undef GCM_MUL 203static void
578# define GCM_MUL(ctx,Xi) (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable) 204gcm128_init(GCM128_CONTEXT *ctx)
579# ifdef GHASH 205{
580# undef GHASH 206 gcm_init_4bit(ctx->Htable, ctx->H.u);
581# define GHASH(ctx,in,len) (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,in,len) 207 ctx->gmult = gcm_gmult_4bit;
582# endif 208 ctx->ghash = gcm_ghash_4bit;
209}
583#endif 210#endif
584 211
585void 212void
@@ -595,60 +222,35 @@ CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block)
595 ctx->H.u[0] = be64toh(ctx->H.u[0]); 222 ctx->H.u[0] = be64toh(ctx->H.u[0]);
596 ctx->H.u[1] = be64toh(ctx->H.u[1]); 223 ctx->H.u[1] = be64toh(ctx->H.u[1]);
597 224
598#if TABLE_BITS==8 225 gcm128_init(ctx);
599 gcm_init_8bit(ctx->Htable, ctx->H.u);
600#elif TABLE_BITS==4
601# if defined(GHASH_ASM_X86_OR_64)
602# if !defined(GHASH_ASM_X86) || defined(OPENSSL_IA32_SSE2)
603 /* check FXSR and PCLMULQDQ bits */
604 if ((crypto_cpu_caps_ia32() & (CPUCAP_MASK_FXSR | CPUCAP_MASK_PCLMUL)) ==
605 (CPUCAP_MASK_FXSR | CPUCAP_MASK_PCLMUL)) {
606 gcm_init_clmul(ctx->Htable, ctx->H.u);
607 ctx->gmult = gcm_gmult_clmul;
608 ctx->ghash = gcm_ghash_clmul;
609 return;
610 }
611# endif
612 gcm_init_4bit(ctx->Htable, ctx->H.u);
613# if defined(GHASH_ASM_X86) /* x86 only */
614# if defined(OPENSSL_IA32_SSE2)
615 if (crypto_cpu_caps_ia32() & CPUCAP_MASK_SSE) { /* check SSE bit */
616# else
617 if (crypto_cpu_caps_ia32() & CPUCAP_MASK_MMX) { /* check MMX bit */
618# endif
619 ctx->gmult = gcm_gmult_4bit_mmx;
620 ctx->ghash = gcm_ghash_4bit_mmx;
621 } else {
622 ctx->gmult = gcm_gmult_4bit_x86;
623 ctx->ghash = gcm_ghash_4bit_x86;
624 }
625# else
626 ctx->gmult = gcm_gmult_4bit;
627 ctx->ghash = gcm_ghash_4bit;
628# endif
629# elif defined(GHASH_ASM_ARM)
630 if (OPENSSL_armcap_P & ARMV7_NEON) {
631 ctx->gmult = gcm_gmult_neon;
632 ctx->ghash = gcm_ghash_neon;
633 } else {
634 gcm_init_4bit(ctx->Htable, ctx->H.u);
635 ctx->gmult = gcm_gmult_4bit;
636 ctx->ghash = gcm_ghash_4bit;
637 }
638# else
639 gcm_init_4bit(ctx->Htable, ctx->H.u);
640# endif
641#endif
642} 226}
643LCRYPTO_ALIAS(CRYPTO_gcm128_init); 227LCRYPTO_ALIAS(CRYPTO_gcm128_init);
644 228
229GCM128_CONTEXT *
230CRYPTO_gcm128_new(void *key, block128_f block)
231{
232 GCM128_CONTEXT *ctx;
233
234 if ((ctx = calloc(1, sizeof(*ctx))) == NULL)
235 return NULL;
236
237 CRYPTO_gcm128_init(ctx, key, block);
238
239 return ctx;
240}
241LCRYPTO_ALIAS(CRYPTO_gcm128_new);
242
243void
244CRYPTO_gcm128_release(GCM128_CONTEXT *ctx)
245{
246 freezero(ctx, sizeof(*ctx));
247}
248LCRYPTO_ALIAS(CRYPTO_gcm128_release);
249
645void 250void
646CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, size_t len) 251CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, size_t len)
647{ 252{
648 unsigned int ctr; 253 unsigned int ctr;
649#ifdef GCM_FUNCREF_4BIT
650 void (*gcm_gmult_p)(u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
651#endif
652 254
653 ctx->Yi.u[0] = 0; 255 ctx->Yi.u[0] = 0;
654 ctx->Yi.u[1] = 0; 256 ctx->Yi.u[1] = 0;
@@ -665,573 +267,277 @@ CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, size_t len)
665 ctr = 1; 267 ctr = 1;
666 } else { 268 } else {
667 size_t i; 269 size_t i;
668 u64 len0 = len; 270 uint64_t len0 = len;
669 271
670 while (len >= 16) { 272 while (len >= 16) {
671 for (i = 0; i < 16; ++i) 273 for (i = 0; i < 16; i++)
672 ctx->Yi.c[i] ^= iv[i]; 274 ctx->Yi.c[i] ^= iv[i];
673 GCM_MUL(ctx, Yi); 275 gcm_mul(ctx, ctx->Yi.u);
674 iv += 16; 276 iv += 16;
675 len -= 16; 277 len -= 16;
676 } 278 }
677 if (len) { 279 if (len > 0) {
678 for (i = 0; i < len; ++i) 280 for (i = 0; i < len; i++)
679 ctx->Yi.c[i] ^= iv[i]; 281 ctx->Yi.c[i] ^= iv[i];
680 GCM_MUL(ctx, Yi); 282 gcm_mul(ctx, ctx->Yi.u);
681 } 283 }
682 len0 <<= 3; 284 len0 <<= 3;
683 ctx->Yi.u[1] ^= htobe64(len0); 285 ctx->Yi.u[1] ^= htobe64(len0);
684 286
685 GCM_MUL(ctx, Yi); 287 gcm_mul(ctx, ctx->Yi.u);
686 288
687 ctr = be32toh(ctx->Yi.d[3]); 289 ctr = be32toh(ctx->Yi.d[3]);
688 } 290 }
689 291
690 (*ctx->block)(ctx->Yi.c, ctx->EK0.c, ctx->key); 292 (*ctx->block)(ctx->Yi.c, ctx->EK0.c, ctx->key);
691 ++ctr; 293 ctx->Yi.d[3] = htobe32(++ctr);
692 ctx->Yi.d[3] = htobe32(ctr);
693} 294}
694LCRYPTO_ALIAS(CRYPTO_gcm128_setiv); 295LCRYPTO_ALIAS(CRYPTO_gcm128_setiv);
695 296
696int 297int
697CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, size_t len) 298CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, size_t len)
698{ 299{
699 size_t i;
700 unsigned int n; 300 unsigned int n;
701 u64 alen = ctx->len.u[0]; 301 uint64_t alen;
702#ifdef GCM_FUNCREF_4BIT 302 size_t i;
703 void (*gcm_gmult_p)(u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
704# ifdef GHASH
705 void (*gcm_ghash_p)(u64 Xi[2], const u128 Htable[16],
706 const u8 *inp, size_t len) = ctx->ghash;
707# endif
708#endif
709 303
710 if (ctx->len.u[1]) 304 if (ctx->len.u[1] != 0)
711 return -2; 305 return -2;
712 306
713 alen += len; 307 alen = ctx->len.u[0] + len;
714 if (alen > (U64(1) << 61) || (sizeof(len) == 8 && alen < len)) 308 if (alen > (U64(1) << 61) || (sizeof(len) == 8 && alen < len))
715 return -1; 309 return -1;
716 ctx->len.u[0] = alen; 310 ctx->len.u[0] = alen;
717 311
718 n = ctx->ares; 312 if ((n = ctx->ares) > 0) {
719 if (n) { 313 while (n > 0 && len > 0) {
720 while (n && len) {
721 ctx->Xi.c[n] ^= *(aad++); 314 ctx->Xi.c[n] ^= *(aad++);
722 --len;
723 n = (n + 1) % 16; 315 n = (n + 1) % 16;
316 len--;
724 } 317 }
725 if (n == 0) 318 if (n > 0) {
726 GCM_MUL(ctx, Xi);
727 else {
728 ctx->ares = n; 319 ctx->ares = n;
729 return 0; 320 return 0;
730 } 321 }
322 gcm_mul(ctx, ctx->Xi.u);
731 } 323 }
732 324
733#ifdef GHASH 325 if ((i = (len & (size_t)-16)) > 0) {
734 if ((i = (len & (size_t)-16))) { 326 gcm_ghash(ctx, aad, i);
735 GHASH(ctx, aad, i);
736 aad += i; 327 aad += i;
737 len -= i; 328 len -= i;
738 } 329 }
739#else 330 if (len > 0) {
740 while (len >= 16) {
741 for (i = 0; i < 16; ++i)
742 ctx->Xi.c[i] ^= aad[i];
743 GCM_MUL(ctx, Xi);
744 aad += 16;
745 len -= 16;
746 }
747#endif
748 if (len) {
749 n = (unsigned int)len; 331 n = (unsigned int)len;
750 for (i = 0; i < len; ++i) 332 for (i = 0; i < len; i++)
751 ctx->Xi.c[i] ^= aad[i]; 333 ctx->Xi.c[i] ^= aad[i];
752 } 334 }
753
754 ctx->ares = n; 335 ctx->ares = n;
336
755 return 0; 337 return 0;
756} 338}
757LCRYPTO_ALIAS(CRYPTO_gcm128_aad); 339LCRYPTO_ALIAS(CRYPTO_gcm128_aad);
758 340
759int 341int
760CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, 342CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const unsigned char *in,
761 const unsigned char *in, unsigned char *out, 343 unsigned char *out, size_t len)
762 size_t len)
763{ 344{
764 unsigned int n, ctr; 345 unsigned int n, ctr;
346 uint64_t mlen;
765 size_t i; 347 size_t i;
766 u64 mlen = ctx->len.u[1];
767 block128_f block = ctx->block;
768 void *key = ctx->key;
769#ifdef GCM_FUNCREF_4BIT
770 void (*gcm_gmult_p)(u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
771# ifdef GHASH
772 void (*gcm_ghash_p)(u64 Xi[2], const u128 Htable[16],
773 const u8 *inp, size_t len) = ctx->ghash;
774# endif
775#endif
776 348
777 mlen += len; 349 mlen = ctx->len.u[1] + len;
778 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) 350 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len))
779 return -1; 351 return -1;
780 ctx->len.u[1] = mlen; 352 ctx->len.u[1] = mlen;
781 353
782 if (ctx->ares) { 354 if (ctx->ares > 0) {
783 /* First call to encrypt finalizes GHASH(AAD) */ 355 /* First call to encrypt finalizes GHASH(AAD) */
784 GCM_MUL(ctx, Xi); 356 gcm_mul(ctx, ctx->Xi.u);
785 ctx->ares = 0; 357 ctx->ares = 0;
786 } 358 }
787 359
788 ctr = be32toh(ctx->Yi.d[3]); 360 ctr = be32toh(ctx->Yi.d[3]);
789 361
790 n = ctx->mres; 362 n = ctx->mres;
791 if (16 % sizeof(size_t) == 0)
792 do { /* always true actually */
793 if (n) {
794 while (n && len) {
795 ctx->Xi.c[n] ^= *(out++) = *(in++) ^
796 ctx->EKi.c[n];
797 --len;
798 n = (n + 1) % 16;
799 }
800 if (n == 0)
801 GCM_MUL(ctx, Xi);
802 else {
803 ctx->mres = n;
804 return 0;
805 }
806 }
807#ifdef __STRICT_ALIGNMENT
808 if (((size_t)in|(size_t)out) % sizeof(size_t) != 0)
809 break;
810#endif
811#if defined(GHASH) && defined(GHASH_CHUNK)
812 while (len >= GHASH_CHUNK) {
813 size_t j = GHASH_CHUNK;
814
815 while (j) {
816 size_t *out_t = (size_t *)out;
817 const size_t *in_t = (const size_t *)in;
818
819 (*block)(ctx->Yi.c, ctx->EKi.c, key);
820 ++ctr;
821 ctx->Yi.d[3] = htobe32(ctr);
822
823 for (i = 0; i < 16/sizeof(size_t); ++i)
824 out_t[i] = in_t[i] ^
825 ctx->EKi.t[i];
826 out += 16;
827 in += 16;
828 j -= 16;
829 }
830 GHASH(ctx, out - GHASH_CHUNK, GHASH_CHUNK);
831 len -= GHASH_CHUNK;
832 }
833 if ((i = (len & (size_t)-16))) {
834 size_t j = i;
835
836 while (len >= 16) {
837 size_t *out_t = (size_t *)out;
838 const size_t *in_t = (const size_t *)in;
839
840 (*block)(ctx->Yi.c, ctx->EKi.c, key);
841 ++ctr;
842 ctx->Yi.d[3] = htobe32(ctr);
843
844 for (i = 0; i < 16/sizeof(size_t); ++i)
845 out_t[i] = in_t[i] ^
846 ctx->EKi.t[i];
847 out += 16;
848 in += 16;
849 len -= 16;
850 }
851 GHASH(ctx, out - j, j);
852 }
853#else
854 while (len >= 16) {
855 size_t *out_t = (size_t *)out;
856 const size_t *in_t = (const size_t *)in;
857
858 (*block)(ctx->Yi.c, ctx->EKi.c, key);
859 ++ctr;
860 ctx->Yi.d[3] = htobe32(ctr);
861
862 for (i = 0; i < 16/sizeof(size_t); ++i)
863 ctx->Xi.t[i] ^=
864 out_t[i] = in_t[i] ^ ctx->EKi.t[i];
865 GCM_MUL(ctx, Xi);
866 out += 16;
867 in += 16;
868 len -= 16;
869 }
870#endif
871 if (len) {
872 (*block)(ctx->Yi.c, ctx->EKi.c, key);
873 ++ctr;
874 ctx->Yi.d[3] = htobe32(ctr);
875
876 while (len--) {
877 ctx->Xi.c[n] ^= out[n] = in[n] ^
878 ctx->EKi.c[n];
879 ++n;
880 }
881 }
882 363
883 ctx->mres = n; 364 for (i = 0; i < len; i++) {
884 return 0;
885 } while (0);
886 for (i = 0; i < len; ++i) {
887 if (n == 0) { 365 if (n == 0) {
888 (*block)(ctx->Yi.c, ctx->EKi.c, key); 366 ctx->block(ctx->Yi.c, ctx->EKi.c, ctx->key);
889 ++ctr; 367 ctx->Yi.d[3] = htobe32(++ctr);
890 ctx->Yi.d[3] = htobe32(ctr);
891 } 368 }
892 ctx->Xi.c[n] ^= out[i] = in[i] ^ ctx->EKi.c[n]; 369 ctx->Xi.c[n] ^= out[i] = in[i] ^ ctx->EKi.c[n];
893 n = (n + 1) % 16; 370 n = (n + 1) % 16;
894 if (n == 0) 371 if (n == 0)
895 GCM_MUL(ctx, Xi); 372 gcm_mul(ctx, ctx->Xi.u);
896 } 373 }
897 374
898 ctx->mres = n; 375 ctx->mres = n;
376
899 return 0; 377 return 0;
900} 378}
901LCRYPTO_ALIAS(CRYPTO_gcm128_encrypt); 379LCRYPTO_ALIAS(CRYPTO_gcm128_encrypt);
902 380
903int 381int
904CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, 382CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const unsigned char *in,
905 const unsigned char *in, unsigned char *out, 383 unsigned char *out, size_t len)
906 size_t len)
907{ 384{
908 unsigned int n, ctr; 385 unsigned int n, ctr;
386 uint64_t mlen;
387 uint8_t c;
909 size_t i; 388 size_t i;
910 u64 mlen = ctx->len.u[1];
911 block128_f block = ctx->block;
912 void *key = ctx->key;
913#ifdef GCM_FUNCREF_4BIT
914 void (*gcm_gmult_p)(u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
915# ifdef GHASH
916 void (*gcm_ghash_p)(u64 Xi[2], const u128 Htable[16],
917 const u8 *inp, size_t len) = ctx->ghash;
918# endif
919#endif
920 389
921 mlen += len; 390 mlen = ctx->len.u[1] + len;
922 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) 391 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len))
923 return -1; 392 return -1;
924 ctx->len.u[1] = mlen; 393 ctx->len.u[1] = mlen;
925 394
926 if (ctx->ares) { 395 if (ctx->ares) {
927 /* First call to decrypt finalizes GHASH(AAD) */ 396 /* First call to decrypt finalizes GHASH(AAD) */
928 GCM_MUL(ctx, Xi); 397 gcm_mul(ctx, ctx->Xi.u);
929 ctx->ares = 0; 398 ctx->ares = 0;
930 } 399 }
931 400
932 ctr = be32toh(ctx->Yi.d[3]); 401 ctr = be32toh(ctx->Yi.d[3]);
933 402
934 n = ctx->mres; 403 n = ctx->mres;
935 if (16 % sizeof(size_t) == 0)
936 do { /* always true actually */
937 if (n) {
938 while (n && len) {
939 u8 c = *(in++);
940 *(out++) = c ^ ctx->EKi.c[n];
941 ctx->Xi.c[n] ^= c;
942 --len;
943 n = (n + 1) % 16;
944 }
945 if (n == 0)
946 GCM_MUL(ctx, Xi);
947 else {
948 ctx->mres = n;
949 return 0;
950 }
951 }
952#ifdef __STRICT_ALIGNMENT
953 if (((size_t)in|(size_t)out) % sizeof(size_t) != 0)
954 break;
955#endif
956#if defined(GHASH) && defined(GHASH_CHUNK)
957 while (len >= GHASH_CHUNK) {
958 size_t j = GHASH_CHUNK;
959
960 GHASH(ctx, in, GHASH_CHUNK);
961 while (j) {
962 size_t *out_t = (size_t *)out;
963 const size_t *in_t = (const size_t *)in;
964
965 (*block)(ctx->Yi.c, ctx->EKi.c, key);
966 ++ctr;
967 ctx->Yi.d[3] = htobe32(ctr);
968
969 for (i = 0; i < 16/sizeof(size_t); ++i)
970 out_t[i] = in_t[i] ^
971 ctx->EKi.t[i];
972 out += 16;
973 in += 16;
974 j -= 16;
975 }
976 len -= GHASH_CHUNK;
977 }
978 if ((i = (len & (size_t)-16))) {
979 GHASH(ctx, in, i);
980 while (len >= 16) {
981 size_t *out_t = (size_t *)out;
982 const size_t *in_t = (const size_t *)in;
983
984 (*block)(ctx->Yi.c, ctx->EKi.c, key);
985 ++ctr;
986 ctx->Yi.d[3] = htobe32(ctr);
987
988 for (i = 0; i < 16/sizeof(size_t); ++i)
989 out_t[i] = in_t[i] ^
990 ctx->EKi.t[i];
991 out += 16;
992 in += 16;
993 len -= 16;
994 }
995 }
996#else
997 while (len >= 16) {
998 size_t *out_t = (size_t *)out;
999 const size_t *in_t = (const size_t *)in;
1000
1001 (*block)(ctx->Yi.c, ctx->EKi.c, key);
1002 ++ctr;
1003 ctx->Yi.d[3] = htobe32(ctr);
1004
1005 for (i = 0; i < 16/sizeof(size_t); ++i) {
1006 size_t c = in_t[i];
1007 out_t[i] = c ^ ctx->EKi.t[i];
1008 ctx->Xi.t[i] ^= c;
1009 }
1010 GCM_MUL(ctx, Xi);
1011 out += 16;
1012 in += 16;
1013 len -= 16;
1014 }
1015#endif
1016 if (len) {
1017 (*block)(ctx->Yi.c, ctx->EKi.c, key);
1018 ++ctr;
1019 ctx->Yi.d[3] = htobe32(ctr);
1020
1021 while (len--) {
1022 u8 c = in[n];
1023 ctx->Xi.c[n] ^= c;
1024 out[n] = c ^ ctx->EKi.c[n];
1025 ++n;
1026 }
1027 }
1028 404
1029 ctx->mres = n; 405 for (i = 0; i < len; i++) {
1030 return 0;
1031 } while (0);
1032 for (i = 0; i < len; ++i) {
1033 u8 c;
1034 if (n == 0) { 406 if (n == 0) {
1035 (*block)(ctx->Yi.c, ctx->EKi.c, key); 407 ctx->block(ctx->Yi.c, ctx->EKi.c, ctx->key);
1036 ++ctr; 408 ctx->Yi.d[3] = htobe32(++ctr);
1037 ctx->Yi.d[3] = htobe32(ctr);
1038 } 409 }
1039 c = in[i]; 410 c = in[i];
1040 out[i] = c ^ ctx->EKi.c[n]; 411 out[i] = c ^ ctx->EKi.c[n];
1041 ctx->Xi.c[n] ^= c; 412 ctx->Xi.c[n] ^= c;
1042 n = (n + 1) % 16; 413 n = (n + 1) % 16;
1043 if (n == 0) 414 if (n == 0)
1044 GCM_MUL(ctx, Xi); 415 gcm_mul(ctx, ctx->Xi.u);
1045 } 416 }
1046 417
1047 ctx->mres = n; 418 ctx->mres = n;
419
1048 return 0; 420 return 0;
1049} 421}
1050LCRYPTO_ALIAS(CRYPTO_gcm128_decrypt); 422LCRYPTO_ALIAS(CRYPTO_gcm128_decrypt);
1051 423
1052int 424int
1053CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, 425CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in,
1054 const unsigned char *in, unsigned char *out, 426 unsigned char *out, size_t len, ctr128_f stream)
1055 size_t len, ctr128_f stream)
1056{ 427{
1057 unsigned int n, ctr; 428 unsigned int n, ctr;
1058 size_t i; 429 uint64_t mlen;
1059 u64 mlen = ctx->len.u[1]; 430 size_t i, j;
1060 void *key = ctx->key;
1061#ifdef GCM_FUNCREF_4BIT
1062 void (*gcm_gmult_p)(u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
1063# ifdef GHASH
1064 void (*gcm_ghash_p)(u64 Xi[2], const u128 Htable[16],
1065 const u8 *inp, size_t len) = ctx->ghash;
1066# endif
1067#endif
1068 431
1069 mlen += len; 432 mlen = ctx->len.u[1] + len;
1070 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) 433 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len))
1071 return -1; 434 return -1;
1072 ctx->len.u[1] = mlen; 435 ctx->len.u[1] = mlen;
1073 436
1074 if (ctx->ares) { 437 if (ctx->ares > 0) {
1075 /* First call to encrypt finalizes GHASH(AAD) */ 438 /* First call to encrypt finalizes GHASH(AAD) */
1076 GCM_MUL(ctx, Xi); 439 gcm_mul(ctx, ctx->Xi.u);
1077 ctx->ares = 0; 440 ctx->ares = 0;
1078 } 441 }
1079 442
1080 ctr = be32toh(ctx->Yi.d[3]); 443 ctr = be32toh(ctx->Yi.d[3]);
1081 444
1082 n = ctx->mres; 445 if ((n = ctx->mres) > 0) {
1083 if (n) { 446 while (n > 0 && len > 0) {
1084 while (n && len) {
1085 ctx->Xi.c[n] ^= *(out++) = *(in++) ^ ctx->EKi.c[n]; 447 ctx->Xi.c[n] ^= *(out++) = *(in++) ^ ctx->EKi.c[n];
1086 --len;
1087 n = (n + 1) % 16; 448 n = (n + 1) % 16;
449 len--;
1088 } 450 }
1089 if (n == 0) 451 if (n > 0) {
1090 GCM_MUL(ctx, Xi);
1091 else {
1092 ctx->mres = n; 452 ctx->mres = n;
1093 return 0; 453 return 0;
1094 } 454 }
455 gcm_mul(ctx, ctx->Xi.u);
1095 } 456 }
1096#if defined(GHASH) && defined(GHASH_CHUNK) 457 if ((i = (len & (size_t)-16)) > 0) {
1097 while (len >= GHASH_CHUNK) { 458 j = i / 16;
1098 (*stream)(in, out, GHASH_CHUNK/16, key, ctx->Yi.c); 459 stream(in, out, j, ctx->key, ctx->Yi.c);
1099 ctr += GHASH_CHUNK/16;
1100 ctx->Yi.d[3] = htobe32(ctr);
1101 GHASH(ctx, out, GHASH_CHUNK);
1102 out += GHASH_CHUNK;
1103 in += GHASH_CHUNK;
1104 len -= GHASH_CHUNK;
1105 }
1106#endif
1107 if ((i = (len & (size_t)-16))) {
1108 size_t j = i/16;
1109
1110 (*stream)(in, out, j, key, ctx->Yi.c);
1111 ctr += (unsigned int)j; 460 ctr += (unsigned int)j;
1112 ctx->Yi.d[3] = htobe32(ctr); 461 ctx->Yi.d[3] = htobe32(ctr);
462 gcm_ghash(ctx, out, i);
1113 in += i; 463 in += i;
1114 len -= i;
1115#if defined(GHASH)
1116 GHASH(ctx, out, i);
1117 out += i; 464 out += i;
1118#else 465 len -= i;
1119 while (j--) {
1120 for (i = 0; i < 16; ++i)
1121 ctx->Xi.c[i] ^= out[i];
1122 GCM_MUL(ctx, Xi);
1123 out += 16;
1124 }
1125#endif
1126 } 466 }
1127 if (len) { 467 if (len > 0) {
1128 (*ctx->block)(ctx->Yi.c, ctx->EKi.c, key); 468 ctx->block(ctx->Yi.c, ctx->EKi.c, ctx->key);
1129 ++ctr; 469 ctx->Yi.d[3] = htobe32(++ctr);
1130 ctx->Yi.d[3] = htobe32(ctr); 470 while (len-- > 0) {
1131 while (len--) {
1132 ctx->Xi.c[n] ^= out[n] = in[n] ^ ctx->EKi.c[n]; 471 ctx->Xi.c[n] ^= out[n] = in[n] ^ ctx->EKi.c[n];
1133 ++n; 472 n++;
1134 } 473 }
1135 } 474 }
1136 475
1137 ctx->mres = n; 476 ctx->mres = n;
477
1138 return 0; 478 return 0;
1139} 479}
1140LCRYPTO_ALIAS(CRYPTO_gcm128_encrypt_ctr32); 480LCRYPTO_ALIAS(CRYPTO_gcm128_encrypt_ctr32);
1141 481
1142int 482int
1143CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, 483CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in,
1144 const unsigned char *in, unsigned char *out, 484 unsigned char *out, size_t len, ctr128_f stream)
1145 size_t len, ctr128_f stream)
1146{ 485{
1147 unsigned int n, ctr; 486 unsigned int n, ctr;
1148 size_t i; 487 uint64_t mlen;
1149 u64 mlen = ctx->len.u[1]; 488 size_t i, j;
1150 void *key = ctx->key; 489 uint8_t c;
1151#ifdef GCM_FUNCREF_4BIT
1152 void (*gcm_gmult_p)(u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
1153# ifdef GHASH
1154 void (*gcm_ghash_p)(u64 Xi[2], const u128 Htable[16],
1155 const u8 *inp, size_t len) = ctx->ghash;
1156# endif
1157#endif
1158 490
1159 mlen += len; 491 mlen = ctx->len.u[1] + len;
1160 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) 492 if (mlen > ((U64(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len))
1161 return -1; 493 return -1;
1162 ctx->len.u[1] = mlen; 494 ctx->len.u[1] = mlen;
1163 495
1164 if (ctx->ares) { 496 if (ctx->ares > 0) {
1165 /* First call to decrypt finalizes GHASH(AAD) */ 497 /* First call to decrypt finalizes GHASH(AAD) */
1166 GCM_MUL(ctx, Xi); 498 gcm_mul(ctx, ctx->Xi.u);
1167 ctx->ares = 0; 499 ctx->ares = 0;
1168 } 500 }
1169 501
1170 ctr = be32toh(ctx->Yi.d[3]); 502 ctr = be32toh(ctx->Yi.d[3]);
1171 503
1172 n = ctx->mres; 504 if ((n = ctx->mres) > 0) {
1173 if (n) { 505 while (n > 0 && len > 0) {
1174 while (n && len) { 506 c = *(in++);
1175 u8 c = *(in++);
1176 *(out++) = c ^ ctx->EKi.c[n]; 507 *(out++) = c ^ ctx->EKi.c[n];
1177 ctx->Xi.c[n] ^= c; 508 ctx->Xi.c[n] ^= c;
1178 --len;
1179 n = (n + 1) % 16; 509 n = (n + 1) % 16;
510 len--;
1180 } 511 }
1181 if (n == 0) 512 if (n > 0) {
1182 GCM_MUL(ctx, Xi);
1183 else {
1184 ctx->mres = n; 513 ctx->mres = n;
1185 return 0; 514 return 0;
1186 } 515 }
516 gcm_mul(ctx, ctx->Xi.u);
1187 } 517 }
1188#if defined(GHASH) && defined(GHASH_CHUNK) 518 if ((i = (len & (size_t)-16)) > 0) {
1189 while (len >= GHASH_CHUNK) { 519 j = i / 16;
1190 GHASH(ctx, in, GHASH_CHUNK); 520 gcm_ghash(ctx, in, i);
1191 (*stream)(in, out, GHASH_CHUNK/16, key, ctx->Yi.c); 521 stream(in, out, j, ctx->key, ctx->Yi.c);
1192 ctr += GHASH_CHUNK/16;
1193 ctx->Yi.d[3] = htobe32(ctr);
1194 out += GHASH_CHUNK;
1195 in += GHASH_CHUNK;
1196 len -= GHASH_CHUNK;
1197 }
1198#endif
1199 if ((i = (len & (size_t)-16))) {
1200 size_t j = i/16;
1201
1202#if defined(GHASH)
1203 GHASH(ctx, in, i);
1204#else
1205 while (j--) {
1206 size_t k;
1207 for (k = 0; k < 16; ++k)
1208 ctx->Xi.c[k] ^= in[k];
1209 GCM_MUL(ctx, Xi);
1210 in += 16;
1211 }
1212 j = i/16;
1213 in -= i;
1214#endif
1215 (*stream)(in, out, j, key, ctx->Yi.c);
1216 ctr += (unsigned int)j; 522 ctr += (unsigned int)j;
1217 ctx->Yi.d[3] = htobe32(ctr); 523 ctx->Yi.d[3] = htobe32(ctr);
1218 out += i;
1219 in += i; 524 in += i;
525 out += i;
1220 len -= i; 526 len -= i;
1221 } 527 }
1222 if (len) { 528 if (len > 0) {
1223 (*ctx->block)(ctx->Yi.c, ctx->EKi.c, key); 529 ctx->block(ctx->Yi.c, ctx->EKi.c, ctx->key);
1224 ++ctr; 530 ctx->Yi.d[3] = htobe32(++ctr);
1225 ctx->Yi.d[3] = htobe32(ctr); 531 while (len-- > 0) {
1226 while (len--) { 532 c = in[n];
1227 u8 c = in[n];
1228 ctx->Xi.c[n] ^= c; 533 ctx->Xi.c[n] ^= c;
1229 out[n] = c ^ ctx->EKi.c[n]; 534 out[n] = c ^ ctx->EKi.c[n];
1230 ++n; 535 n++;
1231 } 536 }
1232 } 537 }
1233 538
1234 ctx->mres = n; 539 ctx->mres = n;
540
1235 return 0; 541 return 0;
1236} 542}
1237LCRYPTO_ALIAS(CRYPTO_gcm128_decrypt_ctr32); 543LCRYPTO_ALIAS(CRYPTO_gcm128_decrypt_ctr32);
@@ -1240,26 +546,25 @@ int
1240CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag, 546CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,
1241 size_t len) 547 size_t len)
1242{ 548{
1243 u64 alen = ctx->len.u[0] << 3; 549 uint64_t alen, clen;
1244 u64 clen = ctx->len.u[1] << 3;
1245#ifdef GCM_FUNCREF_4BIT
1246 void (*gcm_gmult_p)(u64 Xi[2], const u128 Htable[16]) = ctx->gmult;
1247#endif
1248 550
1249 if (ctx->mres || ctx->ares) 551 alen = ctx->len.u[0] << 3;
1250 GCM_MUL(ctx, Xi); 552 clen = ctx->len.u[1] << 3;
553
554 if (ctx->ares > 0 || ctx->mres > 0)
555 gcm_mul(ctx, ctx->Xi.u);
1251 556
1252 ctx->Xi.u[0] ^= htobe64(alen); 557 ctx->Xi.u[0] ^= htobe64(alen);
1253 ctx->Xi.u[1] ^= htobe64(clen); 558 ctx->Xi.u[1] ^= htobe64(clen);
1254 GCM_MUL(ctx, Xi); 559 gcm_mul(ctx, ctx->Xi.u);
1255 560
1256 ctx->Xi.u[0] ^= ctx->EK0.u[0]; 561 ctx->Xi.u[0] ^= ctx->EK0.u[0];
1257 ctx->Xi.u[1] ^= ctx->EK0.u[1]; 562 ctx->Xi.u[1] ^= ctx->EK0.u[1];
1258 563
1259 if (tag && len <= sizeof(ctx->Xi)) 564 if (tag == NULL || len > sizeof(ctx->Xi))
1260 return memcmp(ctx->Xi.c, tag, len);
1261 else
1262 return -1; 565 return -1;
566
567 return timingsafe_memcmp(ctx->Xi.c, tag, len);
1263} 568}
1264LCRYPTO_ALIAS(CRYPTO_gcm128_finish); 569LCRYPTO_ALIAS(CRYPTO_gcm128_finish);
1265 570
@@ -1267,26 +572,10 @@ void
1267CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len) 572CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len)
1268{ 573{
1269 CRYPTO_gcm128_finish(ctx, NULL, 0); 574 CRYPTO_gcm128_finish(ctx, NULL, 0);
1270 memcpy(tag, ctx->Xi.c,
1271 len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c));
1272}
1273LCRYPTO_ALIAS(CRYPTO_gcm128_tag);
1274 575
1275GCM128_CONTEXT * 576 if (len > sizeof(ctx->Xi.c))
1276CRYPTO_gcm128_new(void *key, block128_f block) 577 len = sizeof(ctx->Xi.c);
1277{
1278 GCM128_CONTEXT *ret;
1279
1280 if ((ret = malloc(sizeof(GCM128_CONTEXT))))
1281 CRYPTO_gcm128_init(ret, key, block);
1282
1283 return ret;
1284}
1285LCRYPTO_ALIAS(CRYPTO_gcm128_new);
1286 578
1287void 579 memcpy(tag, ctx->Xi.c, len);
1288CRYPTO_gcm128_release(GCM128_CONTEXT *ctx)
1289{
1290 freezero(ctx, sizeof(*ctx));
1291} 580}
1292LCRYPTO_ALIAS(CRYPTO_gcm128_release); 581LCRYPTO_ALIAS(CRYPTO_gcm128_tag);
diff --git a/src/lib/libcrypto/modes/gcm128_amd64.c b/src/lib/libcrypto/modes/gcm128_amd64.c
new file mode 100644
index 0000000000..eaa66fb32f
--- /dev/null
+++ b/src/lib/libcrypto/modes/gcm128_amd64.c
@@ -0,0 +1,44 @@
1/* $OpenBSD: gcm128_amd64.c,v 1.1 2025/06/28 12:39:10 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include "crypto_arch.h"
19#include "modes_local.h"
20
21void gcm_init_4bit(u128 Htable[16], uint64_t H[2]);
22void gcm_gmult_4bit(uint64_t Xi[2], const u128 Htable[16]);
23void gcm_ghash_4bit(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
24 size_t len);
25
26void gcm_init_clmul(u128 Htable[16], const uint64_t Xi[2]);
27void gcm_gmult_clmul(uint64_t Xi[2], const u128 Htable[16]);
28void gcm_ghash_clmul(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
29 size_t len);
30
31void
32gcm128_init(GCM128_CONTEXT *ctx)
33{
34 if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_CLMUL) != 0) {
35 gcm_init_clmul(ctx->Htable, ctx->H.u);
36 ctx->gmult = gcm_gmult_clmul;
37 ctx->ghash = gcm_ghash_clmul;
38 return;
39 }
40
41 gcm_init_4bit(ctx->Htable, ctx->H.u);
42 ctx->gmult = gcm_gmult_4bit;
43 ctx->ghash = gcm_ghash_4bit;
44}
diff --git a/src/lib/libcrypto/modes/gcm128_i386.c b/src/lib/libcrypto/modes/gcm128_i386.c
new file mode 100644
index 0000000000..ac517fdb04
--- /dev/null
+++ b/src/lib/libcrypto/modes/gcm128_i386.c
@@ -0,0 +1,56 @@
1/* $OpenBSD: gcm128_i386.c,v 1.1 2025/06/28 12:39:10 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include "crypto_arch.h"
19#include "modes_local.h"
20
21void gcm_init_4bit(u128 Htable[16], uint64_t H[2]);
22
23void gcm_gmult_4bit_mmx(uint64_t Xi[2], const u128 Htable[16]);
24void gcm_ghash_4bit_mmx(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
25 size_t len);
26
27void gcm_gmult_4bit_x86(uint64_t Xi[2], const u128 Htable[16]);
28void gcm_ghash_4bit_x86(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
29 size_t len);
30
31void gcm_init_clmul(u128 Htable[16], const uint64_t Xi[2]);
32void gcm_gmult_clmul(uint64_t Xi[2], const u128 Htable[16]);
33void gcm_ghash_clmul(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
34 size_t len);
35
36void
37gcm128_init(GCM128_CONTEXT *ctx)
38{
39 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_CLMUL) != 0) {
40 gcm_init_clmul(ctx->Htable, ctx->H.u);
41 ctx->gmult = gcm_gmult_clmul;
42 ctx->ghash = gcm_ghash_clmul;
43 return;
44 }
45
46 if ((crypto_cpu_caps_i386 & CRYPTO_CPU_CAPS_I386_MMX) != 0) {
47 gcm_init_4bit(ctx->Htable, ctx->H.u);
48 ctx->gmult = gcm_gmult_4bit_mmx;
49 ctx->ghash = gcm_ghash_4bit_mmx;
50 return;
51 }
52
53 gcm_init_4bit(ctx->Htable, ctx->H.u);
54 ctx->gmult = gcm_gmult_4bit_x86;
55 ctx->ghash = gcm_ghash_4bit_x86;
56}
diff --git a/src/lib/libcrypto/modes/modes_local.h b/src/lib/libcrypto/modes/modes_local.h
index c04db034d0..5c1acfc25f 100644
--- a/src/lib/libcrypto/modes/modes_local.h
+++ b/src/lib/libcrypto/modes/modes_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: modes_local.h,v 1.4 2025/04/23 14:15:19 jsing Exp $ */ 1/* $OpenBSD: modes_local.h,v 1.7 2025/07/13 06:01:33 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -15,67 +15,47 @@
15__BEGIN_HIDDEN_DECLS 15__BEGIN_HIDDEN_DECLS
16 16
17#if defined(_LP64) 17#if defined(_LP64)
18typedef long i64;
19typedef unsigned long u64;
20#define U64(C) C##UL 18#define U64(C) C##UL
21#else 19#else
22typedef long long i64;
23typedef unsigned long long u64;
24#define U64(C) C##ULL 20#define U64(C) C##ULL
25#endif 21#endif
26 22
27typedef unsigned int u32;
28typedef unsigned char u8;
29
30/* GCM definitions */ 23/* GCM definitions */
31 24
32typedef struct { 25typedef struct {
33 u64 hi, lo; 26 uint64_t hi, lo;
34} u128; 27} u128;
35 28
36#ifdef TABLE_BITS
37#undef TABLE_BITS
38#endif
39/*
40 * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should
41 * never be set to 8 [or 1]. For further information see gcm128.c.
42 */
43#define TABLE_BITS 4
44
45struct gcm128_context { 29struct gcm128_context {
46 /* Following 6 names follow names in GCM specification */ 30 /* Following 6 names follow names in GCM specification */
47 union { 31 union {
48 u64 u[2]; 32 uint64_t u[2];
49 u32 d[4]; 33 uint32_t d[4];
50 u8 c[16]; 34 uint8_t c[16];
51 size_t t[16/sizeof(size_t)]; 35 size_t t[16/sizeof(size_t)];
52 } Yi, EKi, EK0, len, Xi, H; 36 } Yi, EKi, EK0, len, Xi, H;
53 /* Relative position of Xi, H and pre-computed Htable is used 37 /* Relative position of Xi, H and pre-computed Htable is used
54 * in some assembler modules, i.e. don't change the order! */ 38 * in some assembler modules, i.e. don't change the order! */
55#if TABLE_BITS==8
56 u128 Htable[256];
57#else
58 u128 Htable[16]; 39 u128 Htable[16];
59 void (*gmult)(u64 Xi[2], const u128 Htable[16]); 40 void (*gmult)(uint64_t Xi[2], const u128 Htable[16]);
60 void (*ghash)(u64 Xi[2], const u128 Htable[16], const u8 *inp, 41 void (*ghash)(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp,
61 size_t len); 42 size_t len);
62#endif
63 unsigned int mres, ares; 43 unsigned int mres, ares;
64 block128_f block; 44 block128_f block;
65 void *key; 45 void *key;
66}; 46};
67 47
68struct xts128_context { 48struct xts128_context {
69 void *key1, *key2; 49 const void *key1, *key2;
70 block128_f block1, block2; 50 block128_f block1, block2;
71}; 51};
72 52
73struct ccm128_context { 53struct ccm128_context {
74 union { 54 union {
75 u64 u[2]; 55 uint64_t u[2];
76 u8 c[16]; 56 uint8_t c[16];
77 } nonce, cmac; 57 } nonce, cmac;
78 u64 blocks; 58 uint64_t blocks;
79 block128_f block; 59 block128_f block;
80 void *key; 60 void *key;
81}; 61};
diff --git a/src/lib/libcrypto/modes/xts128.c b/src/lib/libcrypto/modes/xts128.c
index 789af9ef65..9c863e73d6 100644
--- a/src/lib/libcrypto/modes/xts128.c
+++ b/src/lib/libcrypto/modes/xts128.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xts128.c,v 1.14 2025/04/21 16:01:18 jsing Exp $ */ 1/* $OpenBSD: xts128.c,v 1.15 2025/05/18 09:05:59 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -61,9 +61,9 @@ CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
61 size_t len, int enc) 61 size_t len, int enc)
62{ 62{
63 union { 63 union {
64 u64 u[2]; 64 uint64_t u[2];
65 u32 d[4]; 65 uint32_t d[4];
66 u8 c[16]; 66 uint8_t c[16];
67 } tweak, scratch; 67 } tweak, scratch;
68 unsigned int i; 68 unsigned int i;
69 69
@@ -83,8 +83,8 @@ CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
83 scratch.u[0] ^= tweak.u[0]; 83 scratch.u[0] ^= tweak.u[0];
84 scratch.u[1] ^= tweak.u[1]; 84 scratch.u[1] ^= tweak.u[1];
85#else 85#else
86 scratch.u[0] = ((u64 *)inp)[0] ^ tweak.u[0]; 86 scratch.u[0] = ((uint64_t *)inp)[0] ^ tweak.u[0];
87 scratch.u[1] = ((u64 *)inp)[1] ^ tweak.u[1]; 87 scratch.u[1] = ((uint64_t *)inp)[1] ^ tweak.u[1];
88#endif 88#endif
89 (*ctx->block1)(scratch.c, scratch.c, ctx->key1); 89 (*ctx->block1)(scratch.c, scratch.c, ctx->key1);
90#ifdef __STRICT_ALIGNMENT 90#ifdef __STRICT_ALIGNMENT
@@ -92,8 +92,8 @@ CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
92 scratch.u[1] ^= tweak.u[1]; 92 scratch.u[1] ^= tweak.u[1];
93 memcpy(out, scratch.c, 16); 93 memcpy(out, scratch.c, 16);
94#else 94#else
95 ((u64 *)out)[0] = scratch.u[0] ^= tweak.u[0]; 95 ((uint64_t *)out)[0] = scratch.u[0] ^= tweak.u[0];
96 ((u64 *)out)[1] = scratch.u[1] ^= tweak.u[1]; 96 ((uint64_t *)out)[1] = scratch.u[1] ^= tweak.u[1];
97#endif 97#endif
98 inp += 16; 98 inp += 16;
99 out += 16; 99 out += 16;
@@ -115,15 +115,15 @@ CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
115 for (c = 0, i = 0; i < 16; ++i) { 115 for (c = 0, i = 0; i < 16; ++i) {
116 /*+ substitutes for |, because c is 1 bit */ 116 /*+ substitutes for |, because c is 1 bit */
117 c += ((size_t)tweak.c[i]) << 1; 117 c += ((size_t)tweak.c[i]) << 1;
118 tweak.c[i] = (u8)c; 118 tweak.c[i] = (uint8_t)c;
119 c = c >> 8; 119 c = c >> 8;
120 } 120 }
121 tweak.c[0] ^= (u8)(0x87 & (0 - c)); 121 tweak.c[0] ^= (uint8_t)(0x87 & (0 - c));
122#endif 122#endif
123 } 123 }
124 if (enc) { 124 if (enc) {
125 for (i = 0; i < len; ++i) { 125 for (i = 0; i < len; ++i) {
126 u8 ch = inp[i]; 126 uint8_t ch = inp[i];
127 out[i] = scratch.c[i]; 127 out[i] = scratch.c[i];
128 scratch.c[i] = ch; 128 scratch.c[i] = ch;
129 } 129 }
@@ -135,8 +135,8 @@ CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
135 memcpy(out - 16, scratch.c, 16); 135 memcpy(out - 16, scratch.c, 16);
136 } else { 136 } else {
137 union { 137 union {
138 u64 u[2]; 138 uint64_t u[2];
139 u8 c[16]; 139 uint8_t c[16];
140 } tweak1; 140 } tweak1;
141 141
142#if BYTE_ORDER == LITTLE_ENDIAN 142#if BYTE_ORDER == LITTLE_ENDIAN
@@ -152,25 +152,25 @@ CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
152 for (c = 0, i = 0; i < 16; ++i) { 152 for (c = 0, i = 0; i < 16; ++i) {
153 /*+ substitutes for |, because c is 1 bit */ 153 /*+ substitutes for |, because c is 1 bit */
154 c += ((size_t)tweak.c[i]) << 1; 154 c += ((size_t)tweak.c[i]) << 1;
155 tweak1.c[i] = (u8)c; 155 tweak1.c[i] = (uint8_t)c;
156 c = c >> 8; 156 c = c >> 8;
157 } 157 }
158 tweak1.c[0] ^= (u8)(0x87 & (0 - c)); 158 tweak1.c[0] ^= (uint8_t)(0x87 & (0 - c));
159#endif 159#endif
160#ifdef __STRICT_ALIGNMENT 160#ifdef __STRICT_ALIGNMENT
161 memcpy(scratch.c, inp, 16); 161 memcpy(scratch.c, inp, 16);
162 scratch.u[0] ^= tweak1.u[0]; 162 scratch.u[0] ^= tweak1.u[0];
163 scratch.u[1] ^= tweak1.u[1]; 163 scratch.u[1] ^= tweak1.u[1];
164#else 164#else
165 scratch.u[0] = ((u64 *)inp)[0] ^ tweak1.u[0]; 165 scratch.u[0] = ((uint64_t *)inp)[0] ^ tweak1.u[0];
166 scratch.u[1] = ((u64 *)inp)[1] ^ tweak1.u[1]; 166 scratch.u[1] = ((uint64_t *)inp)[1] ^ tweak1.u[1];
167#endif 167#endif
168 (*ctx->block1)(scratch.c, scratch.c, ctx->key1); 168 (*ctx->block1)(scratch.c, scratch.c, ctx->key1);
169 scratch.u[0] ^= tweak1.u[0]; 169 scratch.u[0] ^= tweak1.u[0];
170 scratch.u[1] ^= tweak1.u[1]; 170 scratch.u[1] ^= tweak1.u[1];
171 171
172 for (i = 0; i < len; ++i) { 172 for (i = 0; i < len; ++i) {
173 u8 ch = inp[16 + i]; 173 uint8_t ch = inp[16 + i];
174 out[16 + i] = scratch.c[i]; 174 out[16 + i] = scratch.c[i];
175 scratch.c[i] = ch; 175 scratch.c[i] = ch;
176 } 176 }
@@ -182,8 +182,8 @@ CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
182 scratch.u[1] ^= tweak.u[1]; 182 scratch.u[1] ^= tweak.u[1];
183 memcpy(out, scratch.c, 16); 183 memcpy(out, scratch.c, 16);
184#else 184#else
185 ((u64 *)out)[0] = scratch.u[0] ^ tweak.u[0]; 185 ((uint64_t *)out)[0] = scratch.u[0] ^ tweak.u[0];
186 ((u64 *)out)[1] = scratch.u[1] ^ tweak.u[1]; 186 ((uint64_t *)out)[1] = scratch.u[1] ^ tweak.u[1];
187#endif 187#endif
188 } 188 }
189 189
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 2f4012fe15..d4da6be52c 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_dat.c,v 1.94 2025/02/26 10:48:25 tb Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.95 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -66,11 +66,11 @@
66 66
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68#include <openssl/bn.h> 68#include <openssl/bn.h>
69#include <openssl/err.h>
70#include <openssl/lhash.h> 69#include <openssl/lhash.h>
71#include <openssl/objects.h> 70#include <openssl/objects.h>
72 71
73#include "asn1_local.h" 72#include "asn1_local.h"
73#include "err_local.h"
74 74
75/* obj_dat.h is generated from objects.h by obj_dat.pl */ 75/* obj_dat.h is generated from objects.h by obj_dat.pl */
76#include "obj_dat.h" 76#include "obj_dat.h"
diff --git a/src/lib/libcrypto/objects/obj_lib.c b/src/lib/libcrypto/objects/obj_lib.c
index 45062dbd4c..56b0b10423 100644
--- a/src/lib/libcrypto/objects/obj_lib.c
+++ b/src/lib/libcrypto/objects/obj_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_lib.c,v 1.19 2023/08/17 09:13:01 tb Exp $ */ 1/* $OpenBSD: obj_lib.c,v 1.20 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,12 +59,12 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/err.h>
63#include <openssl/buffer.h> 62#include <openssl/buffer.h>
64#include <openssl/lhash.h> 63#include <openssl/lhash.h>
65#include <openssl/objects.h> 64#include <openssl/objects.h>
66 65
67#include "asn1_local.h" 66#include "asn1_local.h"
67#include "err_local.h"
68 68
69ASN1_OBJECT * 69ASN1_OBJECT *
70OBJ_dup(const ASN1_OBJECT *o) 70OBJ_dup(const ASN1_OBJECT *o)
diff --git a/src/lib/libcrypto/objects/obj_mac.num b/src/lib/libcrypto/objects/obj_mac.num
index 728bf02400..124aafec77 100644
--- a/src/lib/libcrypto/objects/obj_mac.num
+++ b/src/lib/libcrypto/objects/obj_mac.num
@@ -1053,3 +1053,6 @@ RSA_SHA3_512 1052
1053acmeIdentifier 1053 1053acmeIdentifier 1053
1054id_ct_rpkiSignedPrefixList 1054 1054id_ct_rpkiSignedPrefixList 1054
1055tls1_prf 1055 1055tls1_prf 1055
1056MLKEM768_X25519 1056
1057MLKEM768_ECDH_P256 1057
1058MLKEM768_ECDH_P384 1058
diff --git a/src/lib/libcrypto/objects/objects.txt b/src/lib/libcrypto/objects/objects.txt
index 4d5a52efcf..bdf6ea9fe3 100644
--- a/src/lib/libcrypto/objects/objects.txt
+++ b/src/lib/libcrypto/objects/objects.txt
@@ -1477,3 +1477,9 @@ tc26 1 3 3 : id-tc26-signwithdigest-gost3410-2012-512 : GOST R 34.11-2012 with
1477 : AuthECDSA : auth-ecdsa 1477 : AuthECDSA : auth-ecdsa
1478 : AuthGOST01 : auth-gost01 1478 : AuthGOST01 : auth-gost01
1479 : AuthNULL : auth-null 1479 : AuthNULL : auth-null
1480
1481# Hybrid KEMs from
1482# https://www.ietf.org/archive/id/draft-ietf-lamps-pq-composite-kem-06.html#section-7.1
14832 16 840 1 114027 80 5 2 33 : MLKEM768-X25519
14842 16 840 1 114027 80 5 2 34 : MLKEM768-ECDH-P256
14852 16 840 1 114027 80 5 2 35 : MLKEM768-ECDH-P384
diff --git a/src/lib/libcrypto/ocsp/ocsp_cl.c b/src/lib/libcrypto/ocsp/ocsp_cl.c
index d8ee33c391..460c1bce5e 100644
--- a/src/lib/libcrypto/ocsp/ocsp_cl.c
+++ b/src/lib/libcrypto/ocsp/ocsp_cl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_cl.c,v 1.25 2024/03/24 11:30:12 beck Exp $ */ 1/* $OpenBSD: ocsp_cl.c,v 1.26 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL 2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */ 3 * project. */
4 4
@@ -64,7 +64,6 @@
64#include <stdio.h> 64#include <stdio.h>
65#include <time.h> 65#include <time.h>
66 66
67#include <openssl/err.h>
68#include <openssl/ocsp.h> 67#include <openssl/ocsp.h>
69#include <openssl/objects.h> 68#include <openssl/objects.h>
70#include <openssl/pem.h> 69#include <openssl/pem.h>
@@ -73,6 +72,7 @@
73#include <openssl/x509v3.h> 72#include <openssl/x509v3.h>
74 73
75#include "asn1_local.h" 74#include "asn1_local.h"
75#include "err_local.h"
76#include "ocsp_local.h" 76#include "ocsp_local.h"
77 77
78/* Utility functions related to sending OCSP requests and extracting 78/* Utility functions related to sending OCSP requests and extracting
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index 69723c2154..db83b35518 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_ht.c,v 1.27 2023/11/28 09:29:20 jsg Exp $ */ 1/* $OpenBSD: ocsp_ht.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -60,11 +60,13 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <ctype.h> 61#include <ctype.h>
62#include <string.h> 62#include <string.h>
63
63#include <openssl/asn1.h> 64#include <openssl/asn1.h>
64#include <openssl/ocsp.h> 65#include <openssl/ocsp.h>
65#include <openssl/err.h>
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67 67
68#include "err_local.h"
69
68/* Stateful OCSP request code, supporting non-blocking I/O */ 70/* Stateful OCSP request code, supporting non-blocking I/O */
69 71
70/* Opaque OCSP request status structure */ 72/* Opaque OCSP request status structure */
diff --git a/src/lib/libcrypto/ocsp/ocsp_lib.c b/src/lib/libcrypto/ocsp/ocsp_lib.c
index 521fb67aed..dfa002a594 100644
--- a/src/lib/libcrypto/ocsp/ocsp_lib.c
+++ b/src/lib/libcrypto/ocsp/ocsp_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_lib.c,v 1.28 2024/08/28 06:27:19 tb Exp $ */ 1/* $OpenBSD: ocsp_lib.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL 2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */ 3 * project. */
4 4
@@ -67,13 +67,13 @@
67#include <openssl/opensslconf.h> 67#include <openssl/opensslconf.h>
68 68
69#include <openssl/asn1t.h> 69#include <openssl/asn1t.h>
70#include <openssl/err.h>
71#include <openssl/objects.h> 70#include <openssl/objects.h>
72#include <openssl/ocsp.h> 71#include <openssl/ocsp.h>
73#include <openssl/pem.h> 72#include <openssl/pem.h>
74#include <openssl/x509.h> 73#include <openssl/x509.h>
75#include <openssl/x509v3.h> 74#include <openssl/x509v3.h>
76 75
76#include "err_local.h"
77#include "ocsp_local.h" 77#include "ocsp_local.h"
78#include "x509_local.h" 78#include "x509_local.h"
79 79
diff --git a/src/lib/libcrypto/ocsp/ocsp_prn.c b/src/lib/libcrypto/ocsp/ocsp_prn.c
index fb7b9651d9..537d5e3d20 100644
--- a/src/lib/libcrypto/ocsp/ocsp_prn.c
+++ b/src/lib/libcrypto/ocsp/ocsp_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_prn.c,v 1.11 2024/08/28 06:18:44 tb Exp $ */ 1/* $OpenBSD: ocsp_prn.c,v 1.12 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL 2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */ 3 * project. */
4 4
@@ -62,7 +62,6 @@
62 */ 62 */
63 63
64#include <openssl/bio.h> 64#include <openssl/bio.h>
65#include <openssl/err.h>
66#include <openssl/ocsp.h> 65#include <openssl/ocsp.h>
67#include <openssl/pem.h> 66#include <openssl/pem.h>
68#include <openssl/x509.h> 67#include <openssl/x509.h>
diff --git a/src/lib/libcrypto/ocsp/ocsp_srv.c b/src/lib/libcrypto/ocsp/ocsp_srv.c
index 77c5e2e0fd..4b1d73d7ac 100644
--- a/src/lib/libcrypto/ocsp/ocsp_srv.c
+++ b/src/lib/libcrypto/ocsp/ocsp_srv.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_srv.c,v 1.13 2023/07/08 10:44:00 beck Exp $ */ 1/* $OpenBSD: ocsp_srv.c,v 1.14 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -58,13 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/objects.h> 61#include <openssl/objects.h>
63#include <openssl/ocsp.h> 62#include <openssl/ocsp.h>
64#include <openssl/pem.h> 63#include <openssl/pem.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "ocsp_local.h" 68#include "ocsp_local.h"
69 69
70/* Utility functions related to sending OCSP responses and extracting 70/* Utility functions related to sending OCSP responses and extracting
diff --git a/src/lib/libcrypto/ocsp/ocsp_vfy.c b/src/lib/libcrypto/ocsp/ocsp_vfy.c
index 27d2283ea7..185839f465 100644
--- a/src/lib/libcrypto/ocsp/ocsp_vfy.c
+++ b/src/lib/libcrypto/ocsp/ocsp_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_vfy.c,v 1.24 2024/07/12 18:15:10 beck Exp $ */ 1/* $OpenBSD: ocsp_vfy.c,v 1.25 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -57,9 +57,9 @@
57 */ 57 */
58 58
59#include <openssl/ocsp.h> 59#include <openssl/ocsp.h>
60#include <openssl/err.h>
61#include <string.h> 60#include <string.h>
62 61
62#include "err_local.h"
63#include "ocsp_local.h" 63#include "ocsp_local.h"
64#include "x509_local.h" 64#include "x509_local.h"
65 65
diff --git a/src/lib/libcrypto/pem/pem.h b/src/lib/libcrypto/pem/pem.h
index 4fdab48bb2..709e17308b 100644
--- a/src/lib/libcrypto/pem/pem.h
+++ b/src/lib/libcrypto/pem/pem.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem.h,v 1.28 2024/05/11 05:41:28 tb Exp $ */ 1/* $OpenBSD: pem.h,v 1.29 2025/07/16 15:59:26 tb Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -338,8 +338,6 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,
338 338
339STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, 339STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp,
340 STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); 340 STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
341int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
342 unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
343#endif 341#endif
344 342
345int PEM_read(FILE *fp, char **name, char **header, 343int PEM_read(FILE *fp, char **name, char **header,
@@ -351,8 +349,6 @@ void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
351int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, 349int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
352 void *x, const EVP_CIPHER *enc, unsigned char *kstr, 350 void *x, const EVP_CIPHER *enc, unsigned char *kstr,
353 int klen, pem_password_cb *callback, void *u); 351 int klen, pem_password_cb *callback, void *u);
354STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
355 pem_password_cb *cb, void *u);
356 352
357int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); 353int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
358int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt); 354int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index b979c79b33..26061f6f08 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_info.c,v 1.27 2023/07/07 13:40:44 beck Exp $ */ 1/* $OpenBSD: pem_info.c,v 1.33 2025/07/16 15:59:26 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -57,43 +57,81 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h>
60#include <string.h> 61#include <string.h>
61 62
62#include <openssl/opensslconf.h> 63#include <openssl/opensslconf.h>
63 64
64#include <openssl/buffer.h> 65#include <openssl/asn1.h>
66#include <openssl/bio.h>
67#include <openssl/crypto.h>
68#include <openssl/dsa.h>
69#include <openssl/ec.h>
65#include <openssl/err.h> 70#include <openssl/err.h>
66#include <openssl/evp.h> 71#include <openssl/evp.h>
67#include <openssl/objects.h> 72#include <openssl/objects.h>
68#include <openssl/pem.h> 73#include <openssl/pem.h>
69#include <openssl/x509.h>
70
71#ifndef OPENSSL_NO_DSA
72#include <openssl/dsa.h>
73#endif
74#ifndef OPENSSL_NO_RSA
75#include <openssl/rsa.h> 74#include <openssl/rsa.h>
76#endif 75#include <openssl/x509.h>
77 76
77#include "err_local.h"
78#include "evp_local.h" 78#include "evp_local.h"
79 79
80STACK_OF(X509_INFO) * 80X509_PKEY *
81PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, 81X509_PKEY_new(void)
82 void *u) 82{
83 X509_PKEY *x_pkey;
84
85 if ((x_pkey = calloc(1, sizeof(*x_pkey))) == NULL) {
86 ASN1error(ERR_R_MALLOC_FAILURE);
87 return NULL;
88 }
89
90 return x_pkey;
91}
92
93void
94X509_PKEY_free(X509_PKEY *x_pkey)
95{
96 if (x_pkey == NULL)
97 return;
98
99 EVP_PKEY_free(x_pkey->dec_pkey);
100 free(x_pkey);
101}
102
103X509_INFO *
104X509_INFO_new(void)
83{ 105{
84 BIO *b; 106 X509_INFO *ret;
85 STACK_OF(X509_INFO) *ret;
86 107
87 if ((b = BIO_new(BIO_s_file())) == NULL) { 108 if ((ret = calloc(1, sizeof(X509_INFO))) == NULL) {
88 PEMerror(ERR_R_BUF_LIB); 109 ASN1error(ERR_R_MALLOC_FAILURE);
89 return (0); 110 return NULL;
90 } 111 }
91 BIO_set_fp(b, fp, BIO_NOCLOSE); 112 ret->references = 1;
92 ret = PEM_X509_INFO_read_bio(b, sk, cb, u); 113
93 BIO_free(b); 114 return ret;
94 return (ret); 115}
116LCRYPTO_ALIAS(X509_INFO_new);
117
118void
119X509_INFO_free(X509_INFO *x)
120{
121 if (x == NULL)
122 return;
123
124 if (CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_INFO) > 0)
125 return;
126
127 X509_free(x->x509);
128 X509_CRL_free(x->crl);
129 X509_PKEY_free(x->x_pkey);
130 free(x->enc_data);
131
132 free(x);
95} 133}
96LCRYPTO_ALIAS(PEM_X509_INFO_read); 134LCRYPTO_ALIAS(X509_INFO_free);
97 135
98STACK_OF(X509_INFO) * 136STACK_OF(X509_INFO) *
99PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, 137PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb,
@@ -290,98 +328,3 @@ err:
290 return ret; 328 return ret;
291} 329}
292LCRYPTO_ALIAS(PEM_X509_INFO_read_bio); 330LCRYPTO_ALIAS(PEM_X509_INFO_read_bio);
293
294
295/* A TJH addition */
296int
297PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
298 unsigned char *kstr, int klen, pem_password_cb *cb, void *u)
299{
300 EVP_CIPHER_CTX ctx;
301 int i, ret = 0;
302 unsigned char *data = NULL;
303 const char *objstr = NULL;
304 char buf[PEM_BUFSIZE];
305 unsigned char *iv = NULL;
306
307 if (enc != NULL) {
308 objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc));
309 if (objstr == NULL) {
310 PEMerror(PEM_R_UNSUPPORTED_CIPHER);
311 goto err;
312 }
313 }
314
315 /* now for the fun part ... if we have a private key then
316 * we have to be able to handle a not-yet-decrypted key
317 * being written out correctly ... if it is decrypted or
318 * it is non-encrypted then we use the base code
319 */
320 if (xi->x_pkey != NULL) {
321 if ((xi->enc_data != NULL) && (xi->enc_len > 0) ) {
322 if (enc == NULL) {
323 PEMerror(PEM_R_CIPHER_IS_NULL);
324 goto err;
325 }
326
327 /* copy from weirdo names into more normal things */
328 iv = xi->enc_cipher.iv;
329 data = (unsigned char *)xi->enc_data;
330 i = xi->enc_len;
331
332 /* we take the encryption data from the
333 * internal stuff rather than what the
334 * user has passed us ... as we have to
335 * match exactly for some strange reason
336 */
337 objstr = OBJ_nid2sn(
338 EVP_CIPHER_nid(xi->enc_cipher.cipher));
339 if (objstr == NULL) {
340 PEMerror(PEM_R_UNSUPPORTED_CIPHER);
341 goto err;
342 }
343
344 /* create the right magic header stuff */
345 if (strlen(objstr) + 23 + 2 * enc->iv_len + 13 >
346 sizeof buf) {
347 PEMerror(ASN1_R_BUFFER_TOO_SMALL);
348 goto err;
349 }
350 buf[0] = '\0';
351 PEM_proc_type(buf, PEM_TYPE_ENCRYPTED);
352 PEM_dek_info(buf, objstr, enc->iv_len, (char *)iv);
353
354 /* use the normal code to write things out */
355 i = PEM_write_bio(bp, PEM_STRING_RSA, buf, data, i);
356 if (i <= 0)
357 goto err;
358 } else {
359 /* Add DSA/DH */
360#ifndef OPENSSL_NO_RSA
361 /* normal optionally encrypted stuff */
362 if (PEM_write_bio_RSAPrivateKey(bp,
363 xi->x_pkey->dec_pkey->pkey.rsa,
364 enc, kstr, klen, cb, u) <= 0)
365 goto err;
366#endif
367 }
368 }
369
370 /* if we have a certificate then write it out now */
371 if ((xi->x509 != NULL) && (PEM_write_bio_X509(bp, xi->x509) <= 0))
372 goto err;
373
374 /* we are ignoring anything else that is loaded into the X509_INFO
375 * structure for the moment ... as I don't need it so I'm not
376 * coding it here and Eric can do it when this makes it into the
377 * base library --tjh
378 */
379
380 ret = 1;
381
382err:
383 explicit_bzero((char *)&ctx, sizeof(ctx));
384 explicit_bzero(buf, PEM_BUFSIZE);
385 return (ret);
386}
387LCRYPTO_ALIAS(PEM_X509_INFO_write_bio);
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 30db092c3e..7c7f776cae 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_lib.c,v 1.56 2024/02/18 15:44:10 tb Exp $ */ 1/* $OpenBSD: pem_lib.c,v 1.57 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -64,7 +64,6 @@
64#include <openssl/opensslconf.h> 64#include <openssl/opensslconf.h>
65 65
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#include <openssl/err.h>
68#include <openssl/evp.h> 67#include <openssl/evp.h>
69#include <openssl/objects.h> 68#include <openssl/objects.h>
70#include <openssl/pem.h> 69#include <openssl/pem.h>
@@ -76,6 +75,7 @@
76#endif 75#endif
77 76
78#include "asn1_local.h" 77#include "asn1_local.h"
78#include "err_local.h"
79#include "evp_local.h" 79#include "evp_local.h"
80 80
81#define MIN_LENGTH 4 81#define MIN_LENGTH 4
diff --git a/src/lib/libcrypto/pem/pem_oth.c b/src/lib/libcrypto/pem/pem_oth.c
index 2dca978efd..d466179ad7 100644
--- a/src/lib/libcrypto/pem/pem_oth.c
+++ b/src/lib/libcrypto/pem/pem_oth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_oth.c,v 1.9 2023/07/07 13:40:44 beck Exp $ */ 1/* $OpenBSD: pem_oth.c,v 1.10 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,12 +59,13 @@
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/buffer.h> 61#include <openssl/buffer.h>
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/pem.h> 64#include <openssl/pem.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67 66
67#include "err_local.h"
68
68/* Handle 'other' PEMs: not private keys */ 69/* Handle 'other' PEMs: not private keys */
69 70
70void * 71void *
diff --git a/src/lib/libcrypto/pem/pem_pk8.c b/src/lib/libcrypto/pem/pem_pk8.c
index 6d0c0cbd57..16bde39a7e 100644
--- a/src/lib/libcrypto/pem/pem_pk8.c
+++ b/src/lib/libcrypto/pem/pem_pk8.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_pk8.c,v 1.14 2023/07/07 13:40:44 beck Exp $ */ 1/* $OpenBSD: pem_pk8.c,v 1.15 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,13 +60,13 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/buffer.h> 62#include <openssl/buffer.h>
63#include <openssl/err.h>
64#include <openssl/evp.h>
65#include <openssl/objects.h> 63#include <openssl/objects.h>
66#include <openssl/pem.h> 64#include <openssl/pem.h>
67#include <openssl/pkcs12.h> 65#include <openssl/pkcs12.h>
68#include <openssl/x509.h> 66#include <openssl/x509.h>
69 67
68#include "err_local.h"
69
70static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, 70static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid,
71 const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); 71 const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u);
72static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder, int nid, 72static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder, int nid,
diff --git a/src/lib/libcrypto/pem/pem_pkey.c b/src/lib/libcrypto/pem/pem_pkey.c
index d7001c83cc..df8ebaa036 100644
--- a/src/lib/libcrypto/pem/pem_pkey.c
+++ b/src/lib/libcrypto/pem/pem_pkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_pkey.c,v 1.28 2023/11/19 15:46:10 tb Exp $ */ 1/* $OpenBSD: pem_pkey.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,7 +62,6 @@
62#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63 63
64#include <openssl/buffer.h> 64#include <openssl/buffer.h>
65#include <openssl/err.h>
66#include <openssl/evp.h> 65#include <openssl/evp.h>
67#include <openssl/objects.h> 66#include <openssl/objects.h>
68#include <openssl/pem.h> 67#include <openssl/pem.h>
@@ -70,6 +69,7 @@
70#include <openssl/x509.h> 69#include <openssl/x509.h>
71 70
72#include "asn1_local.h" 71#include "asn1_local.h"
72#include "err_local.h"
73#include "evp_local.h" 73#include "evp_local.h"
74 74
75int pem_check_suffix(const char *pem_str, const char *suffix); 75int pem_check_suffix(const char *pem_str, const char *suffix);
diff --git a/src/lib/libcrypto/pem/pem_sign.c b/src/lib/libcrypto/pem/pem_sign.c
index 461f957445..878be01b70 100644
--- a/src/lib/libcrypto/pem/pem_sign.c
+++ b/src/lib/libcrypto/pem/pem_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_sign.c,v 1.15 2023/07/07 13:40:44 beck Exp $ */ 1/* $OpenBSD: pem_sign.c,v 1.16 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -58,12 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/pem.h> 63#include <openssl/pem.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
66#include "err_local.h"
67
67int 68int
68PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) 69PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type)
69{ 70{
diff --git a/src/lib/libcrypto/pem/pvkfmt.c b/src/lib/libcrypto/pem/pvkfmt.c
index 40c9feefe5..395fd9df83 100644
--- a/src/lib/libcrypto/pem/pvkfmt.c
+++ b/src/lib/libcrypto/pem/pvkfmt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pvkfmt.c,v 1.28 2024/02/18 15:45:42 tb Exp $ */ 1/* $OpenBSD: pvkfmt.c,v 1.30 2025/06/07 09:32:35 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2005. 3 * project 2005.
4 */ 4 */
@@ -66,7 +66,6 @@
66#include <openssl/opensslconf.h> 66#include <openssl/opensslconf.h>
67 67
68#include <openssl/bn.h> 68#include <openssl/bn.h>
69#include <openssl/err.h>
70#include <openssl/pem.h> 69#include <openssl/pem.h>
71 70
72#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) 71#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA)
@@ -75,6 +74,7 @@
75 74
76#include "bn_local.h" 75#include "bn_local.h"
77#include "dsa_local.h" 76#include "dsa_local.h"
77#include "err_local.h"
78#include "evp_local.h" 78#include "evp_local.h"
79#include "rsa_local.h" 79#include "rsa_local.h"
80 80
@@ -803,8 +803,8 @@ do_PVK_body(const unsigned char **in, unsigned int saltlen,
803 803
804 err: 804 err:
805 EVP_CIPHER_CTX_free(cctx); 805 EVP_CIPHER_CTX_free(cctx);
806 if (enctmp && saltlen) 806 free(enctmp);
807 free(enctmp); 807
808 return ret; 808 return ret;
809} 809}
810 810
diff --git a/src/lib/libcrypto/pkcs12/p12_add.c b/src/lib/libcrypto/pkcs12/p12_add.c
index f6f42c558c..e45218ba96 100644
--- a/src/lib/libcrypto/pkcs12/p12_add.c
+++ b/src/lib/libcrypto/pkcs12/p12_add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_add.c,v 1.25 2024/03/02 10:20:27 tb Exp $ */ 1/* $OpenBSD: p12_add.c,v 1.26 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -58,9 +58,9 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
63 62
63#include "err_local.h"
64#include "pkcs12_local.h" 64#include "pkcs12_local.h"
65#include "x509_local.h" 65#include "x509_local.h"
66 66
diff --git a/src/lib/libcrypto/pkcs12/p12_crt.c b/src/lib/libcrypto/pkcs12/p12_crt.c
index 502ccecd25..321115cfcd 100644
--- a/src/lib/libcrypto/pkcs12/p12_crt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_crt.c,v 1.26 2024/08/22 12:22:42 tb Exp $ */ 1/* $OpenBSD: p12_crt.c,v 1.27 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -58,10 +58,10 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
63#include <openssl/x509.h> 62#include <openssl/x509.h>
64 63
64#include "err_local.h"
65#include "evp_local.h" 65#include "evp_local.h"
66#include "pkcs12_local.h" 66#include "pkcs12_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index 907d4e52a6..8466e92415 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_decr.c,v 1.26 2024/03/02 10:15:16 tb Exp $ */ 1/* $OpenBSD: p12_decr.c,v 1.27 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -59,9 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/err.h>
63#include <openssl/pkcs12.h> 62#include <openssl/pkcs12.h>
64 63
64#include "err_local.h"
65#include "evp_local.h" 65#include "evp_local.h"
66 66
67/* Encrypt/Decrypt a buffer based on password and algor, result in a 67/* Encrypt/Decrypt a buffer based on password and algor, result in a
diff --git a/src/lib/libcrypto/pkcs12/p12_init.c b/src/lib/libcrypto/pkcs12/p12_init.c
index cd9422d215..ac0f1eeb57 100644
--- a/src/lib/libcrypto/pkcs12/p12_init.c
+++ b/src/lib/libcrypto/pkcs12/p12_init.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_init.c,v 1.17 2024/03/24 06:48:03 tb Exp $ */ 1/* $OpenBSD: p12_init.c,v 1.18 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -58,9 +58,9 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
63 62
63#include "err_local.h"
64#include "pkcs12_local.h" 64#include "pkcs12_local.h"
65 65
66/* Initialise a PKCS12 structure to take data */ 66/* Initialise a PKCS12 structure to take data */
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 443d632c87..29a99bbca4 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_key.c,v 1.36 2025/03/09 15:45:52 tb Exp $ */ 1/* $OpenBSD: p12_key.c,v 1.37 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,9 +60,9 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/err.h>
64#include <openssl/pkcs12.h> 63#include <openssl/pkcs12.h>
65 64
65#include "err_local.h"
66#include "evp_local.h" 66#include "evp_local.h"
67#include "pkcs12_local.h" 67#include "pkcs12_local.h"
68 68
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c
index e4de2eb61c..f6f09ff2de 100644
--- a/src/lib/libcrypto/pkcs12/p12_kiss.c
+++ b/src/lib/libcrypto/pkcs12/p12_kiss.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_kiss.c,v 1.28 2025/01/06 23:35:25 tb Exp $ */ 1/* $OpenBSD: p12_kiss.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -58,9 +58,9 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
63 62
63#include "err_local.h"
64#include "pkcs12_local.h" 64#include "pkcs12_local.h"
65 65
66/* Simplified PKCS#12 routines */ 66/* Simplified PKCS#12 routines */
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c
index 2060358188..4a9d0f9757 100644
--- a/src/lib/libcrypto/pkcs12/p12_mutl.c
+++ b/src/lib/libcrypto/pkcs12/p12_mutl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_mutl.c,v 1.38 2024/03/24 06:48:03 tb Exp $ */ 1/* $OpenBSD: p12_mutl.c,v 1.40 2025/06/03 08:42:15 kenjiro Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -64,10 +64,10 @@
64 64
65#ifndef OPENSSL_NO_HMAC 65#ifndef OPENSSL_NO_HMAC
66 66
67#include <openssl/err.h>
68#include <openssl/hmac.h> 67#include <openssl/hmac.h>
69#include <openssl/pkcs12.h> 68#include <openssl/pkcs12.h>
70 69
70#include "err_local.h"
71#include "evp_local.h" 71#include "evp_local.h"
72#include "hmac_local.h" 72#include "hmac_local.h"
73#include "pkcs12_local.h" 73#include "pkcs12_local.h"
@@ -189,10 +189,10 @@ PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen)
189 PKCS12error(PKCS12_R_MAC_GENERATION_ERROR); 189 PKCS12error(PKCS12_R_MAC_GENERATION_ERROR);
190 return 0; 190 return 0;
191 } 191 }
192 if ((maclen != (unsigned int)p12->mac->dinfo->digest->length) || 192 if (maclen != (unsigned int)p12->mac->dinfo->digest->length)
193 memcmp(mac, p12->mac->dinfo->digest->data, maclen))
194 return 0; 193 return 0;
195 return 1; 194
195 return timingsafe_memcmp(mac, p12->mac->dinfo->digest->data, maclen) == 0;
196} 196}
197LCRYPTO_ALIAS(PKCS12_verify_mac); 197LCRYPTO_ALIAS(PKCS12_verify_mac);
198 198
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
index 6d3b43ce22..c78deb9182 100644
--- a/src/lib/libcrypto/pkcs12/p12_npas.c
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_npas.c,v 1.27 2024/01/25 15:33:35 tb Exp $ */ 1/* $OpenBSD: p12_npas.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,9 +60,9 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <openssl/pem.h> 62#include <openssl/pem.h>
63#include <openssl/err.h>
64#include <openssl/pkcs12.h> 63#include <openssl/pkcs12.h>
65 64
65#include "err_local.h"
66#include "pkcs12_local.h" 66#include "pkcs12_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
diff --git a/src/lib/libcrypto/pkcs12/p12_p8e.c b/src/lib/libcrypto/pkcs12/p12_p8e.c
index bf61593266..a8a5039dfb 100644
--- a/src/lib/libcrypto/pkcs12/p12_p8e.c
+++ b/src/lib/libcrypto/pkcs12/p12_p8e.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_p8e.c,v 1.13 2024/03/02 10:15:16 tb Exp $ */ 1/* $OpenBSD: p12_p8e.c,v 1.14 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -58,9 +58,9 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/pkcs12.h> 61#include <openssl/pkcs12.h>
63 62
63#include "err_local.h"
64#include "pkcs12_local.h" 64#include "pkcs12_local.h"
65#include "x509_local.h" 65#include "x509_local.h"
66 66
diff --git a/src/lib/libcrypto/pkcs12/p12_sbag.c b/src/lib/libcrypto/pkcs12/p12_sbag.c
index 1664e9409d..5fea54073b 100644
--- a/src/lib/libcrypto/pkcs12/p12_sbag.c
+++ b/src/lib/libcrypto/pkcs12/p12_sbag.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_sbag.c,v 1.9 2024/03/24 06:48:03 tb Exp $ */ 1/* $OpenBSD: p12_sbag.c,v 1.10 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4 * 1999-2018. 4 * 1999-2018.
@@ -59,9 +59,9 @@
59 59
60#include <stdio.h> 60#include <stdio.h>
61 61
62#include <openssl/err.h>
63#include <openssl/pkcs12.h> 62#include <openssl/pkcs12.h>
64 63
64#include "err_local.h"
65#include "pkcs12_local.h" 65#include "pkcs12_local.h"
66#include "x509_local.h" 66#include "x509_local.h"
67 67
diff --git a/src/lib/libcrypto/pkcs12/pkcs12.h b/src/lib/libcrypto/pkcs12/pkcs12.h
index 200712039b..aec0362806 100644
--- a/src/lib/libcrypto/pkcs12/pkcs12.h
+++ b/src/lib/libcrypto/pkcs12/pkcs12.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pkcs12.h,v 1.29 2025/03/09 15:45:52 tb Exp $ */ 1/* $OpenBSD: pkcs12.h,v 1.30 2025/05/10 19:01:16 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -77,7 +77,7 @@ extern "C" {
77 77
78#define PKCS12_MAC_KEY_LENGTH 20 78#define PKCS12_MAC_KEY_LENGTH 20
79 79
80#define PKCS12_SALT_LEN 8 80#define PKCS12_SALT_LEN 16
81 81
82/* Uncomment out next line for unicode password and names, otherwise ASCII */ 82/* Uncomment out next line for unicode password and names, otherwise ASCII */
83 83
diff --git a/src/lib/libcrypto/pkcs7/pk7_asn1.c b/src/lib/libcrypto/pkcs7/pk7_asn1.c
index 8a6ae487da..be1c4c1a1d 100644
--- a/src/lib/libcrypto/pkcs7/pk7_asn1.c
+++ b/src/lib/libcrypto/pkcs7/pk7_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pk7_asn1.c,v 1.18 2024/07/08 16:23:27 beck Exp $ */ 1/* $OpenBSD: pk7_asn1.c,v 1.19 2025/06/11 18:11:55 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -84,7 +84,6 @@ static const ASN1_ADB_TABLE PKCS7_adbtbl[] = {
84 .field_name = "d.data", 84 .field_name = "d.data",
85 .item = &ASN1_OCTET_STRING_NDEF_it, 85 .item = &ASN1_OCTET_STRING_NDEF_it,
86 }, 86 },
87
88 }, 87 },
89 { 88 {
90 .value = NID_pkcs7_signed, 89 .value = NID_pkcs7_signed,
@@ -95,7 +94,6 @@ static const ASN1_ADB_TABLE PKCS7_adbtbl[] = {
95 .field_name = "d.sign", 94 .field_name = "d.sign",
96 .item = &PKCS7_SIGNED_it, 95 .item = &PKCS7_SIGNED_it,
97 }, 96 },
98
99 }, 97 },
100 { 98 {
101 .value = NID_pkcs7_enveloped, 99 .value = NID_pkcs7_enveloped,
@@ -106,7 +104,6 @@ static const ASN1_ADB_TABLE PKCS7_adbtbl[] = {
106 .field_name = "d.enveloped", 104 .field_name = "d.enveloped",
107 .item = &PKCS7_ENVELOPE_it, 105 .item = &PKCS7_ENVELOPE_it,
108 }, 106 },
109
110 }, 107 },
111 { 108 {
112 .value = NID_pkcs7_signedAndEnveloped, 109 .value = NID_pkcs7_signedAndEnveloped,
@@ -117,7 +114,6 @@ static const ASN1_ADB_TABLE PKCS7_adbtbl[] = {
117 .field_name = "d.signed_and_enveloped", 114 .field_name = "d.signed_and_enveloped",
118 .item = &PKCS7_SIGN_ENVELOPE_it, 115 .item = &PKCS7_SIGN_ENVELOPE_it,
119 }, 116 },
120
121 }, 117 },
122 { 118 {
123 .value = NID_pkcs7_digest, 119 .value = NID_pkcs7_digest,
@@ -128,7 +124,6 @@ static const ASN1_ADB_TABLE PKCS7_adbtbl[] = {
128 .field_name = "d.digest", 124 .field_name = "d.digest",
129 .item = &PKCS7_DIGEST_it, 125 .item = &PKCS7_DIGEST_it,
130 }, 126 },
131
132 }, 127 },
133 { 128 {
134 .value = NID_pkcs7_encrypted, 129 .value = NID_pkcs7_encrypted,
@@ -139,7 +134,6 @@ static const ASN1_ADB_TABLE PKCS7_adbtbl[] = {
139 .field_name = "d.encrypted", 134 .field_name = "d.encrypted",
140 .item = &PKCS7_ENCRYPT_it, 135 .item = &PKCS7_ENCRYPT_it,
141 }, 136 },
142
143 }, 137 },
144}; 138};
145 139
diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c
index 52463aa3a3..f2e17806db 100644
--- a/src/lib/libcrypto/pkcs7/pk7_attr.c
+++ b/src/lib/libcrypto/pkcs7/pk7_attr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pk7_attr.c,v 1.15 2024/02/19 15:37:44 tb Exp $ */ 1/* $OpenBSD: pk7_attr.c,v 1.22 2025/07/31 02:24:21 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -59,23 +59,48 @@
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/err.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/pkcs7.h> 63#include <openssl/pkcs7.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66 65
66#include "asn1_local.h"
67#include "err_local.h"
68#include "x509_local.h"
69
67int 70int
68PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) *cap) 71PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) *cap)
69{ 72{
70 ASN1_STRING *seq; 73 ASN1_STRING *seq = NULL;
71 if (!(seq = ASN1_STRING_new())) { 74 unsigned char *data = NULL;
75 int len = 0;
76 int ret = 0;
77
78 if ((len = i2d_X509_ALGORS(cap, &data)) <= 0) {
79 len = 0;
80 goto err;
81 }
82
83 if ((seq = ASN1_STRING_new()) == NULL) {
72 PKCS7error(ERR_R_MALLOC_FAILURE); 84 PKCS7error(ERR_R_MALLOC_FAILURE);
73 return 0; 85 goto err;
74 } 86 }
75 seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data, 87
76 &X509_ALGORS_it); 88 ASN1_STRING_set0(seq, data, len);
77 return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, 89 data = NULL;
78 V_ASN1_SEQUENCE, seq); 90 len = 0;
91
92 if (!PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
93 V_ASN1_SEQUENCE, seq))
94 goto err;
95 seq = NULL;
96
97 ret = 1;
98
99 err:
100 ASN1_STRING_free(seq);
101 freezero(data, len);
102
103 return ret;
79} 104}
80LCRYPTO_ALIAS(PKCS7_add_attrib_smimecap); 105LCRYPTO_ALIAS(PKCS7_add_attrib_smimecap);
81 106
@@ -84,51 +109,60 @@ PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si)
84{ 109{
85 ASN1_TYPE *cap; 110 ASN1_TYPE *cap;
86 const unsigned char *p; 111 const unsigned char *p;
112 int len;
87 113
88 cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities); 114 if ((cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities)) == NULL)
89 if (!cap || (cap->type != V_ASN1_SEQUENCE)) 115 return NULL;
116 if (cap->type != V_ASN1_SEQUENCE)
90 return NULL; 117 return NULL;
118
91 p = cap->value.sequence->data; 119 p = cap->value.sequence->data;
92 return (STACK_OF(X509_ALGOR) *) 120 len = cap->value.sequence->length;
93 ASN1_item_d2i(NULL, &p, cap->value.sequence->length, 121
94 &X509_ALGORS_it); 122 return d2i_X509_ALGORS(NULL, &p, len);
95} 123}
96LCRYPTO_ALIAS(PKCS7_get_smimecap); 124LCRYPTO_ALIAS(PKCS7_get_smimecap);
97 125
98/* Basic smime-capabilities OID and optional integer arg */ 126/*
127 * Add AlgorithmIdentifier OID of type |nid| to the SMIMECapability attribute
128 * set |sk| (see RFC 3851, section 2.5.2). If keysize > 0, the OID has an
129 * integer parameter of value |keysize|, otherwise parameters are omitted.
130 *
131 * See also CMS_add_simple_smimecap().
132 */
99int 133int
100PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg) 134PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int keysize)
101{ 135{
102 X509_ALGOR *alg; 136 X509_ALGOR *alg = NULL;
137 ASN1_INTEGER *parameter = NULL;
138 int parameter_type = V_ASN1_UNDEF;
139 int ret = 0;
103 140
104 if (!(alg = X509_ALGOR_new())) { 141 if (keysize > 0) {
105 PKCS7error(ERR_R_MALLOC_FAILURE); 142 if ((parameter = ASN1_INTEGER_new()) == NULL)
106 return 0;
107 }
108 ASN1_OBJECT_free(alg->algorithm);
109 alg->algorithm = OBJ_nid2obj(nid);
110 if (arg > 0) {
111 ASN1_INTEGER *nbit;
112
113 if (!(alg->parameter = ASN1_TYPE_new()))
114 goto err;
115 if (!(nbit = ASN1_INTEGER_new()))
116 goto err; 143 goto err;
117 if (!ASN1_INTEGER_set(nbit, arg)) { 144 if (!ASN1_INTEGER_set(parameter, keysize))
118 ASN1_INTEGER_free(nbit);
119 goto err; 145 goto err;
120 } 146 parameter_type = V_ASN1_INTEGER;
121 alg->parameter->value.integer = nbit;
122 alg->parameter->type = V_ASN1_INTEGER;
123 } 147 }
124 if (sk_X509_ALGOR_push(sk, alg) == 0) 148
149 if ((alg = X509_ALGOR_new()) == NULL)
125 goto err; 150 goto err;
126 return 1; 151 if (!X509_ALGOR_set0_by_nid(alg, nid, parameter_type, parameter))
152 goto err;
153 parameter = NULL;
154
155 if (sk_X509_ALGOR_push(sk, alg) <= 0)
156 goto err;
157 alg = NULL;
127 158
128err: 159 ret = 1;
129 PKCS7error(ERR_R_MALLOC_FAILURE); 160
161 err:
130 X509_ALGOR_free(alg); 162 X509_ALGOR_free(alg);
131 return 0; 163 ASN1_INTEGER_free(parameter);
164
165 return ret;
132} 166}
133LCRYPTO_ALIAS(PKCS7_simple_smimecap); 167LCRYPTO_ALIAS(PKCS7_simple_smimecap);
134 168
@@ -147,30 +181,54 @@ LCRYPTO_ALIAS(PKCS7_add_attrib_content_type);
147int 181int
148PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t) 182PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t)
149{ 183{
150 if (!t && !(t = X509_gmtime_adj(NULL, 0))) { 184 ASN1_TIME *tm;
185 int ret = 0;
186
187 if ((tm = t) == NULL)
188 tm = X509_gmtime_adj(NULL, 0);
189 if (tm == NULL) {
151 PKCS7error(ERR_R_MALLOC_FAILURE); 190 PKCS7error(ERR_R_MALLOC_FAILURE);
152 return 0; 191 goto err;
153 } 192 }
154 return PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime, 193
155 V_ASN1_UTCTIME, t); 194 /* RFC 5652, section 11.3 - UTCTime for the years 1950-2049. */
195 if (ASN1_time_parse(tm->data, tm->length, NULL, tm->type) == -1)
196 goto err;
197 if (!PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime, tm->type, tm))
198 goto err;
199 tm = NULL;
200
201 ret = 1;
202
203 err:
204 if (tm != t)
205 ASN1_TIME_free(tm);
206
207 return ret;
156} 208}
157LCRYPTO_ALIAS(PKCS7_add0_attrib_signing_time); 209LCRYPTO_ALIAS(PKCS7_add0_attrib_signing_time);
158 210
159int 211int
160PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, const unsigned char *md, 212PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, const unsigned char *md,
161 int mdlen) 213 int md_len)
162{ 214{
163 ASN1_OCTET_STRING *os; 215 ASN1_OCTET_STRING *os;
216 int ret = 0;
164 217
165 os = ASN1_OCTET_STRING_new(); 218 if ((os = ASN1_OCTET_STRING_new()) == NULL)
166 if (!os) 219 goto err;
167 return 0; 220 if (!ASN1_STRING_set(os, md, md_len))
168 if (!ASN1_STRING_set(os, md, mdlen) || 221 goto err;
169 !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest, 222 if (!PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
170 V_ASN1_OCTET_STRING, os)) { 223 V_ASN1_OCTET_STRING, os))
171 ASN1_OCTET_STRING_free(os); 224 goto err;
172 return 0; 225 os = NULL;
173 } 226
174 return 1; 227 ret = 1;
228
229 err:
230 ASN1_OCTET_STRING_free(os);
231
232 return ret;
175} 233}
176LCRYPTO_ALIAS(PKCS7_add1_attrib_digest); 234LCRYPTO_ALIAS(PKCS7_add1_attrib_digest);
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c
index 020de71fef..e39d960780 100644
--- a/src/lib/libcrypto/pkcs7/pk7_doit.c
+++ b/src/lib/libcrypto/pkcs7/pk7_doit.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pk7_doit.c,v 1.59 2025/03/18 12:53:25 tb Exp $ */ 1/* $OpenBSD: pk7_doit.c,v 1.61 2025/07/27 07:06:41 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,11 +60,11 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/err.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "evp_local.h" 68#include "evp_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
70 70
@@ -1208,43 +1208,51 @@ PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) *sk)
1208LCRYPTO_ALIAS(PKCS7_set_attributes); 1208LCRYPTO_ALIAS(PKCS7_set_attributes);
1209 1209
1210static int 1210static int
1211add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, void *value) 1211add_attribute(STACK_OF(X509_ATTRIBUTE) **in_sk, int nid, int atrtype, void *value)
1212{ 1212{
1213 X509_ATTRIBUTE *attr = NULL; 1213 STACK_OF(X509_ATTRIBUTE) *sk;
1214 X509_ATTRIBUTE *old_attr = NULL, *new_attr = NULL;
1215 int need_pop = 0;
1216 int i;
1214 1217
1215 if (*sk == NULL) { 1218 if ((sk = *in_sk) == NULL)
1216 *sk = sk_X509_ATTRIBUTE_new_null(); 1219 sk = sk_X509_ATTRIBUTE_new_null();
1217 if (*sk == NULL) 1220 if (sk == NULL)
1218 return 0; 1221 goto err;
1219new_attrib: 1222
1220 if (!(attr = X509_ATTRIBUTE_create(nid, atrtype, value))) 1223 /* Replace an already existing attribute with the given nid. */
1221 return 0; 1224 for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) {
1222 if (!sk_X509_ATTRIBUTE_push(*sk, attr)) { 1225 old_attr = sk_X509_ATTRIBUTE_value(sk, i);
1223 X509_ATTRIBUTE_free(attr); 1226 if(OBJ_obj2nid(old_attr->object) == nid)
1224 return 0; 1227 break;
1225 } 1228 }
1226 } else { 1229
1227 int i; 1230 /* If there is none, make room for the new one, so _set() succeeds. */
1228 1231 if (i == sk_X509_ATTRIBUTE_num(sk)) {
1229 for (i = 0; i < sk_X509_ATTRIBUTE_num(*sk); i++) { 1232 old_attr = NULL;
1230 attr = sk_X509_ATTRIBUTE_value(*sk, i); 1233 if (sk_X509_ATTRIBUTE_push(sk, NULL) <= 0)
1231 if (OBJ_obj2nid(attr->object) == nid) { 1234 goto err;
1232 X509_ATTRIBUTE_free(attr); 1235 need_pop = 1;
1233 attr = X509_ATTRIBUTE_create(nid, atrtype,
1234 value);
1235 if (attr == NULL)
1236 return 0;
1237 if (!sk_X509_ATTRIBUTE_set(*sk, i, attr)) {
1238 X509_ATTRIBUTE_free(attr);
1239 return 0;
1240 }
1241 goto end;
1242 }
1243 }
1244 goto new_attrib;
1245 } 1236 }
1246end: 1237
1238 /* On success, new_attr owns value. */
1239 if ((new_attr = X509_ATTRIBUTE_create(nid, atrtype, value)) == NULL)
1240 goto err;
1241
1242 X509_ATTRIBUTE_free(old_attr);
1243 (void)sk_X509_ATTRIBUTE_set(sk, i, new_attr);
1244
1245 *in_sk = sk;
1246
1247 return 1; 1247 return 1;
1248
1249 err:
1250 if (need_pop)
1251 (void)sk_X509_ATTRIBUTE_pop(sk);
1252 if (*in_sk != sk)
1253 sk_X509_ATTRIBUTE_pop_free(sk, X509_ATTRIBUTE_free);
1254
1255 return 0;
1248} 1256}
1249 1257
1250int 1258int
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c
index a1c7d61cca..8712a2ecc1 100644
--- a/src/lib/libcrypto/pkcs7/pk7_lib.c
+++ b/src/lib/libcrypto/pkcs7/pk7_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pk7_lib.c,v 1.30 2024/12/06 07:10:20 tb Exp $ */ 1/* $OpenBSD: pk7_lib.c,v 1.31 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -58,11 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/objects.h> 61#include <openssl/objects.h>
63#include <openssl/x509.h> 62#include <openssl/x509.h>
64 63
65#include "asn1_local.h" 64#include "asn1_local.h"
65#include "err_local.h"
66#include "evp_local.h" 66#include "evp_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c
index cff89c34e1..32f28f0505 100644
--- a/src/lib/libcrypto/pkcs7/pk7_smime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_smime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pk7_smime.c,v 1.27 2024/04/20 10:11:55 tb Exp $ */ 1/* $OpenBSD: pk7_smime.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -60,10 +60,10 @@
60 60
61#include <stdio.h> 61#include <stdio.h>
62 62
63#include <openssl/err.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
65#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
66 65
66#include "err_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
69static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si); 69static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
diff --git a/src/lib/libcrypto/pkcs7/pkcs7.h b/src/lib/libcrypto/pkcs7/pkcs7.h
index 6fd5adf457..6f0ccc0dc8 100644
--- a/src/lib/libcrypto/pkcs7/pkcs7.h
+++ b/src/lib/libcrypto/pkcs7/pkcs7.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pkcs7.h,v 1.22 2024/10/23 01:57:19 jsg Exp $ */ 1/* $OpenBSD: pkcs7.h,v 1.24 2025/07/02 10:24:17 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -82,7 +82,7 @@ typedef struct pkcs7_issuer_and_serial_st {
82} PKCS7_ISSUER_AND_SERIAL; 82} PKCS7_ISSUER_AND_SERIAL;
83 83
84typedef struct pkcs7_signer_info_st { 84typedef struct pkcs7_signer_info_st {
85 ASN1_INTEGER *version; /* version 1 */ 85 ASN1_INTEGER *version; /* version 1 */
86 PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; 86 PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
87 X509_ALGOR *digest_alg; 87 X509_ALGOR *digest_alg;
88 STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ 88 STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */
@@ -145,7 +145,7 @@ typedef struct pkcs7_signedandenveloped_st {
145typedef struct pkcs7_digest_st { 145typedef struct pkcs7_digest_st {
146 ASN1_INTEGER *version; /* version 0 */ 146 ASN1_INTEGER *version; /* version 0 */
147 X509_ALGOR *md; /* md used */ 147 X509_ALGOR *md; /* md used */
148 struct pkcs7_st *contents; 148 struct pkcs7_st *contents;
149 ASN1_OCTET_STRING *digest; 149 ASN1_OCTET_STRING *digest;
150} PKCS7_DIGEST; 150} PKCS7_DIGEST;
151 151
@@ -362,7 +362,7 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
362ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); 362ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);
363int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type, 363int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,
364 void *data); 364 void *data);
365int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, 365int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
366 void *value); 366 void *value);
367ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); 367ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);
368ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); 368ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);
diff --git a/src/lib/libcrypto/rc2/rc2_cbc.c b/src/lib/libcrypto/rc2/rc2.c
index 1d8e2def99..c122d4b810 100644
--- a/src/lib/libcrypto/rc2/rc2_cbc.c
+++ b/src/lib/libcrypto/rc2/rc2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rc2_cbc.c,v 1.8 2023/07/07 13:40:44 beck Exp $ */ 1/* $OpenBSD: rc2.c,v 1.1 2025/05/25 05:29:54 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -57,86 +57,89 @@
57 */ 57 */
58 58
59#include <openssl/rc2.h> 59#include <openssl/rc2.h>
60
60#include "rc2_local.h" 61#include "rc2_local.h"
61 62
63static const unsigned char key_table[256]={
64 0xd9,0x78,0xf9,0xc4,0x19,0xdd,0xb5,0xed,0x28,0xe9,0xfd,0x79,
65 0x4a,0xa0,0xd8,0x9d,0xc6,0x7e,0x37,0x83,0x2b,0x76,0x53,0x8e,
66 0x62,0x4c,0x64,0x88,0x44,0x8b,0xfb,0xa2,0x17,0x9a,0x59,0xf5,
67 0x87,0xb3,0x4f,0x13,0x61,0x45,0x6d,0x8d,0x09,0x81,0x7d,0x32,
68 0xbd,0x8f,0x40,0xeb,0x86,0xb7,0x7b,0x0b,0xf0,0x95,0x21,0x22,
69 0x5c,0x6b,0x4e,0x82,0x54,0xd6,0x65,0x93,0xce,0x60,0xb2,0x1c,
70 0x73,0x56,0xc0,0x14,0xa7,0x8c,0xf1,0xdc,0x12,0x75,0xca,0x1f,
71 0x3b,0xbe,0xe4,0xd1,0x42,0x3d,0xd4,0x30,0xa3,0x3c,0xb6,0x26,
72 0x6f,0xbf,0x0e,0xda,0x46,0x69,0x07,0x57,0x27,0xf2,0x1d,0x9b,
73 0xbc,0x94,0x43,0x03,0xf8,0x11,0xc7,0xf6,0x90,0xef,0x3e,0xe7,
74 0x06,0xc3,0xd5,0x2f,0xc8,0x66,0x1e,0xd7,0x08,0xe8,0xea,0xde,
75 0x80,0x52,0xee,0xf7,0x84,0xaa,0x72,0xac,0x35,0x4d,0x6a,0x2a,
76 0x96,0x1a,0xd2,0x71,0x5a,0x15,0x49,0x74,0x4b,0x9f,0xd0,0x5e,
77 0x04,0x18,0xa4,0xec,0xc2,0xe0,0x41,0x6e,0x0f,0x51,0xcb,0xcc,
78 0x24,0x91,0xaf,0x50,0xa1,0xf4,0x70,0x39,0x99,0x7c,0x3a,0x85,
79 0x23,0xb8,0xb4,0x7a,0xfc,0x02,0x36,0x5b,0x25,0x55,0x97,0x31,
80 0x2d,0x5d,0xfa,0x98,0xe3,0x8a,0x92,0xae,0x05,0xdf,0x29,0x10,
81 0x67,0x6c,0xba,0xc9,0xd3,0x00,0xe6,0xcf,0xe1,0x9e,0xa8,0x2c,
82 0x63,0x16,0x01,0x3f,0x58,0xe2,0x89,0xa9,0x0d,0x38,0x34,0x1b,
83 0xab,0x33,0xff,0xb0,0xbb,0x48,0x0c,0x5f,0xb9,0xb1,0xcd,0x2e,
84 0xc5,0xf3,0xdb,0x47,0xe5,0xa5,0x9c,0x77,0x0a,0xa6,0x20,0x68,
85 0xfe,0x7f,0xc1,0xad,
86 };
87
88/* It has come to my attention that there are 2 versions of the RC2
89 * key schedule. One which is normal, and anther which has a hook to
90 * use a reduced key length.
91 * BSAFE uses the 'retarded' version. What I previously shipped is
92 * the same as specifying 1024 for the 'bits' parameter. Bsafe uses
93 * a version where the bits parameter is the same as len*8 */
62void 94void
63RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 95RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
64 RC2_KEY *ks, unsigned char *iv, int encrypt)
65{ 96{
66 unsigned long tin0, tin1; 97 int i, j;
67 unsigned long tout0, tout1, xor0, xor1; 98 unsigned char *k;
68 long l = length; 99 RC2_INT *ki;
69 unsigned long tin[2]; 100 unsigned int c, d;
70 101
71 if (encrypt) { 102 k = (unsigned char *)&(key->data[0]);
72 c2l(iv, tout0); 103 *k = 0; /* for if there is a zero length key */
73 c2l(iv, tout1); 104
74 iv -= 8; 105 if (len > 128)
75 for (l -= 8; l >= 0; l -= 8) 106 len = 128;
76 { 107 if (bits <= 0)
77 c2l(in, tin0); 108 bits = 1024;
78 c2l(in, tin1); 109 if (bits > 1024)
79 tin0 ^= tout0; 110 bits = 1024;
80 tin1 ^= tout1; 111
81 tin[0] = tin0; 112 for (i = 0; i < len; i++)
82 tin[1] = tin1; 113 k[i] = data[i];
83 RC2_encrypt(tin, ks); 114
84 tout0 = tin[0]; 115 /* expand table */
85 l2c(tout0, out); 116 d = k[len - 1];
86 tout1 = tin[1]; 117 j = 0;
87 l2c(tout1, out); 118 for (i = len; i < 128; i++, j++)
88 } 119 {
89 if (l != -8) { 120 d = key_table[(k[j] + d) & 0xff];
90 c2ln(in, tin0, tin1, l + 8); 121 k[i] = d;
91 tin0 ^= tout0;
92 tin1 ^= tout1;
93 tin[0] = tin0;
94 tin[1] = tin1;
95 RC2_encrypt(tin, ks);
96 tout0 = tin[0];
97 l2c(tout0, out);
98 tout1 = tin[1];
99 l2c(tout1, out);
100 }
101 l2c(tout0, iv);
102 l2c(tout1, iv);
103 } else {
104 c2l(iv, xor0);
105 c2l(iv, xor1);
106 iv -= 8;
107 for (l -= 8; l >= 0; l -= 8)
108 {
109 c2l(in, tin0);
110 tin[0] = tin0;
111 c2l(in, tin1);
112 tin[1] = tin1;
113 RC2_decrypt(tin, ks);
114 tout0 = tin[0] ^ xor0;
115 tout1 = tin[1] ^ xor1;
116 l2c(tout0, out);
117 l2c(tout1, out);
118 xor0 = tin0;
119 xor1 = tin1;
120 }
121 if (l != -8) {
122 c2l(in, tin0);
123 tin[0] = tin0;
124 c2l(in, tin1);
125 tin[1] = tin1;
126 RC2_decrypt(tin, ks);
127 tout0 = tin[0] ^ xor0;
128 tout1 = tin[1] ^ xor1;
129 l2cn(tout0, tout1, out, l + 8);
130 xor0 = tin0;
131 xor1 = tin1;
132 }
133 l2c(xor0, iv);
134 l2c(xor1, iv);
135 } 122 }
136 tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; 123
137 tin[0] = tin[1] = 0; 124 /* hmm.... key reduction to 'bits' bits */
125
126 j = (bits + 7) >> 3;
127 i = 128 - j;
128 c = (0xff >> (-bits & 0x07));
129
130 d = key_table[k[i] & c];
131 k[i] = d;
132 while (i--) {
133 d = key_table[k[i + j] ^ d];
134 k[i] = d;
135 }
136
137 /* copy from bytes into RC2_INT's */
138 ki = &(key->data[63]);
139 for (i = 127; i >= 0; i -= 2)
140 *(ki--) = ((k[i] << 8)|k[i - 1]) & 0xffff;
138} 141}
139LCRYPTO_ALIAS(RC2_cbc_encrypt); 142LCRYPTO_ALIAS(RC2_set_key);
140 143
141void 144void
142RC2_encrypt(unsigned long *d, RC2_KEY *key) 145RC2_encrypt(unsigned long *d, RC2_KEY *key)
@@ -234,3 +237,225 @@ RC2_decrypt(unsigned long *d, RC2_KEY *key)
234 16L); 237 16L);
235} 238}
236LCRYPTO_ALIAS(RC2_decrypt); 239LCRYPTO_ALIAS(RC2_decrypt);
240
241void
242RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
243 RC2_KEY *ks, unsigned char *iv, int encrypt)
244{
245 unsigned long tin0, tin1;
246 unsigned long tout0, tout1, xor0, xor1;
247 long l = length;
248 unsigned long tin[2];
249
250 if (encrypt) {
251 c2l(iv, tout0);
252 c2l(iv, tout1);
253 iv -= 8;
254 for (l -= 8; l >= 0; l -= 8)
255 {
256 c2l(in, tin0);
257 c2l(in, tin1);
258 tin0 ^= tout0;
259 tin1 ^= tout1;
260 tin[0] = tin0;
261 tin[1] = tin1;
262 RC2_encrypt(tin, ks);
263 tout0 = tin[0];
264 l2c(tout0, out);
265 tout1 = tin[1];
266 l2c(tout1, out);
267 }
268 if (l != -8) {
269 c2ln(in, tin0, tin1, l + 8);
270 tin0 ^= tout0;
271 tin1 ^= tout1;
272 tin[0] = tin0;
273 tin[1] = tin1;
274 RC2_encrypt(tin, ks);
275 tout0 = tin[0];
276 l2c(tout0, out);
277 tout1 = tin[1];
278 l2c(tout1, out);
279 }
280 l2c(tout0, iv);
281 l2c(tout1, iv);
282 } else {
283 c2l(iv, xor0);
284 c2l(iv, xor1);
285 iv -= 8;
286 for (l -= 8; l >= 0; l -= 8)
287 {
288 c2l(in, tin0);
289 tin[0] = tin0;
290 c2l(in, tin1);
291 tin[1] = tin1;
292 RC2_decrypt(tin, ks);
293 tout0 = tin[0] ^ xor0;
294 tout1 = tin[1] ^ xor1;
295 l2c(tout0, out);
296 l2c(tout1, out);
297 xor0 = tin0;
298 xor1 = tin1;
299 }
300 if (l != -8) {
301 c2l(in, tin0);
302 tin[0] = tin0;
303 c2l(in, tin1);
304 tin[1] = tin1;
305 RC2_decrypt(tin, ks);
306 tout0 = tin[0] ^ xor0;
307 tout1 = tin[1] ^ xor1;
308 l2cn(tout0, tout1, out, l + 8);
309 xor0 = tin0;
310 xor1 = tin1;
311 }
312 l2c(xor0, iv);
313 l2c(xor1, iv);
314 }
315 tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0;
316 tin[0] = tin[1] = 0;
317}
318LCRYPTO_ALIAS(RC2_cbc_encrypt);
319
320/* The input and output encrypted as though 64bit cfb mode is being
321 * used. The extra state information to record how much of the
322 * 64bit block we have used is contained in *num;
323 */
324void
325RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,
326 long length, RC2_KEY *schedule, unsigned char *ivec,
327 int *num, int encrypt)
328{
329 unsigned long v0, v1, t;
330 int n = *num;
331 long l = length;
332 unsigned long ti[2];
333 unsigned char *iv, c, cc;
334
335 iv = (unsigned char *)ivec;
336 if (encrypt) {
337 while (l--) {
338 if (n == 0) {
339 c2l(iv, v0);
340 ti[0] = v0;
341 c2l(iv, v1);
342 ti[1] = v1;
343 RC2_encrypt((unsigned long *)ti, schedule);
344 iv = (unsigned char *)ivec;
345 t = ti[0];
346 l2c(t, iv);
347 t = ti[1];
348 l2c(t, iv);
349 iv = (unsigned char *)ivec;
350 }
351 c = *(in++) ^ iv[n];
352 *(out++) = c;
353 iv[n] = c;
354 n = (n + 1) & 0x07;
355 }
356 } else {
357 while (l--) {
358 if (n == 0) {
359 c2l(iv, v0);
360 ti[0] = v0;
361 c2l(iv, v1);
362 ti[1] = v1;
363 RC2_encrypt((unsigned long *)ti, schedule);
364 iv = (unsigned char *)ivec;
365 t = ti[0];
366 l2c(t, iv);
367 t = ti[1];
368 l2c(t, iv);
369 iv = (unsigned char *)ivec;
370 }
371 cc = *(in++);
372 c = iv[n];
373 iv[n] = cc;
374 *(out++) = c ^ cc;
375 n = (n + 1) & 0x07;
376 }
377 }
378 v0 = v1 = ti[0] = ti[1] = t = c = cc = 0;
379 *num = n;
380}
381LCRYPTO_ALIAS(RC2_cfb64_encrypt);
382
383/* RC2 as implemented frm a posting from
384 * Newsgroups: sci.crypt
385 * Sender: pgut01@cs.auckland.ac.nz (Peter Gutmann)
386 * Subject: Specification for Ron Rivests Cipher No.2
387 * Message-ID: <4fk39f$f70@net.auckland.ac.nz>
388 * Date: 11 Feb 1996 06:45:03 GMT
389 */
390void
391RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, RC2_KEY *ks,
392 int encrypt)
393{
394 unsigned long l, d[2];
395
396 c2l(in, l);
397 d[0] = l;
398 c2l(in, l);
399 d[1] = l;
400 if (encrypt)
401 RC2_encrypt(d, ks);
402 else
403 RC2_decrypt(d, ks);
404 l = d[0];
405 l2c(l, out);
406 l = d[1];
407 l2c(l, out);
408 l = d[0] = d[1] = 0;
409}
410LCRYPTO_ALIAS(RC2_ecb_encrypt);
411
412/* The input and output encrypted as though 64bit ofb mode is being
413 * used. The extra state information to record how much of the
414 * 64bit block we have used is contained in *num;
415 */
416void
417RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,
418 long length, RC2_KEY *schedule, unsigned char *ivec,
419 int *num)
420{
421 unsigned long v0, v1, t;
422 int n = *num;
423 long l = length;
424 unsigned char d[8];
425 char *dp;
426 unsigned long ti[2];
427 unsigned char *iv;
428 int save = 0;
429
430 iv = (unsigned char *)ivec;
431 c2l(iv, v0);
432 c2l(iv, v1);
433 ti[0] = v0;
434 ti[1] = v1;
435 dp = (char *)d;
436 l2c(v0, dp);
437 l2c(v1, dp);
438 while (l--) {
439 if (n == 0) {
440 RC2_encrypt((unsigned long *)ti, schedule);
441 dp = (char *)d;
442 t = ti[0];
443 l2c(t, dp);
444 t = ti[1];
445 l2c(t, dp);
446 save++;
447 }
448 *(out++) = *(in++) ^ d[n];
449 n = (n + 1) & 0x07;
450 }
451 if (save) {
452 v0 = ti[0];
453 v1 = ti[1];
454 iv = (unsigned char *)ivec;
455 l2c(v0, iv);
456 l2c(v1, iv);
457 }
458 t = v0 = v1 = ti[0] = ti[1] = 0;
459 *num = n;
460}
461LCRYPTO_ALIAS(RC2_ofb64_encrypt);
diff --git a/src/lib/libcrypto/rc2/rc2.h b/src/lib/libcrypto/rc2/rc2.h
index 96e395f32d..ead308cf51 100644
--- a/src/lib/libcrypto/rc2/rc2.h
+++ b/src/lib/libcrypto/rc2/rc2.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: rc2.h,v 1.13 2025/01/25 17:59:44 tb Exp $ */ 1/* $OpenBSD: rc2.h,v 1.14 2025/06/09 14:37:49 tb Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,7 +59,12 @@
59#ifndef HEADER_RC2_H 59#ifndef HEADER_RC2_H
60#define HEADER_RC2_H 60#define HEADER_RC2_H
61 61
62#include <openssl/opensslconf.h> /* OPENSSL_NO_RC2, RC2_INT */ 62#include <openssl/opensslconf.h> /* OPENSSL_NO_RC2 */
63
64#ifndef RC2_INT
65/* XXX - typedef */
66#define RC2_INT unsigned int
67#endif
63 68
64#define RC2_ENCRYPT 1 69#define RC2_ENCRYPT 1
65#define RC2_DECRYPT 0 70#define RC2_DECRYPT 0
diff --git a/src/lib/libcrypto/rc2/rc2_ecb.c b/src/lib/libcrypto/rc2/rc2_ecb.c
deleted file mode 100644
index 6a3c8098eb..0000000000
--- a/src/lib/libcrypto/rc2/rc2_ecb.c
+++ /dev/null
@@ -1,91 +0,0 @@
1/* $OpenBSD: rc2_ecb.c,v 1.9 2023/07/07 13:40:44 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc2.h>
60#include "rc2_local.h"
61#include <openssl/opensslv.h>
62
63/* RC2 as implemented frm a posting from
64 * Newsgroups: sci.crypt
65 * Sender: pgut01@cs.auckland.ac.nz (Peter Gutmann)
66 * Subject: Specification for Ron Rivests Cipher No.2
67 * Message-ID: <4fk39f$f70@net.auckland.ac.nz>
68 * Date: 11 Feb 1996 06:45:03 GMT
69 */
70
71void
72RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, RC2_KEY *ks,
73 int encrypt)
74{
75 unsigned long l, d[2];
76
77 c2l(in, l);
78 d[0] = l;
79 c2l(in, l);
80 d[1] = l;
81 if (encrypt)
82 RC2_encrypt(d, ks);
83 else
84 RC2_decrypt(d, ks);
85 l = d[0];
86 l2c(l, out);
87 l = d[1];
88 l2c(l, out);
89 l = d[0] = d[1] = 0;
90}
91LCRYPTO_ALIAS(RC2_ecb_encrypt);
diff --git a/src/lib/libcrypto/rc2/rc2_skey.c b/src/lib/libcrypto/rc2/rc2_skey.c
deleted file mode 100644
index d33c02da8c..0000000000
--- a/src/lib/libcrypto/rc2/rc2_skey.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/* $OpenBSD: rc2_skey.c,v 1.15 2023/07/07 13:40:44 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/crypto.h>
60#include <openssl/rc2.h>
61#include "rc2_local.h"
62
63static const unsigned char key_table[256]={
64 0xd9,0x78,0xf9,0xc4,0x19,0xdd,0xb5,0xed,0x28,0xe9,0xfd,0x79,
65 0x4a,0xa0,0xd8,0x9d,0xc6,0x7e,0x37,0x83,0x2b,0x76,0x53,0x8e,
66 0x62,0x4c,0x64,0x88,0x44,0x8b,0xfb,0xa2,0x17,0x9a,0x59,0xf5,
67 0x87,0xb3,0x4f,0x13,0x61,0x45,0x6d,0x8d,0x09,0x81,0x7d,0x32,
68 0xbd,0x8f,0x40,0xeb,0x86,0xb7,0x7b,0x0b,0xf0,0x95,0x21,0x22,
69 0x5c,0x6b,0x4e,0x82,0x54,0xd6,0x65,0x93,0xce,0x60,0xb2,0x1c,
70 0x73,0x56,0xc0,0x14,0xa7,0x8c,0xf1,0xdc,0x12,0x75,0xca,0x1f,
71 0x3b,0xbe,0xe4,0xd1,0x42,0x3d,0xd4,0x30,0xa3,0x3c,0xb6,0x26,
72 0x6f,0xbf,0x0e,0xda,0x46,0x69,0x07,0x57,0x27,0xf2,0x1d,0x9b,
73 0xbc,0x94,0x43,0x03,0xf8,0x11,0xc7,0xf6,0x90,0xef,0x3e,0xe7,
74 0x06,0xc3,0xd5,0x2f,0xc8,0x66,0x1e,0xd7,0x08,0xe8,0xea,0xde,
75 0x80,0x52,0xee,0xf7,0x84,0xaa,0x72,0xac,0x35,0x4d,0x6a,0x2a,
76 0x96,0x1a,0xd2,0x71,0x5a,0x15,0x49,0x74,0x4b,0x9f,0xd0,0x5e,
77 0x04,0x18,0xa4,0xec,0xc2,0xe0,0x41,0x6e,0x0f,0x51,0xcb,0xcc,
78 0x24,0x91,0xaf,0x50,0xa1,0xf4,0x70,0x39,0x99,0x7c,0x3a,0x85,
79 0x23,0xb8,0xb4,0x7a,0xfc,0x02,0x36,0x5b,0x25,0x55,0x97,0x31,
80 0x2d,0x5d,0xfa,0x98,0xe3,0x8a,0x92,0xae,0x05,0xdf,0x29,0x10,
81 0x67,0x6c,0xba,0xc9,0xd3,0x00,0xe6,0xcf,0xe1,0x9e,0xa8,0x2c,
82 0x63,0x16,0x01,0x3f,0x58,0xe2,0x89,0xa9,0x0d,0x38,0x34,0x1b,
83 0xab,0x33,0xff,0xb0,0xbb,0x48,0x0c,0x5f,0xb9,0xb1,0xcd,0x2e,
84 0xc5,0xf3,0xdb,0x47,0xe5,0xa5,0x9c,0x77,0x0a,0xa6,0x20,0x68,
85 0xfe,0x7f,0xc1,0xad,
86 };
87
88/* It has come to my attention that there are 2 versions of the RC2
89 * key schedule. One which is normal, and anther which has a hook to
90 * use a reduced key length.
91 * BSAFE uses the 'retarded' version. What I previously shipped is
92 * the same as specifying 1024 for the 'bits' parameter. Bsafe uses
93 * a version where the bits parameter is the same as len*8 */
94void
95RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits)
96{
97 int i, j;
98 unsigned char *k;
99 RC2_INT *ki;
100 unsigned int c, d;
101
102 k = (unsigned char *)&(key->data[0]);
103 *k = 0; /* for if there is a zero length key */
104
105 if (len > 128)
106 len = 128;
107 if (bits <= 0)
108 bits = 1024;
109 if (bits > 1024)
110 bits = 1024;
111
112 for (i = 0; i < len; i++)
113 k[i] = data[i];
114
115 /* expand table */
116 d = k[len - 1];
117 j = 0;
118 for (i = len; i < 128; i++, j++)
119 {
120 d = key_table[(k[j] + d) & 0xff];
121 k[i] = d;
122 }
123
124 /* hmm.... key reduction to 'bits' bits */
125
126 j = (bits + 7) >> 3;
127 i = 128 - j;
128 c = (0xff >> (-bits & 0x07));
129
130 d = key_table[k[i] & c];
131 k[i] = d;
132 while (i--) {
133 d = key_table[k[i + j] ^ d];
134 k[i] = d;
135 }
136
137 /* copy from bytes into RC2_INT's */
138 ki = &(key->data[63]);
139 for (i = 127; i >= 0; i -= 2)
140 *(ki--) = ((k[i] << 8)|k[i - 1]) & 0xffff;
141}
142LCRYPTO_ALIAS(RC2_set_key);
diff --git a/src/lib/libcrypto/rc2/rc2cfb64.c b/src/lib/libcrypto/rc2/rc2cfb64.c
deleted file mode 100644
index 21266c430b..0000000000
--- a/src/lib/libcrypto/rc2/rc2cfb64.c
+++ /dev/null
@@ -1,124 +0,0 @@
1/* $OpenBSD: rc2cfb64.c,v 1.8 2023/07/07 13:40:44 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc2.h>
60#include "rc2_local.h"
61
62/* The input and output encrypted as though 64bit cfb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66
67void
68RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,
69 long length, RC2_KEY *schedule, unsigned char *ivec,
70 int *num, int encrypt)
71{
72 unsigned long v0, v1, t;
73 int n = *num;
74 long l = length;
75 unsigned long ti[2];
76 unsigned char *iv, c, cc;
77
78 iv = (unsigned char *)ivec;
79 if (encrypt) {
80 while (l--) {
81 if (n == 0) {
82 c2l(iv, v0);
83 ti[0] = v0;
84 c2l(iv, v1);
85 ti[1] = v1;
86 RC2_encrypt((unsigned long *)ti, schedule);
87 iv = (unsigned char *)ivec;
88 t = ti[0];
89 l2c(t, iv);
90 t = ti[1];
91 l2c(t, iv);
92 iv = (unsigned char *)ivec;
93 }
94 c = *(in++) ^ iv[n];
95 *(out++) = c;
96 iv[n] = c;
97 n = (n + 1) & 0x07;
98 }
99 } else {
100 while (l--) {
101 if (n == 0) {
102 c2l(iv, v0);
103 ti[0] = v0;
104 c2l(iv, v1);
105 ti[1] = v1;
106 RC2_encrypt((unsigned long *)ti, schedule);
107 iv = (unsigned char *)ivec;
108 t = ti[0];
109 l2c(t, iv);
110 t = ti[1];
111 l2c(t, iv);
112 iv = (unsigned char *)ivec;
113 }
114 cc = *(in++);
115 c = iv[n];
116 iv[n] = cc;
117 *(out++) = c ^ cc;
118 n = (n + 1) & 0x07;
119 }
120 }
121 v0 = v1 = ti[0] = ti[1] = t = c = cc = 0;
122 *num = n;
123}
124LCRYPTO_ALIAS(RC2_cfb64_encrypt);
diff --git a/src/lib/libcrypto/rc2/rc2ofb64.c b/src/lib/libcrypto/rc2/rc2ofb64.c
deleted file mode 100644
index 73d8323e92..0000000000
--- a/src/lib/libcrypto/rc2/rc2ofb64.c
+++ /dev/null
@@ -1,111 +0,0 @@
1/* $OpenBSD: rc2ofb64.c,v 1.8 2023/07/07 13:40:44 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/rc2.h>
60#include "rc2_local.h"
61
62/* The input and output encrypted as though 64bit ofb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66void
67RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,
68 long length, RC2_KEY *schedule, unsigned char *ivec,
69 int *num)
70{
71 unsigned long v0, v1, t;
72 int n = *num;
73 long l = length;
74 unsigned char d[8];
75 char *dp;
76 unsigned long ti[2];
77 unsigned char *iv;
78 int save = 0;
79
80 iv = (unsigned char *)ivec;
81 c2l(iv, v0);
82 c2l(iv, v1);
83 ti[0] = v0;
84 ti[1] = v1;
85 dp = (char *)d;
86 l2c(v0, dp);
87 l2c(v1, dp);
88 while (l--) {
89 if (n == 0) {
90 RC2_encrypt((unsigned long *)ti, schedule);
91 dp = (char *)d;
92 t = ti[0];
93 l2c(t, dp);
94 t = ti[1];
95 l2c(t, dp);
96 save++;
97 }
98 *(out++) = *(in++) ^ d[n];
99 n = (n + 1) & 0x07;
100 }
101 if (save) {
102 v0 = ti[0];
103 v1 = ti[1];
104 iv = (unsigned char *)ivec;
105 l2c(v0, iv);
106 l2c(v1, iv);
107 }
108 t = v0 = v1 = ti[0] = ti[1] = 0;
109 *num = n;
110}
111LCRYPTO_ALIAS(RC2_ofb64_encrypt);
diff --git a/src/lib/libcrypto/rc2/rrc2.doc b/src/lib/libcrypto/rc2/rrc2.doc
deleted file mode 100644
index f93ee003d2..0000000000
--- a/src/lib/libcrypto/rc2/rrc2.doc
+++ /dev/null
@@ -1,219 +0,0 @@
1>From cygnus.mincom.oz.au!minbne.mincom.oz.au!bunyip.cc.uq.oz.au!munnari.OZ.AU!comp.vuw.ac.nz!waikato!auckland.ac.nz!news Mon Feb 12 18:48:17 EST 1996
2Article 23601 of sci.crypt:
3Path: cygnus.mincom.oz.au!minbne.mincom.oz.au!bunyip.cc.uq.oz.au!munnari.OZ.AU!comp.vuw.ac.nz!waikato!auckland.ac.nz!news
4>From: pgut01@cs.auckland.ac.nz (Peter Gutmann)
5Newsgroups: sci.crypt
6Subject: Specification for Ron Rivests Cipher No.2
7Date: 11 Feb 1996 06:45:03 GMT
8Organization: University of Auckland
9Lines: 203
10Sender: pgut01@cs.auckland.ac.nz (Peter Gutmann)
11Message-ID: <4fk39f$f70@net.auckland.ac.nz>
12NNTP-Posting-Host: cs26.cs.auckland.ac.nz
13X-Newsreader: NN version 6.5.0 #3 (NOV)
14
15
16
17
18 Ron Rivest's Cipher No.2
19 ------------------------
20
21Ron Rivest's Cipher No.2 (hereafter referred to as RRC.2, other people may
22refer to it by other names) is word oriented, operating on a block of 64 bits
23divided into four 16-bit words, with a key table of 64 words. All data units
24are little-endian. This functional description of the algorithm is based in
25the paper "The RC5 Encryption Algorithm" (RC5 is a trademark of RSADSI), using
26the same general layout, terminology, and pseudocode style.
27
28
29Notation and RRC.2 Primitive Operations
30
31RRC.2 uses the following primitive operations:
32
331. Two's-complement addition of words, denoted by "+". The inverse operation,
34 subtraction, is denoted by "-".
352. Bitwise exclusive OR, denoted by "^".
363. Bitwise AND, denoted by "&".
374. Bitwise NOT, denoted by "~".
385. A left-rotation of words; the rotation of word x left by y is denoted
39 x <<< y. The inverse operation, right-rotation, is denoted x >>> y.
40
41These operations are directly and efficiently supported by most processors.
42
43
44The RRC.2 Algorithm
45
46RRC.2 consists of three components, a *key expansion* algorithm, an
47*encryption* algorithm, and a *decryption* algorithm.
48
49
50Key Expansion
51
52The purpose of the key-expansion routine is to expand the user's key K to fill
53the expanded key array S, so S resembles an array of random binary words
54determined by the user's secret key K.
55
56Initialising the S-box
57
58RRC.2 uses a single 256-byte S-box derived from the ciphertext contents of
59Beale Cipher No.1 XOR'd with a one-time pad. The Beale Ciphers predate modern
60cryptography by enough time that there should be no concerns about trapdoors
61hidden in the data. They have been published widely, and the S-box can be
62easily recreated from the one-time pad values and the Beale Cipher data taken
63from a standard source. To initialise the S-box:
64
65 for i = 0 to 255 do
66 sBox[ i ] = ( beale[ i ] mod 256 ) ^ pad[ i ]
67
68The contents of Beale Cipher No.1 and the necessary one-time pad are given as
69an appendix at the end of this document. For efficiency, implementors may wish
70to skip the Beale Cipher expansion and store the sBox table directly.
71
72Expanding the Secret Key to 128 Bytes
73
74The secret key is first expanded to fill 128 bytes (64 words). The expansion
75consists of taking the sum of the first and last bytes in the user key, looking
76up the sum (modulo 256) in the S-box, and appending the result to the key. The
77operation is repeated with the second byte and new last byte of the key until
78all 128 bytes have been generated. Note that the following pseudocode treats
79the S array as an array of 128 bytes rather than 64 words.
80
81 for j = 0 to length-1 do
82 S[ j ] = K[ j ]
83 for j = length to 127 do
84 s[ j ] = sBox[ ( S[ j-length ] + S[ j-1 ] ) mod 256 ];
85
86At this point it is possible to perform a truncation of the effective key
87length to ease the creation of espionage-enabled software products. However
88since the author cannot conceive why anyone would want to do this, it will not
89be considered further.
90
91The final phase of the key expansion involves replacing the first byte of S
92with the entry selected from the S-box:
93
94 S[ 0 ] = sBox[ S[ 0 ] ]
95
96
97Encryption
98
99The cipher has 16 full rounds, each divided into 4 subrounds. Two of the full
100rounds perform an additional transformation on the data. Note that the
101following pseudocode treats the S array as an array of 64 words rather than 128
102bytes.
103
104 for i = 0 to 15 do
105 j = i * 4;
106 word0 = ( word0 + ( word1 & ~word3 ) + ( word2 & word3 ) + S[ j+0 ] ) <<< 1
107 word1 = ( word1 + ( word2 & ~word0 ) + ( word3 & word0 ) + S[ j+1 ] ) <<< 2
108 word2 = ( word2 + ( word3 & ~word1 ) + ( word0 & word1 ) + S[ j+2 ] ) <<< 3
109 word3 = ( word3 + ( word0 & ~word2 ) + ( word1 & word2 ) + S[ j+3 ] ) <<< 5
110
111In addition the fifth and eleventh rounds add the contents of the S-box indexed
112by one of the data words to another of the data words following the four
113subrounds as follows:
114
115 word0 = word0 + S[ word3 & 63 ];
116 word1 = word1 + S[ word0 & 63 ];
117 word2 = word2 + S[ word1 & 63 ];
118 word3 = word3 + S[ word2 & 63 ];
119
120
121Decryption
122
123The decryption operation is simply the inverse of the encryption operation.
124Note that the following pseudocode treats the S array as an array of 64 words
125rather than 128 bytes.
126
127 for i = 15 downto 0 do
128 j = i * 4;
129 word3 = ( word3 >>> 5 ) - ( word0 & ~word2 ) - ( word1 & word2 ) - S[ j+3 ]
130 word2 = ( word2 >>> 3 ) - ( word3 & ~word1 ) - ( word0 & word1 ) - S[ j+2 ]
131 word1 = ( word1 >>> 2 ) - ( word2 & ~word0 ) - ( word3 & word0 ) - S[ j+1 ]
132 word0 = ( word0 >>> 1 ) - ( word1 & ~word3 ) - ( word2 & word3 ) - S[ j+0 ]
133
134In addition the fifth and eleventh rounds subtract the contents of the S-box
135indexed by one of the data words from another one of the data words following
136the four subrounds as follows:
137
138 word3 = word3 - S[ word2 & 63 ]
139 word2 = word2 - S[ word1 & 63 ]
140 word1 = word1 - S[ word0 & 63 ]
141 word0 = word0 - S[ word3 & 63 ]
142
143
144Test Vectors
145
146The following test vectors may be used to test the correctness of an RRC.2
147implementation:
148
149 Key: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
151 Plain: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
152 Cipher: 0x1C, 0x19, 0x8A, 0x83, 0x8D, 0xF0, 0x28, 0xB7
153
154 Key: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
156 Plain: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
157 Cipher: 0x21, 0x82, 0x9C, 0x78, 0xA9, 0xF9, 0xC0, 0x74
158
159 Key: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
161 Plain: 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
162 Cipher: 0x13, 0xDB, 0x35, 0x17, 0xD3, 0x21, 0x86, 0x9E
163
164 Key: 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
165 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
166 Plain: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
167 Cipher: 0x50, 0xDC, 0x01, 0x62, 0xBD, 0x75, 0x7F, 0x31
168
169
170Appendix: Beale Cipher No.1, "The Locality of the Vault", and One-time Pad for
171 Creating the S-Box
172
173Beale Cipher No.1.
174
175 71, 194, 38,1701, 89, 76, 11, 83,1629, 48, 94, 63, 132, 16, 111, 95,
176 84, 341, 975, 14, 40, 64, 27, 81, 139, 213, 63, 90,1120, 8, 15, 3,
177 126,2018, 40, 74, 758, 485, 604, 230, 436, 664, 582, 150, 251, 284, 308, 231,
178 124, 211, 486, 225, 401, 370, 11, 101, 305, 139, 189, 17, 33, 88, 208, 193,
179 145, 1, 94, 73, 416, 918, 263, 28, 500, 538, 356, 117, 136, 219, 27, 176,
180 130, 10, 460, 25, 485, 18, 436, 65, 84, 200, 283, 118, 320, 138, 36, 416,
181 280, 15, 71, 224, 961, 44, 16, 401, 39, 88, 61, 304, 12, 21, 24, 283,
182 134, 92, 63, 246, 486, 682, 7, 219, 184, 360, 780, 18, 64, 463, 474, 131,
183 160, 79, 73, 440, 95, 18, 64, 581, 34, 69, 128, 367, 460, 17, 81, 12,
184 103, 820, 62, 110, 97, 103, 862, 70, 60,1317, 471, 540, 208, 121, 890, 346,
185 36, 150, 59, 568, 614, 13, 120, 63, 219, 812,2160,1780, 99, 35, 18, 21,
186 136, 872, 15, 28, 170, 88, 4, 30, 44, 112, 18, 147, 436, 195, 320, 37,
187 122, 113, 6, 140, 8, 120, 305, 42, 58, 461, 44, 106, 301, 13, 408, 680,
188 93, 86, 116, 530, 82, 568, 9, 102, 38, 416, 89, 71, 216, 728, 965, 818,
189 2, 38, 121, 195, 14, 326, 148, 234, 18, 55, 131, 234, 361, 824, 5, 81,
190 623, 48, 961, 19, 26, 33, 10,1101, 365, 92, 88, 181, 275, 346, 201, 206
191
192One-time Pad.
193
194 158, 186, 223, 97, 64, 145, 190, 190, 117, 217, 163, 70, 206, 176, 183, 194,
195 146, 43, 248, 141, 3, 54, 72, 223, 233, 153, 91, 210, 36, 131, 244, 161,
196 105, 120, 113, 191, 113, 86, 19, 245, 213, 221, 43, 27, 242, 157, 73, 213,
197 193, 92, 166, 10, 23, 197, 112, 110, 193, 30, 156, 51, 125, 51, 158, 67,
198 197, 215, 59, 218, 110, 246, 181, 0, 135, 76, 164, 97, 47, 87, 234, 108,
199 144, 127, 6, 6, 222, 172, 80, 144, 22, 245, 207, 70, 227, 182, 146, 134,
200 119, 176, 73, 58, 135, 69, 23, 198, 0, 170, 32, 171, 176, 129, 91, 24,
201 126, 77, 248, 0, 118, 69, 57, 60, 190, 171, 217, 61, 136, 169, 196, 84,
202 168, 167, 163, 102, 223, 64, 174, 178, 166, 239, 242, 195, 249, 92, 59, 38,
203 241, 46, 236, 31, 59, 114, 23, 50, 119, 186, 7, 66, 212, 97, 222, 182,
204 230, 118, 122, 86, 105, 92, 179, 243, 255, 189, 223, 164, 194, 215, 98, 44,
205 17, 20, 53, 153, 137, 224, 176, 100, 208, 114, 36, 200, 145, 150, 215, 20,
206 87, 44, 252, 20, 235, 242, 163, 132, 63, 18, 5, 122, 74, 97, 34, 97,
207 142, 86, 146, 221, 179, 166, 161, 74, 69, 182, 88, 120, 128, 58, 76, 155,
208 15, 30, 77, 216, 165, 117, 107, 90, 169, 127, 143, 181, 208, 137, 200, 127,
209 170, 195, 26, 84, 255, 132, 150, 58, 103, 250, 120, 221, 237, 37, 8, 99
210
211
212Implementation
213
214A non-US based programmer who has never seen any encryption code before will
215shortly be implementing RRC.2 based solely on this specification and not on
216knowledge of any other encryption algorithms. Stand by.
217
218
219
diff --git a/src/lib/libcrypto/rc2/version b/src/lib/libcrypto/rc2/version
deleted file mode 100644
index 8ca161a613..0000000000
--- a/src/lib/libcrypto/rc2/version
+++ /dev/null
@@ -1,22 +0,0 @@
11.1 23/08/96 - eay
2 Changed RC2_set_key() so it now takes another argument. Many
3 thanks to Peter Gutmann <pgut01@cs.auckland.ac.nz> for the
4 clarification and original specification of RC2. BSAFE uses
5 this last parameter, 'bits'. It the key is 128 bits, BSAFE
6 also sets this parameter to 128. The old behaviour can be
7 duplicated by setting this parameter to 1024.
8
91.0 08/04/96 - eay
10 First version of SSLeay with rc2. This has been written from the spec
11 posted sci.crypt. It is in this directory under rrc2.doc
12 I have no test values for any mode other than ecb, my wrappers for the
13 other modes should be ok since they are basically the same as
14 the ones taken from idea and des :-). I have implemented them as
15 little-endian operators.
16 While rc2 is included because it is used with SSL, I don't know how
17 far I trust it. It is about the same speed as IDEA and DES.
18 So if you are paranoid, used Triple DES, else IDEA. If RC2
19 does get used more, perhaps more people will look for weaknesses in
20 it.
21
22
diff --git a/src/lib/libcrypto/rc4/rc4.c b/src/lib/libcrypto/rc4/rc4.c
index 56ed43cba7..69b7d0a815 100644
--- a/src/lib/libcrypto/rc4/rc4.c
+++ b/src/lib/libcrypto/rc4/rc4.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rc4.c,v 1.13 2025/01/27 14:02:32 jsing Exp $ */ 1/* $OpenBSD: rc4.c,v 1.15 2025/08/17 08:04:25 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -57,234 +57,123 @@
57 */ 57 */
58 58
59#include <endian.h> 59#include <endian.h>
60#include <stdint.h>
60 61
61#include <openssl/rc4.h> 62#include <openssl/rc4.h>
62 63
63#include "crypto_arch.h" 64#include "crypto_arch.h"
64 65
65/* RC4 as implemented from a posting from
66 * Newsgroups: sci.crypt
67 * From: sterndark@netcom.com (David Sterndark)
68 * Subject: RC4 Algorithm revealed.
69 * Message-ID: <sternCvKL4B.Hyy@netcom.com>
70 * Date: Wed, 14 Sep 1994 06:35:31 GMT
71 */
72
73#ifdef HAVE_RC4_INTERNAL 66#ifdef HAVE_RC4_INTERNAL
74void rc4_internal(RC4_KEY *key, size_t len, const unsigned char *indata, 67void rc4_internal(RC4_KEY *key, size_t len, const uint8_t *in,
75 unsigned char *outdata); 68 uint8_t *out);
76 69
77#else 70#else
78static void 71static inline RC4_INT
79rc4_internal(RC4_KEY *key, size_t len, const unsigned char *indata, 72rc4_step(RC4_INT *d, RC4_INT *x, RC4_INT *y)
80 unsigned char *outdata)
81{ 73{
82 RC4_INT *d; 74 RC4_INT tx, ty;
83 RC4_INT x, y,tx, ty;
84 size_t i;
85 75
86 x = key->x; 76 *x = (*x + 1) & 0xff;
87 y = key->y; 77 tx = d[*x];
88 d = key->data; 78 *y = (tx + *y) & 0xff;
79 d[*x] = ty = d[*y];
80 d[*y] = tx;
89 81
90#if defined(RC4_CHUNK) 82 return d[(tx + ty) & 0xff];
91 /* 83}
92 * The original reason for implementing this(*) was the fact that
93 * pre-21164a Alpha CPUs don't have byte load/store instructions
94 * and e.g. a byte store has to be done with 64-bit load, shift,
95 * and, or and finally 64-bit store. Peaking data and operating
96 * at natural word size made it possible to reduce amount of
97 * instructions as well as to perform early read-ahead without
98 * suffering from RAW (read-after-write) hazard. This resulted
99 * in ~40%(**) performance improvement on 21064 box with gcc.
100 * But it's not only Alpha users who win here:-) Thanks to the
101 * early-n-wide read-ahead this implementation also exhibits
102 * >40% speed-up on SPARC and 20-30% on 64-bit MIPS (depending
103 * on sizeof(RC4_INT)).
104 *
105 * (*) "this" means code which recognizes the case when input
106 * and output pointers appear to be aligned at natural CPU
107 * word boundary
108 * (**) i.e. according to 'apps/openssl speed rc4' benchmark,
109 * crypto/rc4/rc4speed.c exhibits almost 70% speed-up...
110 *
111 * Caveats.
112 *
113 * - RC4_CHUNK="unsigned long long" should be a #1 choice for
114 * UltraSPARC. Unfortunately gcc generates very slow code
115 * (2.5-3 times slower than one generated by Sun's WorkShop
116 * C) and therefore gcc (at least 2.95 and earlier) should
117 * always be told that RC4_CHUNK="unsigned long".
118 *
119 * <appro@fy.chalmers.se>
120 */
121 84
122# define RC4_STEP ( \ 85#if BYTE_ORDER == BIG_ENDIAN
123 x=(x+1) &0xff, \ 86static inline uint64_t
124 tx=d[x], \ 87rc4_chunk(RC4_INT *d, RC4_INT *x, RC4_INT *y)
125 y=(tx+y)&0xff, \ 88{
126 ty=d[y], \ 89 uint64_t chunk = 0;
127 d[y]=tx, \ 90 size_t i;
128 d[x]=ty, \
129 (RC4_CHUNK)d[(tx+ty)&0xff]\
130 )
131 91
132 if ((((size_t)indata & (sizeof(RC4_CHUNK) - 1)) | 92 for (i = 0; i < 8; i++)
133 ((size_t)outdata & (sizeof(RC4_CHUNK) - 1))) == 0 ) { 93 chunk = chunk << 8 | (uint64_t)rc4_step(d, x, y);
134 RC4_CHUNK ichunk, otp; 94
95 return chunk;
96}
135 97
136 /*
137 * I reckon we can afford to implement both endian
138 * cases and to decide which way to take at run-time
139 * because the machine code appears to be very compact
140 * and redundant 1-2KB is perfectly tolerable (i.e.
141 * in case the compiler fails to eliminate it:-). By
142 * suggestion from Terrel Larson <terr@terralogic.net>.
143 *
144 * Special notes.
145 *
146 * - compilers (those I've tried) don't seem to have
147 * problems eliminating either the operators guarded
148 * by "if (sizeof(RC4_CHUNK)==8)" or the condition
149 * expressions themselves so I've got 'em to replace
150 * corresponding #ifdefs from the previous version;
151 * - I chose to let the redundant switch cases when
152 * sizeof(RC4_CHUNK)!=8 be (were also #ifdefed
153 * before);
154 * - in case you wonder "&(sizeof(RC4_CHUNK)*8-1)" in
155 * [LB]ESHFT guards against "shift is out of range"
156 * warnings when sizeof(RC4_CHUNK)!=8
157 *
158 * <appro@fy.chalmers.se>
159 */
160#if BYTE_ORDER == BIG_ENDIAN
161# define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1))
162 for (; len & (0 - sizeof(RC4_CHUNK)); len -= sizeof(RC4_CHUNK)) {
163 ichunk = *(RC4_CHUNK *)indata;
164 otp = RC4_STEP << BESHFT(0);
165 otp |= RC4_STEP << BESHFT(1);
166 otp |= RC4_STEP << BESHFT(2);
167 otp |= RC4_STEP << BESHFT(3);
168 if (sizeof(RC4_CHUNK) == 8) {
169 otp |= RC4_STEP << BESHFT(4);
170 otp |= RC4_STEP << BESHFT(5);
171 otp |= RC4_STEP << BESHFT(6);
172 otp |= RC4_STEP << BESHFT(7);
173 }
174 *(RC4_CHUNK *)outdata = otp^ichunk;
175 indata += sizeof(RC4_CHUNK);
176 outdata += sizeof(RC4_CHUNK);
177 }
178#else 98#else
179# define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1)) 99static inline uint64_t
180 for (; len & (0 - sizeof(RC4_CHUNK)); len -= sizeof(RC4_CHUNK)) { 100rc4_chunk(RC4_INT *d, RC4_INT *x, RC4_INT *y)
181 ichunk = *(RC4_CHUNK *)indata; 101{
182 otp = RC4_STEP; 102 uint64_t chunk = 0;
183 otp |= RC4_STEP << 8; 103 size_t i;
184 otp |= RC4_STEP << 16; 104
185 otp |= RC4_STEP << 24; 105 for (i = 0; i < 8; i++)
186 if (sizeof(RC4_CHUNK) == 8) { 106 chunk |= (uint64_t)rc4_step(d, x, y) << (i * 8);
187 otp |= RC4_STEP << LESHFT(4); 107
188 otp |= RC4_STEP << LESHFT(5); 108 return chunk;
189 otp |= RC4_STEP << LESHFT(6); 109}
190 otp |= RC4_STEP << LESHFT(7);
191 }
192 *(RC4_CHUNK *)outdata = otp ^ ichunk;
193 indata += sizeof(RC4_CHUNK);
194 outdata += sizeof(RC4_CHUNK);
195 }
196#endif
197 }
198#endif 110#endif
199#define RC4_LOOP(in,out) \
200 x=((x+1)&0xff); \
201 tx=d[x]; \
202 y=(tx+y)&0xff; \
203 d[x]=ty=d[y]; \
204 d[y]=tx; \
205 (out) = d[(tx+ty)&0xff]^ (in);
206 111
207 i = len >> 3; 112static void
208 if (i) { 113rc4_internal(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out)
209 for (;;) { 114{
210 RC4_LOOP(indata[0], outdata[0]); 115 RC4_INT *d, x, y;
211 RC4_LOOP(indata[1], outdata[1]); 116 size_t i;
212 RC4_LOOP(indata[2], outdata[2]);
213 RC4_LOOP(indata[3], outdata[3]);
214 RC4_LOOP(indata[4], outdata[4]);
215 RC4_LOOP(indata[5], outdata[5]);
216 RC4_LOOP(indata[6], outdata[6]);
217 RC4_LOOP(indata[7], outdata[7]);
218 117
219 indata += 8; 118 x = key->x;
220 outdata += 8; 119 y = key->y;
120 d = key->data;
121
122 /* Process uint64_t chunks if 8 byte aligned. */
123 if ((((size_t)in | (size_t)out) % 8) == 0) {
124 while (len >= 8) {
125 *(uint64_t *)out = *(const uint64_t *)in ^ rc4_chunk(d, &x, &y);
221 126
222 if (--i == 0) 127 in += 8;
223 break; 128 out += 8;
129 len -= 8;
224 } 130 }
225 } 131 }
226 i = len&0x07; 132
227 if (i) { 133 while (len >= 8) {
228 for (;;) { 134 for (i = 0; i < 8; i++)
229 RC4_LOOP(indata[0], outdata[0]); 135 out[i] = rc4_step(d, &x, &y) ^ in[i];
230 if (--i == 0) 136
231 break; 137 in += 8;
232 RC4_LOOP(indata[1], outdata[1]); 138 out += 8;
233 if (--i == 0) 139 len -= 8;
234 break;
235 RC4_LOOP(indata[2], outdata[2]);
236 if (--i == 0)
237 break;
238 RC4_LOOP(indata[3], outdata[3]);
239 if (--i == 0)
240 break;
241 RC4_LOOP(indata[4], outdata[4]);
242 if (--i == 0)
243 break;
244 RC4_LOOP(indata[5], outdata[5]);
245 if (--i == 0)
246 break;
247 RC4_LOOP(indata[6], outdata[6]);
248 if (--i == 0)
249 break;
250 }
251 } 140 }
141 for (i = 0; i < len; i++)
142 out[i] = rc4_step(d, &x, &y) ^ in[i];
143
252 key->x = x; 144 key->x = x;
253 key->y = y; 145 key->y = y;
254} 146}
255#endif 147#endif
256 148
257#ifdef HAVE_RC4_SET_KEY_INTERNAL 149#ifdef HAVE_RC4_SET_KEY_INTERNAL
258void rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data); 150void rc4_set_key_internal(RC4_KEY *key, int len, const uint8_t *data);
259 151
260#else 152#else
261static inline void 153static inline void
262rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data) 154rc4_set_key_internal(RC4_KEY *key, int len, const uint8_t *data)
263{ 155{
264 RC4_INT tmp; 156 RC4_INT *d, tmp;
265 int id1, id2; 157 int idx1, idx2;
266 RC4_INT *d; 158 int i, j;
267 unsigned int i;
268 159
269 d = &(key->data[0]); 160 d = key->data;
270 key->x = 0; 161 key->x = 0;
271 key->y = 0; 162 key->y = 0;
272 id1 = id2 = 0; 163 idx1 = idx2 = 0;
273
274#define SK_LOOP(d,n) { \
275 tmp=d[(n)]; \
276 id2 = (data[id1] + tmp + id2) & 0xff; \
277 if (++id1 == len) id1=0; \
278 d[(n)]=d[id2]; \
279 d[id2]=tmp; }
280 164
281 for (i = 0; i < 256; i++) 165 for (i = 0; i < 256; i++)
282 d[i] = i; 166 d[i] = i;
283 for (i = 0; i < 256; i += 4) { 167 for (i = 0; i < 256; i += 4) {
284 SK_LOOP(d, i + 0); 168 for (j = 0; j < 4; j++) {
285 SK_LOOP(d, i + 1); 169 tmp = d[i + j];
286 SK_LOOP(d, i + 2); 170 idx2 = (data[idx1] + tmp + idx2) & 0xff;
287 SK_LOOP(d, i + 3); 171 d[i + j] = d[idx2];
172 d[idx2] = tmp;
173
174 if (++idx1 == len)
175 idx1 = 0;
176 }
288 } 177 }
289} 178}
290#endif 179#endif
diff --git a/src/lib/libcrypto/rc4/rc4.h b/src/lib/libcrypto/rc4/rc4.h
index a20472372b..c994b39a31 100644
--- a/src/lib/libcrypto/rc4/rc4.h
+++ b/src/lib/libcrypto/rc4/rc4.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: rc4.h,v 1.16 2025/01/25 17:59:44 tb Exp $ */ 1/* $OpenBSD: rc4.h,v 1.17 2025/06/09 14:37:49 tb Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,10 +59,15 @@
59#ifndef HEADER_RC4_H 59#ifndef HEADER_RC4_H
60#define HEADER_RC4_H 60#define HEADER_RC4_H
61 61
62#include <openssl/opensslconf.h> /* OPENSSL_NO_RC4, RC4_INT */ 62#include <openssl/opensslconf.h> /* OPENSSL_NO_RC4 */
63 63
64#include <stddef.h> 64#include <stddef.h>
65 65
66#ifndef RC4_INT
67/* XXX - typedef */
68#define RC4_INT unsigned int
69#endif
70
66#ifdef __cplusplus 71#ifdef __cplusplus
67extern "C" { 72extern "C" {
68#endif 73#endif
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c
index 5a87522289..00fa6afb3d 100644
--- a/src/lib/libcrypto/rsa/rsa_ameth.c
+++ b/src/lib/libcrypto/rsa/rsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_ameth.c,v 1.62 2024/11/02 07:11:14 tb Exp $ */ 1/* $OpenBSD: rsa_ameth.c,v 1.63 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -66,7 +66,6 @@
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/bn.h> 67#include <openssl/bn.h>
68#include <openssl/cms.h> 68#include <openssl/cms.h>
69#include <openssl/err.h>
70#include <openssl/evp.h> 69#include <openssl/evp.h>
71#include <openssl/objects.h> 70#include <openssl/objects.h>
72#include <openssl/pkcs7.h> 71#include <openssl/pkcs7.h>
@@ -76,6 +75,7 @@
76 75
77#include "asn1_local.h" 76#include "asn1_local.h"
78#include "bn_local.h" 77#include "bn_local.h"
78#include "err_local.h"
79#include "evp_local.h" 79#include "evp_local.h"
80#include "rsa_local.h" 80#include "rsa_local.h"
81#include "x509_local.h" 81#include "x509_local.h"
diff --git a/src/lib/libcrypto/rsa/rsa_blinding.c b/src/lib/libcrypto/rsa/rsa_blinding.c
index cac5bd91d2..590b45f5a1 100644
--- a/src/lib/libcrypto/rsa/rsa_blinding.c
+++ b/src/lib/libcrypto/rsa/rsa_blinding.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_blinding.c,v 1.3 2023/08/09 12:09:06 tb Exp $ */ 1/* $OpenBSD: rsa_blinding.c,v 1.4 2025/05/10 05:54:38 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -114,10 +114,10 @@
114 114
115#include <openssl/opensslconf.h> 115#include <openssl/opensslconf.h>
116 116
117#include <openssl/err.h>
118#include <openssl/rsa.h> 117#include <openssl/rsa.h>
119 118
120#include "bn_local.h" 119#include "bn_local.h"
120#include "err_local.h"
121#include "rsa_local.h" 121#include "rsa_local.h"
122 122
123#define BN_BLINDING_COUNTER 32 123#define BN_BLINDING_COUNTER 32
diff --git a/src/lib/libcrypto/rsa/rsa_chk.c b/src/lib/libcrypto/rsa/rsa_chk.c
index b7666e0fed..87d261f88e 100644
--- a/src/lib/libcrypto/rsa/rsa_chk.c
+++ b/src/lib/libcrypto/rsa/rsa_chk.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_chk.c,v 1.18 2023/07/08 12:26:45 beck Exp $ */ 1/* $OpenBSD: rsa_chk.c,v 1.19 2025/05/10 05:54:38 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -49,10 +49,10 @@
49 */ 49 */
50 50
51#include <openssl/bn.h> 51#include <openssl/bn.h>
52#include <openssl/err.h>
53#include <openssl/rsa.h> 52#include <openssl/rsa.h>
54 53
55#include "bn_local.h" 54#include "bn_local.h"
55#include "err_local.h"
56#include "rsa_local.h" 56#include "rsa_local.h"
57 57
58int 58int
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index c2e1e22f9a..65ccfc35e1 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_eay.c,v 1.65 2023/08/09 12:09:06 tb Exp $ */ 1/* $OpenBSD: rsa_eay.c,v 1.66 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -115,10 +115,10 @@
115#include <openssl/opensslconf.h> 115#include <openssl/opensslconf.h>
116 116
117#include <openssl/bn.h> 117#include <openssl/bn.h>
118#include <openssl/err.h>
119#include <openssl/rsa.h> 118#include <openssl/rsa.h>
120 119
121#include "bn_local.h" 120#include "bn_local.h"
121#include "err_local.h"
122#include "rsa_local.h" 122#include "rsa_local.h"
123 123
124static int 124static int
diff --git a/src/lib/libcrypto/rsa/rsa_gen.c b/src/lib/libcrypto/rsa/rsa_gen.c
index ff64eb2f0e..ebd0aeffd5 100644
--- a/src/lib/libcrypto/rsa/rsa_gen.c
+++ b/src/lib/libcrypto/rsa/rsa_gen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_gen.c,v 1.30 2023/07/08 12:26:45 beck Exp $ */ 1/* $OpenBSD: rsa_gen.c,v 1.31 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,10 +60,10 @@
60#include <time.h> 60#include <time.h>
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/err.h>
64#include <openssl/rsa.h> 63#include <openssl/rsa.h>
65 64
66#include "bn_local.h" 65#include "bn_local.h"
66#include "err_local.h"
67#include "rsa_local.h" 67#include "rsa_local.h"
68 68
69static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb); 69static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb);
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index 91f4938ec9..7b8babdf52 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_lib.c,v 1.50 2024/03/27 01:22:30 tb Exp $ */ 1/* $OpenBSD: rsa_lib.c,v 1.51 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,12 +62,12 @@
62 62
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/crypto.h> 64#include <openssl/crypto.h>
65#include <openssl/err.h>
66#include <openssl/evp.h> 65#include <openssl/evp.h>
67#include <openssl/lhash.h> 66#include <openssl/lhash.h>
68#include <openssl/rsa.h> 67#include <openssl/rsa.h>
69 68
70#include "bn_local.h" 69#include "bn_local.h"
70#include "err_local.h"
71#include "evp_local.h" 71#include "evp_local.h"
72#include "rsa_local.h" 72#include "rsa_local.h"
73 73
diff --git a/src/lib/libcrypto/rsa/rsa_meth.c b/src/lib/libcrypto/rsa/rsa_meth.c
index 71608caa01..131c4484ab 100644
--- a/src/lib/libcrypto/rsa/rsa_meth.c
+++ b/src/lib/libcrypto/rsa/rsa_meth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_meth.c,v 1.7 2023/07/08 12:26:45 beck Exp $ */ 1/* $OpenBSD: rsa_meth.c,v 1.8 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -18,7 +18,6 @@
18#include <stdlib.h> 18#include <stdlib.h>
19#include <string.h> 19#include <string.h>
20 20
21#include <openssl/err.h>
22#include <openssl/rsa.h> 21#include <openssl/rsa.h>
23 22
24#include "rsa_local.h" 23#include "rsa_local.h"
diff --git a/src/lib/libcrypto/rsa/rsa_none.c b/src/lib/libcrypto/rsa/rsa_none.c
index 9c53dcf595..b8764d54ef 100644
--- a/src/lib/libcrypto/rsa/rsa_none.c
+++ b/src/lib/libcrypto/rsa/rsa_none.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_none.c,v 1.12 2023/07/08 12:26:45 beck Exp $ */ 1/* $OpenBSD: rsa_none.c,v 1.13 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,9 +60,10 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/err.h>
64#include <openssl/rsa.h> 63#include <openssl/rsa.h>
65 64
65#include "err_local.h"
66
66int 67int
67RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *from, 68RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *from,
68 int flen) 69 int flen)
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c
index d1e138c299..9a175f8c55 100644
--- a/src/lib/libcrypto/rsa/rsa_oaep.c
+++ b/src/lib/libcrypto/rsa/rsa_oaep.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_oaep.c,v 1.39 2024/03/26 05:37:28 joshua Exp $ */ 1/* $OpenBSD: rsa_oaep.c,v 1.40 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. 3 * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * 4 *
@@ -74,12 +74,12 @@
74#include <string.h> 74#include <string.h>
75 75
76#include <openssl/bn.h> 76#include <openssl/bn.h>
77#include <openssl/err.h>
78#include <openssl/evp.h> 77#include <openssl/evp.h>
79#include <openssl/rsa.h> 78#include <openssl/rsa.h>
80#include <openssl/sha.h> 79#include <openssl/sha.h>
81 80
82#include "constant_time.h" 81#include "constant_time.h"
82#include "err_local.h"
83#include "evp_local.h" 83#include "evp_local.h"
84#include "rsa_local.h" 84#include "rsa_local.h"
85 85
diff --git a/src/lib/libcrypto/rsa/rsa_pk1.c b/src/lib/libcrypto/rsa/rsa_pk1.c
index 8e56a8c4cd..554e00e8f8 100644
--- a/src/lib/libcrypto/rsa/rsa_pk1.c
+++ b/src/lib/libcrypto/rsa/rsa_pk1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_pk1.c,v 1.17 2024/03/30 04:34:17 jsing Exp $ */ 1/* $OpenBSD: rsa_pk1.c,v 1.18 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,10 +61,10 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/err.h>
65#include <openssl/rsa.h> 64#include <openssl/rsa.h>
66 65
67#include "bytestring.h" 66#include "bytestring.h"
67#include "err_local.h"
68 68
69int 69int
70RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, 70RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c
index 453570cf74..518b077dbc 100644
--- a/src/lib/libcrypto/rsa/rsa_pmeth.c
+++ b/src/lib/libcrypto/rsa/rsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_pmeth.c,v 1.43 2025/01/17 15:39:19 tb Exp $ */ 1/* $OpenBSD: rsa_pmeth.c,v 1.44 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -65,13 +65,13 @@
65 65
66#include <openssl/asn1t.h> 66#include <openssl/asn1t.h>
67#include <openssl/bn.h> 67#include <openssl/bn.h>
68#include <openssl/err.h>
69#include <openssl/evp.h> 68#include <openssl/evp.h>
70#include <openssl/rsa.h> 69#include <openssl/rsa.h>
71#include <openssl/x509.h> 70#include <openssl/x509.h>
72#include <openssl/x509v3.h> 71#include <openssl/x509v3.h>
73 72
74#include "bn_local.h" 73#include "bn_local.h"
74#include "err_local.h"
75#include "evp_local.h" 75#include "evp_local.h"
76#include "rsa_local.h" 76#include "rsa_local.h"
77 77
diff --git a/src/lib/libcrypto/rsa/rsa_prn.c b/src/lib/libcrypto/rsa/rsa_prn.c
index 1783563661..ef08f76249 100644
--- a/src/lib/libcrypto/rsa/rsa_prn.c
+++ b/src/lib/libcrypto/rsa/rsa_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_prn.c,v 1.10 2023/07/08 12:26:45 beck Exp $ */ 1/* $OpenBSD: rsa_prn.c,v 1.11 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -58,10 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/evp.h> 61#include <openssl/evp.h>
63#include <openssl/rsa.h> 62#include <openssl/rsa.h>
64 63
64#include "err_local.h"
65
65int 66int
66RSA_print_fp(FILE *fp, const RSA *x, int off) 67RSA_print_fp(FILE *fp, const RSA *x, int off)
67{ 68{
diff --git a/src/lib/libcrypto/rsa/rsa_pss.c b/src/lib/libcrypto/rsa/rsa_pss.c
index 610ae7c928..72e252ef06 100644
--- a/src/lib/libcrypto/rsa/rsa_pss.c
+++ b/src/lib/libcrypto/rsa/rsa_pss.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_pss.c,v 1.19 2024/03/26 05:26:27 joshua Exp $ */ 1/* $OpenBSD: rsa_pss.c,v 1.20 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2005. 3 * project 2005.
4 */ 4 */
@@ -61,11 +61,11 @@
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/err.h>
65#include <openssl/evp.h> 64#include <openssl/evp.h>
66#include <openssl/rsa.h> 65#include <openssl/rsa.h>
67#include <openssl/sha.h> 66#include <openssl/sha.h>
68 67
68#include "err_local.h"
69#include "evp_local.h" 69#include "evp_local.h"
70#include "rsa_local.h" 70#include "rsa_local.h"
71 71
diff --git a/src/lib/libcrypto/rsa/rsa_saos.c b/src/lib/libcrypto/rsa/rsa_saos.c
index 07a4f5d659..3052fa912f 100644
--- a/src/lib/libcrypto/rsa/rsa_saos.c
+++ b/src/lib/libcrypto/rsa/rsa_saos.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_saos.c,v 1.25 2023/07/08 12:26:45 beck Exp $ */ 1/* $OpenBSD: rsa_saos.c,v 1.26 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,11 +60,12 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/err.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/rsa.h> 64#include <openssl/rsa.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67 66
67#include "err_local.h"
68
68int 69int
69RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m, unsigned int m_len, 70RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m, unsigned int m_len,
70 unsigned char *sigret, unsigned int *siglen, RSA *rsa) 71 unsigned char *sigret, unsigned int *siglen, RSA *rsa)
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 6edd20626d..09e6972293 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_sign.c,v 1.37 2025/01/05 15:39:12 tb Exp $ */ 1/* $OpenBSD: rsa_sign.c,v 1.38 2025/05/10 05:54:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,12 +60,12 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/err.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/rsa.h> 64#include <openssl/rsa.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67 66
68#include "asn1_local.h" 67#include "asn1_local.h"
68#include "err_local.h"
69#include "rsa_local.h" 69#include "rsa_local.h"
70#include "x509_local.h" 70#include "x509_local.h"
71 71
diff --git a/src/lib/libcrypto/rsa/rsa_x931.c b/src/lib/libcrypto/rsa/rsa_x931.c
index 52f3f803b2..8a0190d7fe 100644
--- a/src/lib/libcrypto/rsa/rsa_x931.c
+++ b/src/lib/libcrypto/rsa/rsa_x931.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_x931.c,v 1.12 2023/05/05 12:19:37 tb Exp $ */ 1/* $OpenBSD: rsa_x931.c,v 1.13 2025/05/10 05:54:38 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2005. 3 * project 2005.
4 */ 4 */
@@ -60,10 +60,11 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/err.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/rsa.h> 64#include <openssl/rsa.h>
66 65
66#include "err_local.h"
67
67int 68int
68RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *from, 69RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *from,
69 int flen) 70 int flen)
diff --git a/src/lib/libcrypto/sha/asm/sha1-586.pl b/src/lib/libcrypto/sha/asm/sha1-586.pl
index 5928e083c1..d2491766f3 100644
--- a/src/lib/libcrypto/sha/asm/sha1-586.pl
+++ b/src/lib/libcrypto/sha/asm/sha1-586.pl
@@ -104,13 +104,7 @@ require "x86asm.pl";
104 104
105&asm_init($ARGV[0],"sha1-586.pl",$ARGV[$#ARGV] eq "386"); 105&asm_init($ARGV[0],"sha1-586.pl",$ARGV[$#ARGV] eq "386");
106 106
107$xmm=$ymm=0; 107$xmm=$ymm=1;
108for (@ARGV) { $xmm=1 if (/-DOPENSSL_IA32_SSE2/); }
109
110$ymm=1 if ($xmm &&
111 `$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
112 =~ /GNU assembler version ([2-9]\.[0-9]+)/ &&
113 $1>=2.19); # first version supporting AVX
114 108
115&external_label("OPENSSL_ia32cap_P") if ($xmm); 109&external_label("OPENSSL_ia32cap_P") if ($xmm);
116 110
diff --git a/src/lib/libcrypto/sha/asm/sha512-586.pl b/src/lib/libcrypto/sha/asm/sha512-586.pl
index c1d0684e92..fe1ff487bc 100644
--- a/src/lib/libcrypto/sha/asm/sha512-586.pl
+++ b/src/lib/libcrypto/sha/asm/sha512-586.pl
@@ -38,8 +38,7 @@ require "x86asm.pl";
38 38
39&asm_init($ARGV[0],"sha512-586.pl",$ARGV[$#ARGV] eq "386"); 39&asm_init($ARGV[0],"sha512-586.pl",$ARGV[$#ARGV] eq "386");
40 40
41$sse2=0; 41$sse2=1;
42for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
43 42
44&external_label("OPENSSL_ia32cap_P") if ($sse2); 43&external_label("OPENSSL_ia32cap_P") if ($sse2);
45 44
diff --git a/src/lib/libcrypto/sha/sha1_aarch64.c b/src/lib/libcrypto/sha/sha1_aarch64.c
new file mode 100644
index 0000000000..04c87761e0
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha1_aarch64.c
@@ -0,0 +1,34 @@
1/* $OpenBSD: sha1_aarch64.c,v 1.1 2025/06/28 12:51:08 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <openssl/sha.h>
19
20#include "crypto_arch.h"
21
22void sha1_block_ce(SHA256_CTX *ctx, const void *in, size_t num);
23void sha1_block_generic(SHA256_CTX *ctx, const void *in, size_t num);
24
25void
26sha1_block_data_order(SHA256_CTX *ctx, const void *in, size_t num)
27{
28 if ((crypto_cpu_caps_aarch64 & CRYPTO_CPU_CAPS_AARCH64_SHA1) != 0) {
29 sha1_block_ce(ctx, in, num);
30 return;
31 }
32
33 sha1_block_generic(ctx, in, num);
34}
diff --git a/src/lib/libcrypto/sha/sha1_aarch64_ce.S b/src/lib/libcrypto/sha/sha1_aarch64_ce.S
new file mode 100644
index 0000000000..8ccf230298
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha1_aarch64_ce.S
@@ -0,0 +1,214 @@
1/* $OpenBSD: sha1_aarch64_ce.S,v 1.1 2025/06/28 12:51:08 jsing Exp $ */
2/*
3 * Copyright (c) 2023,2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18/*
19 * SHA-1 implementation using the ARM Cryptographic Extension (CE).
20 *
21 * There are six instructions for hardware acceleration of SHA-1 - the
22 * documentation for these instructions is woefully inadequate:
23 *
24 * sha1c: hash update (choose)
25 * sha1h: fixed rotate
26 * sha1m: hash update (majority)
27 * sha1p: hash update (parity)
28 * sha1su0: message schedule update with sigma0 for four rounds
29 * sha1su1: message schedule update with sigma1 for four rounds
30 */
31
32#define ctx x0
33#define in x1
34#define num x2
35
36/* Note: the lower 64 bits of v8 through v15 are callee saved. */
37
38#define hc0 v16
39#define hc1 v17
40#define hc1s s17
41
42#define hs0 v18
43#define hs1 v19
44#define hs1s s19
45
46#define w0 v20
47#define w1 v21
48#define w2 v22
49#define w3 v23
50
51#define k0 v24
52#define k1 v25
53#define k2 v26
54#define k3 v27
55
56#define tmp0 v28
57#define tmp1 s29
58
59#define tmp2 w11
60
61/*
62 * Update message schedule for m0 (W0:W1:W2:W3), using m1 (W4:W5:W6:W7),
63 * m2 (W8:W9:W10:11) and m3 (W12:W13:W14:W15). The sha1su0 instruction computes
64 * W0 = W8 ^ W2 ^ W0, while sha1su1 computes rol(W0 ^ W13, 1).
65 */
66#define sha1_message_schedule_update(m0, m1, m2, m3) \
67 sha1su0 m0.4s, m1.4s, m2.4s; \
68 sha1su1 m0.4s, m3.4s;
69
70/*
71 * Compute four SHA-1 rounds by adding W0:W1:W2:W3 + K0:K1:K2:K3, then
72 * computing the remainder of each round (including the shuffle) via
73 * sha1{c,p,m}/sha1h.
74 */
75
76#define sha1_round1(h0, h1, w, k) \
77 add tmp0.4s, w.4s, k.4s; /* Tt = Wt + Kt */ \
78 mov tmp1, h0.s[0]; \
79 sha1c h0, h1, tmp0.4s; \
80 sha1h h1, tmp1;
81
82#define sha1_round2(h0, h1, w, k) \
83 add tmp0.4s, w.4s, k.4s; /* Tt = Wt + Kt */ \
84 mov tmp1, h0.s[0]; \
85 sha1p h0, h1, tmp0.4s; \
86 sha1h h1, tmp1;
87
88#define sha1_round3(h0, h1, w, k) \
89 add tmp0.4s, w.4s, k.4s; /* Tt = Wt + Kt */ \
90 mov tmp1, h0.s[0]; \
91 sha1m h0, h1, tmp0.4s; \
92 sha1h h1, tmp1;
93
94#define sha1_round4(h0, h1, w, k) \
95 add tmp0.4s, w.4s, k.4s; /* Tt = Wt + Kt */ \
96 mov tmp1, h0.s[0]; \
97 sha1p h0, h1, tmp0.4s; \
98 sha1h h1, tmp1;
99
100.arch armv8-a+sha2
101
102.text
103
104/*
105 * void sha1_block_ce(SHA256_CTX *ctx, const void *in, size_t num);
106 *
107 * Standard ARM ABI: x0 = ctx, x1 = in, x2 = num
108 */
109.globl sha1_block_ce
110.type sha1_block_ce,@function
111sha1_block_ce:
112
113 /*
114 * Load SHA-1 round constants.
115 */
116
117 /* Round 1 - 0x5a827999 */
118 movz tmp2, #0x5a82, lsl #16
119 movk tmp2, #0x7999
120 dup k0.4s, tmp2
121
122 /* Round 2 - 0x6ed9eba1 */
123 movz tmp2, #0x6ed9, lsl #16
124 movk tmp2, #0xeba1
125 dup k1.4s, tmp2
126
127 /* Round 3 - 0x8f1bbcdc */
128 movz tmp2, #0x8f1b, lsl #16
129 movk tmp2, #0xbcdc
130 dup k2.4s, tmp2
131
132 /* Round 4 - 0xca62c1d6 */
133 movz tmp2, #0xca62, lsl #16
134 movk tmp2, #0xc1d6
135 dup k3.4s, tmp2
136
137 /* Load current hash state from context (hc0 = a:b:c:d, hc1 = e). */
138 ld1 {hc0.4s}, [ctx]
139 ldr hc1s, [ctx, #(4*4)]
140
141block_loop:
142 /* Copy current hash state. */
143 mov hs0.4s, hc0.4s
144 mov hs1s, hc1.s[0]
145
146 /* Load and byte swap message schedule. */
147 ld1 {w0.16b, w1.16b, w2.16b, w3.16b}, [in], #64
148 rev32 w0.16b, w0.16b
149 rev32 w1.16b, w1.16b
150 rev32 w2.16b, w2.16b
151 rev32 w3.16b, w3.16b
152
153 /* Rounds 0 through 15 (four rounds at a time). */
154 sha1_round1(hs0, hs1s, w0, k0)
155 sha1_round1(hs0, hs1s, w1, k0)
156 sha1_round1(hs0, hs1s, w2, k0)
157 sha1_round1(hs0, hs1s, w3, k0)
158
159 /* Rounds 16 through 31 (four rounds at a time). */
160 sha1_message_schedule_update(w0, w1, w2, w3)
161 sha1_message_schedule_update(w1, w2, w3, w0)
162 sha1_message_schedule_update(w2, w3, w0, w1)
163 sha1_message_schedule_update(w3, w0, w1, w2)
164
165 sha1_round1(hs0, hs1s, w0, k0)
166 sha1_round2(hs0, hs1s, w1, k1)
167 sha1_round2(hs0, hs1s, w2, k1)
168 sha1_round2(hs0, hs1s, w3, k1)
169
170 /* Rounds 32 through 47 (four rounds at a time). */
171 sha1_message_schedule_update(w0, w1, w2, w3)
172 sha1_message_schedule_update(w1, w2, w3, w0)
173 sha1_message_schedule_update(w2, w3, w0, w1)
174 sha1_message_schedule_update(w3, w0, w1, w2)
175
176 sha1_round2(hs0, hs1s, w0, k1)
177 sha1_round2(hs0, hs1s, w1, k1)
178 sha1_round3(hs0, hs1s, w2, k2)
179 sha1_round3(hs0, hs1s, w3, k2)
180
181 /* Rounds 48 through 63 (four rounds at a time). */
182 sha1_message_schedule_update(w0, w1, w2, w3)
183 sha1_message_schedule_update(w1, w2, w3, w0)
184 sha1_message_schedule_update(w2, w3, w0, w1)
185 sha1_message_schedule_update(w3, w0, w1, w2)
186
187 sha1_round3(hs0, hs1s, w0, k2)
188 sha1_round3(hs0, hs1s, w1, k2)
189 sha1_round3(hs0, hs1s, w2, k2)
190 sha1_round4(hs0, hs1s, w3, k3)
191
192 /* Rounds 64 through 79 (four rounds at a time). */
193 sha1_message_schedule_update(w0, w1, w2, w3)
194 sha1_message_schedule_update(w1, w2, w3, w0)
195 sha1_message_schedule_update(w2, w3, w0, w1)
196 sha1_message_schedule_update(w3, w0, w1, w2)
197
198 sha1_round4(hs0, hs1s, w0, k3)
199 sha1_round4(hs0, hs1s, w1, k3)
200 sha1_round4(hs0, hs1s, w2, k3)
201 sha1_round4(hs0, hs1s, w3, k3)
202
203 /* Add intermediate state to hash state. */
204 add hc0.4s, hc0.4s, hs0.4s
205 add hc1.4s, hc1.4s, hs1.4s
206
207 sub num, num, #1
208 cbnz num, block_loop
209
210 /* Store hash state to context. */
211 st1 {hc0.4s}, [ctx]
212 str hc1s, [ctx, #(4*4)]
213
214 ret
diff --git a/src/lib/libcrypto/shlib_version b/src/lib/libcrypto/shlib_version
index a5cb76dd4f..79adf54372 100644
--- a/src/lib/libcrypto/shlib_version
+++ b/src/lib/libcrypto/shlib_version
@@ -1,3 +1,3 @@
1# Don't forget to give libssl and libtls the same type of bump! 1# Don't forget to give libssl and libtls the same type of bump!
2major=56 2major=57
3minor=0 3minor=0
diff --git a/src/lib/libcrypto/sm2/sm2_crypt.c b/src/lib/libcrypto/sm2/sm2_crypt.c
index 63fe1e6ab9..3bc1f21fb6 100644
--- a/src/lib/libcrypto/sm2/sm2_crypt.c
+++ b/src/lib/libcrypto/sm2/sm2_crypt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sm2_crypt.c,v 1.3 2024/02/09 07:43:52 tb Exp $ */ 1/* $OpenBSD: sm2_crypt.c,v 1.4 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2019 Ribose Inc 3 * Copyright (c) 2017, 2019 Ribose Inc
4 * 4 *
@@ -22,10 +22,10 @@
22#include <openssl/asn1.h> 22#include <openssl/asn1.h>
23#include <openssl/asn1t.h> 23#include <openssl/asn1t.h>
24#include <openssl/bn.h> 24#include <openssl/bn.h>
25#include <openssl/err.h>
26#include <openssl/evp.h> 25#include <openssl/evp.h>
27#include <openssl/sm2.h> 26#include <openssl/sm2.h>
28 27
28#include "err_local.h"
29#include "sm2_local.h" 29#include "sm2_local.h"
30 30
31typedef struct SM2_Ciphertext_st SM2_Ciphertext; 31typedef struct SM2_Ciphertext_st SM2_Ciphertext;
diff --git a/src/lib/libcrypto/sm2/sm2_pmeth.c b/src/lib/libcrypto/sm2/sm2_pmeth.c
index 441f5475d1..786e48a992 100644
--- a/src/lib/libcrypto/sm2/sm2_pmeth.c
+++ b/src/lib/libcrypto/sm2/sm2_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sm2_pmeth.c,v 1.2 2022/11/26 16:08:54 tb Exp $ */ 1/* $OpenBSD: sm2_pmeth.c,v 1.3 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2019 Ribose Inc 3 * Copyright (c) 2017, 2019 Ribose Inc
4 * 4 *
@@ -22,9 +22,9 @@
22#include <openssl/sm2.h> 22#include <openssl/sm2.h>
23#include <openssl/asn1t.h> 23#include <openssl/asn1t.h>
24#include <openssl/x509.h> 24#include <openssl/x509.h>
25#include <openssl/err.h>
26#include <openssl/evp.h> 25#include <openssl/evp.h>
27 26
27#include "err_local.h"
28#include "evp_local.h" 28#include "evp_local.h"
29#include "sm2_local.h" 29#include "sm2_local.h"
30 30
diff --git a/src/lib/libcrypto/sm2/sm2_sign.c b/src/lib/libcrypto/sm2/sm2_sign.c
index a5e3a8aee5..1a88d860bc 100644
--- a/src/lib/libcrypto/sm2/sm2_sign.c
+++ b/src/lib/libcrypto/sm2/sm2_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sm2_sign.c,v 1.4 2023/07/05 17:36:19 tb Exp $ */ 1/* $OpenBSD: sm2_sign.c,v 1.5 2025/05/10 05:54:38 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2019 Ribose Inc 3 * Copyright (c) 2017, 2019 Ribose Inc
4 * 4 *
@@ -21,10 +21,10 @@
21 21
22#include <openssl/sm2.h> 22#include <openssl/sm2.h>
23#include <openssl/evp.h> 23#include <openssl/evp.h>
24#include <openssl/err.h>
25#include <openssl/bn.h> 24#include <openssl/bn.h>
26 25
27#include "bn_local.h" 26#include "bn_local.h"
27#include "err_local.h"
28#include "sm2_local.h" 28#include "sm2_local.h"
29 29
30static BIGNUM * 30static BIGNUM *
diff --git a/src/lib/libcrypto/ts/ts_asn1.c b/src/lib/libcrypto/ts/ts_asn1.c
index feb2da68f9..aa3f4ba867 100644
--- a/src/lib/libcrypto/ts/ts_asn1.c
+++ b/src/lib/libcrypto/ts/ts_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_asn1.c,v 1.15 2024/04/15 15:52:46 tb Exp $ */ 1/* $OpenBSD: ts_asn1.c,v 1.16 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Nils Larsch for the OpenSSL project 2004. 2/* Written by Nils Larsch for the OpenSSL project 2004.
3 */ 3 */
4/* ==================================================================== 4/* ====================================================================
@@ -58,9 +58,9 @@
58#include <openssl/opensslconf.h> 58#include <openssl/opensslconf.h>
59 59
60#include <openssl/ts.h> 60#include <openssl/ts.h>
61#include <openssl/err.h>
62#include <openssl/asn1t.h> 61#include <openssl/asn1t.h>
63 62
63#include "err_local.h"
64#include "ts_local.h" 64#include "ts_local.h"
65 65
66static const ASN1_TEMPLATE TS_MSG_IMPRINT_seq_tt[] = { 66static const ASN1_TEMPLATE TS_MSG_IMPRINT_seq_tt[] = {
diff --git a/src/lib/libcrypto/ts/ts_conf.c b/src/lib/libcrypto/ts/ts_conf.c
index bd499238f5..0acefa902f 100644
--- a/src/lib/libcrypto/ts/ts_conf.c
+++ b/src/lib/libcrypto/ts/ts_conf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_conf.c,v 1.15 2024/08/26 22:01:28 op Exp $ */ 1/* $OpenBSD: ts_conf.c,v 1.16 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -63,7 +63,6 @@
63#include <openssl/opensslconf.h> 63#include <openssl/opensslconf.h>
64 64
65#include <openssl/crypto.h> 65#include <openssl/crypto.h>
66#include <openssl/err.h>
67#include <openssl/pem.h> 66#include <openssl/pem.h>
68#include <openssl/ts.h> 67#include <openssl/ts.h>
69 68
diff --git a/src/lib/libcrypto/ts/ts_req_utils.c b/src/lib/libcrypto/ts/ts_req_utils.c
index d679418060..fa3123863c 100644
--- a/src/lib/libcrypto/ts/ts_req_utils.c
+++ b/src/lib/libcrypto/ts/ts_req_utils.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_req_utils.c,v 1.9 2023/07/07 19:37:54 beck Exp $ */ 1/* $OpenBSD: ts_req_utils.c,v 1.10 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -58,11 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/objects.h> 61#include <openssl/objects.h>
63#include <openssl/ts.h> 62#include <openssl/ts.h>
64#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
65 64
65#include "err_local.h"
66#include "ts_local.h" 66#include "ts_local.h"
67 67
68int 68int
diff --git a/src/lib/libcrypto/ts/ts_rsp_sign.c b/src/lib/libcrypto/ts/ts_rsp_sign.c
index e3101340c5..b8cc7e2baf 100644
--- a/src/lib/libcrypto/ts/ts_rsp_sign.c
+++ b/src/lib/libcrypto/ts/ts_rsp_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_rsp_sign.c,v 1.35 2024/03/26 00:39:22 beck Exp $ */ 1/* $OpenBSD: ts_rsp_sign.c,v 1.37 2025/07/31 02:02:35 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -60,11 +60,11 @@
60 60
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/err.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/pkcs7.h> 64#include <openssl/pkcs7.h>
66#include <openssl/ts.h> 65#include <openssl/ts.h>
67 66
67#include "err_local.h"
68#include "evp_local.h" 68#include "evp_local.h"
69#include "ts_local.h" 69#include "ts_local.h"
70#include "x509_local.h" 70#include "x509_local.h"
@@ -955,28 +955,32 @@ static int
955ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc) 955ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc)
956{ 956{
957 ASN1_STRING *seq = NULL; 957 ASN1_STRING *seq = NULL;
958 unsigned char *p, *pp = NULL; 958 unsigned char *data = NULL;
959 int len; 959 int len = 0;
960 int ret = 0;
960 961
961 len = i2d_ESS_SIGNING_CERT(sc, NULL); 962 if ((len = i2d_ESS_SIGNING_CERT(sc, &data)) <= 0) {
962 if (!(pp = malloc(len))) { 963 len = 0;
963 TSerror(ERR_R_MALLOC_FAILURE);
964 goto err; 964 goto err;
965 } 965 }
966 p = pp; 966
967 i2d_ESS_SIGNING_CERT(sc, &p); 967 if ((seq = ASN1_STRING_new()) == NULL)
968 if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set(seq, pp, len)) {
969 TSerror(ERR_R_MALLOC_FAILURE);
970 goto err; 968 goto err;
971 }
972 free(pp);
973 pp = NULL;
974 return PKCS7_add_signed_attribute(si,
975 NID_id_smime_aa_signingCertificate, V_ASN1_SEQUENCE, seq);
976 969
977err: 970 ASN1_STRING_set0(seq, data, len);
971 data = NULL;
972 len = 0;
973
974 if (!PKCS7_add_signed_attribute(si, NID_id_smime_aa_signingCertificate,
975 V_ASN1_SEQUENCE, seq))
976 goto err;
977 seq = NULL;
978
979 ret = 1;
980
981 err:
978 ASN1_STRING_free(seq); 982 ASN1_STRING_free(seq);
979 free(pp); 983 freezero(data, len);
980 984
981 return 0; 985 return ret;
982} 986}
diff --git a/src/lib/libcrypto/ts/ts_rsp_utils.c b/src/lib/libcrypto/ts/ts_rsp_utils.c
index 34994adce8..ecdb46773f 100644
--- a/src/lib/libcrypto/ts/ts_rsp_utils.c
+++ b/src/lib/libcrypto/ts/ts_rsp_utils.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_rsp_utils.c,v 1.11 2023/07/07 19:37:54 beck Exp $ */ 1/* $OpenBSD: ts_rsp_utils.c,v 1.12 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -58,11 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/err.h>
62#include <openssl/objects.h> 61#include <openssl/objects.h>
63#include <openssl/pkcs7.h> 62#include <openssl/pkcs7.h>
64#include <openssl/ts.h> 63#include <openssl/ts.h>
65 64
65#include "err_local.h"
66#include "ts_local.h" 66#include "ts_local.h"
67 67
68/* Function definitions. */ 68/* Function definitions. */
diff --git a/src/lib/libcrypto/ts/ts_rsp_verify.c b/src/lib/libcrypto/ts/ts_rsp_verify.c
index 69236f68ab..d38bb3b460 100644
--- a/src/lib/libcrypto/ts/ts_rsp_verify.c
+++ b/src/lib/libcrypto/ts/ts_rsp_verify.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_rsp_verify.c,v 1.30 2023/07/07 07:25:21 beck Exp $ */ 1/* $OpenBSD: ts_rsp_verify.c,v 1.31 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
@@ -59,11 +59,11 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/err.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/pkcs7.h> 63#include <openssl/pkcs7.h>
65#include <openssl/ts.h> 64#include <openssl/ts.h>
66 65
66#include "err_local.h"
67#include "evp_local.h" 67#include "evp_local.h"
68#include "ts_local.h" 68#include "ts_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
diff --git a/src/lib/libcrypto/ts/ts_verify_ctx.c b/src/lib/libcrypto/ts/ts_verify_ctx.c
index 5a2d95c680..23e2557308 100644
--- a/src/lib/libcrypto/ts/ts_verify_ctx.c
+++ b/src/lib/libcrypto/ts/ts_verify_ctx.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_verify_ctx.c,v 1.14 2023/07/07 07:25:21 beck Exp $ */ 1/* $OpenBSD: ts_verify_ctx.c,v 1.15 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL 2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3 * project 2003. 3 * project 2003.
4 */ 4 */
@@ -58,10 +58,10 @@
58 58
59#include <string.h> 59#include <string.h>
60 60
61#include <openssl/err.h>
62#include <openssl/objects.h> 61#include <openssl/objects.h>
63#include <openssl/ts.h> 62#include <openssl/ts.h>
64 63
64#include "err_local.h"
65#include "ts_local.h" 65#include "ts_local.h"
66 66
67TS_VERIFY_CTX * 67TS_VERIFY_CTX *
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index 73d899afcc..cc9de59c19 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ui_lib.c,v 1.51 2023/02/16 08:38:17 tb Exp $ */ 1/* $OpenBSD: ui_lib.c,v 1.52 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -61,9 +61,9 @@
61#include <openssl/opensslconf.h> 61#include <openssl/opensslconf.h>
62 62
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h>
65#include <openssl/ui.h> 64#include <openssl/ui.h>
66 65
66#include "err_local.h"
67#include "ui_local.h" 67#include "ui_local.h"
68 68
69static const UI_METHOD *default_UI_meth = NULL; 69static const UI_METHOD *default_UI_meth = NULL;
diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c
index 2b2733a04b..9b239c1e9d 100644
--- a/src/lib/libcrypto/x509/by_dir.c
+++ b/src/lib/libcrypto/x509/by_dir.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: by_dir.c,v 1.48 2024/08/31 10:19:17 tb Exp $ */ 1/* $OpenBSD: by_dir.c,v 1.49 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -64,9 +64,9 @@
64 64
65#include <openssl/opensslconf.h> 65#include <openssl/opensslconf.h>
66 66
67#include <openssl/err.h>
68#include <openssl/x509.h> 67#include <openssl/x509.h>
69 68
69#include "err_local.h"
70#include "x509_local.h" 70#include "x509_local.h"
71 71
72typedef struct lookup_dir_hashes_st { 72typedef struct lookup_dir_hashes_st {
diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c
index 9b0fd2542c..86d4cd6b60 100644
--- a/src/lib/libcrypto/x509/by_file.c
+++ b/src/lib/libcrypto/x509/by_file.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: by_file.c,v 1.31 2024/08/31 10:19:17 tb Exp $ */ 1/* $OpenBSD: by_file.c,v 1.32 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -62,10 +62,10 @@
62#include <unistd.h> 62#include <unistd.h>
63 63
64#include <openssl/buffer.h> 64#include <openssl/buffer.h>
65#include <openssl/err.h>
66#include <openssl/pem.h> 65#include <openssl/pem.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68 67
68#include "err_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
70 70
71static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, 71static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
diff --git a/src/lib/libcrypto/x509/by_mem.c b/src/lib/libcrypto/x509/by_mem.c
index 71afefa8a4..66093dd445 100644
--- a/src/lib/libcrypto/x509/by_mem.c
+++ b/src/lib/libcrypto/x509/by_mem.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: by_mem.c,v 1.10 2024/08/31 10:19:17 tb Exp $ */ 1/* $OpenBSD: by_mem.c,v 1.11 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,11 +63,11 @@
63#include <unistd.h> 63#include <unistd.h>
64 64
65#include <openssl/buffer.h> 65#include <openssl/buffer.h>
66#include <openssl/err.h>
67#include <openssl/pem.h> 66#include <openssl/pem.h>
68#include <openssl/lhash.h> 67#include <openssl/lhash.h>
69#include <openssl/x509.h> 68#include <openssl/x509.h>
70 69
70#include "err_local.h"
71#include "x509_local.h" 71#include "x509_local.h"
72 72
73static int by_mem_ctrl(X509_LOOKUP *, int, const char *, long, char **); 73static int by_mem_ctrl(X509_LOOKUP *, int, const char *, long, char **);
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index a198b23202..4148a6398e 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509.h,v 1.121 2025/03/09 15:17:22 tb Exp $ */ 1/* $OpenBSD: x509.h,v 1.124 2025/08/10 06:36:45 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -178,6 +178,7 @@ DECLARE_STACK_OF(X509)
178#define X509_FLAG_NO_SIGDUMP (1L << 9) 178#define X509_FLAG_NO_SIGDUMP (1L << 9)
179#define X509_FLAG_NO_AUX (1L << 10) 179#define X509_FLAG_NO_AUX (1L << 10)
180#define X509_FLAG_NO_ATTRIBUTES (1L << 11) 180#define X509_FLAG_NO_ATTRIBUTES (1L << 11)
181#define X509_FLAG_NO_IDS (1L << 12)
181 182
182/* Flags specific to X509_NAME_print_ex() */ 183/* Flags specific to X509_NAME_print_ex() */
183 184
@@ -244,23 +245,7 @@ typedef struct X509_crl_info_st X509_CRL_INFO;
244DECLARE_STACK_OF(X509_CRL) 245DECLARE_STACK_OF(X509_CRL)
245 246
246typedef struct private_key_st { 247typedef struct private_key_st {
247 int version;
248 /* The PKCS#8 data types */
249 X509_ALGOR *enc_algor;
250 ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
251
252 /* When decrypted, the following will not be NULL */
253 EVP_PKEY *dec_pkey; 248 EVP_PKEY *dec_pkey;
254
255 /* used to encrypt and decrypt */
256 int key_length;
257 char *key_data;
258 int key_free; /* true if we should auto free key_data */
259
260 /* expanded version of 'enc_algor' */
261 EVP_CIPHER_INFO cipher;
262
263 int references;
264} X509_PKEY; 249} X509_PKEY;
265 250
266#ifndef OPENSSL_NO_EVP 251#ifndef OPENSSL_NO_EVP
@@ -646,9 +631,6 @@ int X509_CRL_get0_by_serial(X509_CRL *crl,
646 X509_REVOKED **ret, ASN1_INTEGER *serial); 631 X509_REVOKED **ret, ASN1_INTEGER *serial);
647int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x); 632int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
648 633
649X509_PKEY * X509_PKEY_new(void );
650void X509_PKEY_free(X509_PKEY *a);
651
652NETSCAPE_SPKI *NETSCAPE_SPKI_new(void); 634NETSCAPE_SPKI *NETSCAPE_SPKI_new(void);
653void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a); 635void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a);
654NETSCAPE_SPKI *d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a, const unsigned char **in, long len); 636NETSCAPE_SPKI *d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a, const unsigned char **in, long len);
@@ -1013,6 +995,7 @@ void ERR_load_X509_strings(void);
1013#define X509_R_ERR_ASN1_LIB 102 995#define X509_R_ERR_ASN1_LIB 102
1014#define X509_R_INVALID_DIRECTORY 113 996#define X509_R_INVALID_DIRECTORY 113
1015#define X509_R_INVALID_FIELD_NAME 119 997#define X509_R_INVALID_FIELD_NAME 119
998#define X509_R_INVALID_POLICY_EXTENSION 201
1016#define X509_R_INVALID_TRUST 123 999#define X509_R_INVALID_TRUST 123
1017#define X509_R_INVALID_VERSION 137 1000#define X509_R_INVALID_VERSION 137
1018#define X509_R_KEY_TYPE_MISMATCH 115 1001#define X509_R_KEY_TYPE_MISMATCH 115
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c
index 2208cc434e..b4ee92a14b 100644
--- a/src/lib/libcrypto/x509/x509_addr.c
+++ b/src/lib/libcrypto/x509/x509_addr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_addr.c,v 1.93 2024/07/13 15:08:58 tb Exp $ */ 1/* $OpenBSD: x509_addr.c,v 1.94 2025/05/10 05:54:39 tb Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -69,12 +69,12 @@
69#include <openssl/asn1t.h> 69#include <openssl/asn1t.h>
70#include <openssl/buffer.h> 70#include <openssl/buffer.h>
71#include <openssl/conf.h> 71#include <openssl/conf.h>
72#include <openssl/err.h>
73#include <openssl/x509.h> 72#include <openssl/x509.h>
74#include <openssl/x509v3.h> 73#include <openssl/x509v3.h>
75 74
76#include "asn1_local.h" 75#include "asn1_local.h"
77#include "bytestring.h" 76#include "bytestring.h"
77#include "err_local.h"
78#include "x509_local.h" 78#include "x509_local.h"
79 79
80#ifndef OPENSSL_NO_RFC3779 80#ifndef OPENSSL_NO_RFC3779
diff --git a/src/lib/libcrypto/x509/x509_akey.c b/src/lib/libcrypto/x509/x509_akey.c
index 926508c4cd..524fea8009 100644
--- a/src/lib/libcrypto/x509/x509_akey.c
+++ b/src/lib/libcrypto/x509/x509_akey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_akey.c,v 1.3 2024/08/31 10:03:03 tb Exp $ */ 1/* $OpenBSD: x509_akey.c,v 1.4 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -62,9 +62,9 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/err.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, 70static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_alt.c b/src/lib/libcrypto/x509/x509_alt.c
index 34734a55bd..ca91493848 100644
--- a/src/lib/libcrypto/x509/x509_alt.c
+++ b/src/lib/libcrypto/x509/x509_alt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_alt.c,v 1.19 2025/03/06 07:20:01 tb Exp $ */ 1/* $OpenBSD: x509_alt.c,v 1.20 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -60,9 +60,9 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/conf.h> 62#include <openssl/conf.h>
63#include <openssl/err.h>
64#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
65 64
65#include "err_local.h"
66#include "x509_internal.h" 66#include "x509_internal.h"
67 67
68static GENERAL_NAMES *v2i_subject_alt(X509V3_EXT_METHOD *method, 68static GENERAL_NAMES *v2i_subject_alt(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_asid.c b/src/lib/libcrypto/x509/x509_asid.c
index 40ee201a9f..45a154e7d9 100644
--- a/src/lib/libcrypto/x509/x509_asid.c
+++ b/src/lib/libcrypto/x509/x509_asid.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_asid.c,v 1.45 2024/07/13 15:08:58 tb Exp $ */ 1/* $OpenBSD: x509_asid.c,v 1.46 2025/05/10 05:54:39 tb Exp $ */
2/* 2/*
3 * Contributed to the OpenSSL Project by the American Registry for 3 * Contributed to the OpenSSL Project by the American Registry for
4 * Internet Numbers ("ARIN"). 4 * Internet Numbers ("ARIN").
@@ -68,10 +68,10 @@
68#include <openssl/asn1t.h> 68#include <openssl/asn1t.h>
69#include <openssl/bn.h> 69#include <openssl/bn.h>
70#include <openssl/conf.h> 70#include <openssl/conf.h>
71#include <openssl/err.h>
72#include <openssl/x509.h> 71#include <openssl/x509.h>
73#include <openssl/x509v3.h> 72#include <openssl/x509v3.h>
74 73
74#include "err_local.h"
75#include "x509_local.h" 75#include "x509_local.h"
76 76
77#ifndef OPENSSL_NO_RFC3779 77#ifndef OPENSSL_NO_RFC3779
diff --git a/src/lib/libcrypto/x509/x509_att.c b/src/lib/libcrypto/x509/x509_att.c
index 4931cbbc17..a442a17746 100644
--- a/src/lib/libcrypto/x509/x509_att.c
+++ b/src/lib/libcrypto/x509/x509_att.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_att.c,v 1.25 2024/08/31 10:46:40 tb Exp $ */ 1/* $OpenBSD: x509_att.c,v 1.26 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,13 +59,13 @@
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/err.h>
63#include <openssl/evp.h> 62#include <openssl/evp.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65#include <openssl/stack.h> 64#include <openssl/stack.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67#include <openssl/x509v3.h> 66#include <openssl/x509v3.h>
68 67
68#include "err_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
70 70
71int 71int
diff --git a/src/lib/libcrypto/x509/x509_bcons.c b/src/lib/libcrypto/x509/x509_bcons.c
index 99cb5afe9a..c10f822ccc 100644
--- a/src/lib/libcrypto/x509/x509_bcons.c
+++ b/src/lib/libcrypto/x509/x509_bcons.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_bcons.c,v 1.6 2024/08/31 10:03:03 tb Exp $ */ 1/* $OpenBSD: x509_bcons.c,v 1.7 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -62,9 +62,9 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/err.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, 70static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_bitst.c b/src/lib/libcrypto/x509/x509_bitst.c
index 2bc4f9911a..89289b7af0 100644
--- a/src/lib/libcrypto/x509/x509_bitst.c
+++ b/src/lib/libcrypto/x509/x509_bitst.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_bitst.c,v 1.8 2024/08/31 10:23:13 tb Exp $ */ 1/* $OpenBSD: x509_bitst.c,v 1.9 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,9 +60,9 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/conf.h> 62#include <openssl/conf.h>
63#include <openssl/err.h>
64#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
65 64
65#include "err_local.h"
66#include "x509_local.h" 66#include "x509_local.h"
67 67
68static const BIT_STRING_BITNAME ns_cert_type_table[] = { 68static const BIT_STRING_BITNAME ns_cert_type_table[] = {
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index 2c1e427093..2479dcdd0d 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_cmp.c,v 1.44 2024/03/25 03:41:16 joshua Exp $ */ 1/* $OpenBSD: x509_cmp.c,v 1.45 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,11 +63,11 @@
63#include <openssl/opensslconf.h> 63#include <openssl/opensslconf.h>
64 64
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#include <openssl/err.h>
67#include <openssl/objects.h> 66#include <openssl/objects.h>
68#include <openssl/x509.h> 67#include <openssl/x509.h>
69#include <openssl/x509v3.h> 68#include <openssl/x509v3.h>
70 69
70#include "err_local.h"
71#include "evp_local.h" 71#include "evp_local.h"
72#include "x509_local.h" 72#include "x509_local.h"
73 73
diff --git a/src/lib/libcrypto/x509/x509_conf.c b/src/lib/libcrypto/x509/x509_conf.c
index e5b18c2f77..2089f72bc7 100644
--- a/src/lib/libcrypto/x509/x509_conf.c
+++ b/src/lib/libcrypto/x509/x509_conf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_conf.c,v 1.29 2025/03/06 07:20:01 tb Exp $ */ 1/* $OpenBSD: x509_conf.c,v 1.31 2025/06/02 12:18:21 jsg Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -62,11 +62,11 @@
62#include <string.h> 62#include <string.h>
63 63
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/err.h>
66#include <openssl/x509.h> 65#include <openssl/x509.h>
67#include <openssl/x509v3.h> 66#include <openssl/x509v3.h>
68 67
69#include "conf_local.h" 68#include "conf_local.h"
69#include "err_local.h"
70#include "x509_local.h" 70#include "x509_local.h"
71 71
72static int v3_check_critical(const char **value); 72static int v3_check_critical(const char **value);
@@ -242,8 +242,9 @@ v3_check_critical(const char **value)
242 if ((strlen(p) < 9) || strncmp(p, "critical,", 9)) 242 if ((strlen(p) < 9) || strncmp(p, "critical,", 9))
243 return 0; 243 return 0;
244 p += 9; 244 p += 9;
245 while (isspace((unsigned char)*p)) p++; 245 while (isspace((unsigned char)*p))
246 *value = p; 246 p++;
247 *value = p;
247 return 1; 248 return 1;
248} 249}
249 250
diff --git a/src/lib/libcrypto/x509/x509_cpols.c b/src/lib/libcrypto/x509/x509_cpols.c
index 6bae2a0482..b6a456023f 100644
--- a/src/lib/libcrypto/x509/x509_cpols.c
+++ b/src/lib/libcrypto/x509/x509_cpols.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_cpols.c,v 1.15 2025/03/06 07:20:01 tb Exp $ */ 1/* $OpenBSD: x509_cpols.c,v 1.16 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -62,9 +62,9 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/err.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70/* Certificate policies extension support: this one is a bit complex... */ 70/* Certificate policies extension support: this one is a bit complex... */
diff --git a/src/lib/libcrypto/x509/x509_crld.c b/src/lib/libcrypto/x509/x509_crld.c
index 81f2010df5..75afcefca8 100644
--- a/src/lib/libcrypto/x509/x509_crld.c
+++ b/src/lib/libcrypto/x509/x509_crld.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_crld.c,v 1.9 2025/03/06 07:20:01 tb Exp $ */ 1/* $OpenBSD: x509_crld.c,v 1.10 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -62,9 +62,9 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/err.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70static void *v2i_crld(const X509V3_EXT_METHOD *method, 70static void *v2i_crld(const X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_extku.c b/src/lib/libcrypto/x509/x509_extku.c
index da5036a09a..35460ca46b 100644
--- a/src/lib/libcrypto/x509/x509_extku.c
+++ b/src/lib/libcrypto/x509/x509_extku.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_extku.c,v 1.6 2024/08/31 10:03:03 tb Exp $ */ 1/* $OpenBSD: x509_extku.c,v 1.7 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,9 +60,9 @@
60 60
61#include <openssl/asn1t.h> 61#include <openssl/asn1t.h>
62#include <openssl/conf.h> 62#include <openssl/conf.h>
63#include <openssl/err.h>
64#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
65 64
65#include "err_local.h"
66#include "x509_local.h" 66#include "x509_local.h"
67 67
68static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, 68static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_genn.c b/src/lib/libcrypto/x509/x509_genn.c
index 1ea7155795..5214c394ed 100644
--- a/src/lib/libcrypto/x509/x509_genn.c
+++ b/src/lib/libcrypto/x509/x509_genn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_genn.c,v 1.7 2024/07/08 14:47:44 beck Exp $ */ 1/* $OpenBSD: x509_genn.c,v 1.8 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -63,6 +63,8 @@
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66#include "err_local.h"
67
66static const ASN1_TEMPLATE OTHERNAME_seq_tt[] = { 68static const ASN1_TEMPLATE OTHERNAME_seq_tt[] = {
67 { 69 {
68 .flags = 0, 70 .flags = 0,
diff --git a/src/lib/libcrypto/x509/x509_ia5.c b/src/lib/libcrypto/x509/x509_ia5.c
index 4f62a9134c..b8886c6cb8 100644
--- a/src/lib/libcrypto/x509/x509_ia5.c
+++ b/src/lib/libcrypto/x509/x509_ia5.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_ia5.c,v 1.2 2024/07/13 15:08:58 tb Exp $ */ 1/* $OpenBSD: x509_ia5.c,v 1.3 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -61,9 +61,10 @@
61 61
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/err.h>
65#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
66 65
66#include "err_local.h"
67
67static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); 68static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);
68static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, 69static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
69 X509V3_CTX *ctx, char *str); 70 X509V3_CTX *ctx, char *str);
diff --git a/src/lib/libcrypto/x509/x509_info.c b/src/lib/libcrypto/x509/x509_info.c
index d1de346ee6..c91642a02e 100644
--- a/src/lib/libcrypto/x509/x509_info.c
+++ b/src/lib/libcrypto/x509/x509_info.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_info.c,v 1.5 2024/07/13 15:08:58 tb Exp $ */ 1/* $OpenBSD: x509_info.c,v 1.6 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -62,9 +62,10 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/err.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68
68static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS( 69static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(
69 X509V3_EXT_METHOD *method, AUTHORITY_INFO_ACCESS *ainfo, 70 X509V3_EXT_METHOD *method, AUTHORITY_INFO_ACCESS *ainfo,
70 STACK_OF(CONF_VALUE) *ret); 71 STACK_OF(CONF_VALUE) *ret);
diff --git a/src/lib/libcrypto/x509/x509_lib.c b/src/lib/libcrypto/x509/x509_lib.c
index 6fa66ab88e..0285ac0d3a 100644
--- a/src/lib/libcrypto/x509/x509_lib.c
+++ b/src/lib/libcrypto/x509/x509_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_lib.c,v 1.24 2024/07/13 15:08:58 tb Exp $ */ 1/* $OpenBSD: x509_lib.c,v 1.25 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,9 +60,9 @@
60#include <stdio.h> 60#include <stdio.h>
61 61
62#include <openssl/conf.h> 62#include <openssl/conf.h>
63#include <openssl/err.h>
64#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
65 64
65#include "err_local.h"
66#include "x509_local.h" 66#include "x509_local.h"
67 67
68const X509V3_EXT_METHOD * 68const X509V3_EXT_METHOD *
diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c
index 0367794fca..1ac3436a6e 100644
--- a/src/lib/libcrypto/x509/x509_lu.c
+++ b/src/lib/libcrypto/x509/x509_lu.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_lu.c,v 1.67 2025/03/09 15:20:20 tb Exp $ */ 1/* $OpenBSD: x509_lu.c,v 1.68 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,11 +59,11 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/err.h>
63#include <openssl/lhash.h> 62#include <openssl/lhash.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
65#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
66 65
66#include "err_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
69static int X509_OBJECT_up_ref_count(X509_OBJECT *a); 69static int X509_OBJECT_up_ref_count(X509_OBJECT *a);
diff --git a/src/lib/libcrypto/x509/x509_ncons.c b/src/lib/libcrypto/x509/x509_ncons.c
index 148a66e887..f197488d70 100644
--- a/src/lib/libcrypto/x509/x509_ncons.c
+++ b/src/lib/libcrypto/x509/x509_ncons.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_ncons.c,v 1.11 2024/07/13 15:08:58 tb Exp $ */ 1/* $OpenBSD: x509_ncons.c,v 1.12 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -61,9 +61,9 @@
61 61
62#include <openssl/asn1t.h> 62#include <openssl/asn1t.h>
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/err.h>
65#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
66 65
66#include "err_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
69static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, 69static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_ocsp.c b/src/lib/libcrypto/x509/x509_ocsp.c
index 6531b4c420..d0a0d49890 100644
--- a/src/lib/libcrypto/x509/x509_ocsp.c
+++ b/src/lib/libcrypto/x509/x509_ocsp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_ocsp.c,v 1.4 2024/12/24 09:14:33 schwarze Exp $ */ 1/* $OpenBSD: x509_ocsp.c,v 1.5 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -65,10 +65,10 @@
65 65
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/conf.h> 67#include <openssl/conf.h>
68#include <openssl/err.h>
69#include <openssl/ocsp.h> 68#include <openssl/ocsp.h>
70#include <openssl/x509v3.h> 69#include <openssl/x509v3.h>
71 70
71#include "err_local.h"
72#include "ocsp_local.h" 72#include "ocsp_local.h"
73 73
74/* OCSP extensions and a couple of CRL entry extensions 74/* OCSP extensions and a couple of CRL entry extensions
diff --git a/src/lib/libcrypto/x509/x509_pcons.c b/src/lib/libcrypto/x509/x509_pcons.c
index 66dc57abf6..404fa28724 100644
--- a/src/lib/libcrypto/x509/x509_pcons.c
+++ b/src/lib/libcrypto/x509/x509_pcons.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_pcons.c,v 1.6 2024/08/31 10:03:03 tb Exp $ */ 1/* $OpenBSD: x509_pcons.c,v 1.7 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -62,9 +62,9 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h> 63#include <openssl/asn1t.h>
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/err.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70static STACK_OF(CONF_VALUE) * 70static STACK_OF(CONF_VALUE) *
diff --git a/src/lib/libcrypto/x509/x509_pmaps.c b/src/lib/libcrypto/x509/x509_pmaps.c
index 5039f65f2e..141a3a6f90 100644
--- a/src/lib/libcrypto/x509/x509_pmaps.c
+++ b/src/lib/libcrypto/x509/x509_pmaps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_pmaps.c,v 1.6 2024/08/31 10:03:03 tb Exp $ */ 1/* $OpenBSD: x509_pmaps.c,v 1.7 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -61,9 +61,9 @@
61 61
62#include <openssl/asn1t.h> 62#include <openssl/asn1t.h>
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/err.h>
65#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
66 65
66#include "err_local.h"
67#include "x509_local.h" 67#include "x509_local.h"
68 68
69static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, 69static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_policy.c b/src/lib/libcrypto/x509/x509_policy.c
index d93760755d..2df965aad1 100644
--- a/src/lib/libcrypto/x509/x509_policy.c
+++ b/src/lib/libcrypto/x509/x509_policy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_policy.c,v 1.31 2025/03/28 13:11:57 tb Exp $ */ 1/* $OpenBSD: x509_policy.c,v 1.33 2025/08/10 06:36:45 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2022, Google Inc. 3 * Copyright (c) 2022, Google Inc.
4 * 4 *
@@ -17,19 +17,16 @@
17 17
18#include <string.h> 18#include <string.h>
19 19
20#include <openssl/err.h>
21#include <openssl/objects.h> 20#include <openssl/objects.h>
22#include <openssl/stack.h> 21#include <openssl/stack.h>
23#include <openssl/x509.h> 22#include <openssl/x509.h>
24#include <openssl/x509v3.h> 23#include <openssl/x509v3.h>
25 24
25#include "err_local.h"
26#include "stack_local.h" 26#include "stack_local.h"
27#include "x509_internal.h" 27#include "x509_internal.h"
28#include "x509_local.h" 28#include "x509_local.h"
29 29
30/* XXX move to proper place */
31#define X509_R_INVALID_POLICY_EXTENSION 201
32
33/* 30/*
34 * This file computes the X.509 policy tree, as described in RFC 5280, 31 * This file computes the X.509 policy tree, as described in RFC 5280,
35 * section 6.1 and RFC 9618. It differs in that: 32 * section 6.1 and RFC 9618. It differs in that:
diff --git a/src/lib/libcrypto/x509/x509_prn.c b/src/lib/libcrypto/x509/x509_prn.c
index 3bf7c803e5..23c649a7b9 100644
--- a/src/lib/libcrypto/x509/x509_prn.c
+++ b/src/lib/libcrypto/x509/x509_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_prn.c,v 1.6 2023/05/08 05:30:38 tb Exp $ */ 1/* $OpenBSD: x509_prn.c,v 1.7 2025/06/02 12:18:22 jsg Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -87,8 +87,9 @@ X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml)
87 for (i = 0; i < sk_CONF_VALUE_num(val); i++) { 87 for (i = 0; i < sk_CONF_VALUE_num(val); i++) {
88 if (ml) 88 if (ml)
89 BIO_printf(out, "%*s", indent, ""); 89 BIO_printf(out, "%*s", indent, "");
90 else if (i > 0) BIO_printf(out, ", "); 90 else if (i > 0)
91 nval = sk_CONF_VALUE_value(val, i); 91 BIO_printf(out, ", ");
92 nval = sk_CONF_VALUE_value(val, i);
92 if (!nval->name) 93 if (!nval->name)
93 BIO_puts(out, nval->value); 94 BIO_puts(out, nval->value);
94 else if (!nval->value) 95 else if (!nval->value)
diff --git a/src/lib/libcrypto/x509/x509_purp.c b/src/lib/libcrypto/x509/x509_purp.c
index 619a4b890a..36dfe6abee 100644
--- a/src/lib/libcrypto/x509/x509_purp.c
+++ b/src/lib/libcrypto/x509/x509_purp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_purp.c,v 1.43 2024/07/12 18:15:10 beck Exp $ */ 1/* $OpenBSD: x509_purp.c,v 1.44 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -61,7 +61,6 @@
61 61
62#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63 63
64#include <openssl/err.h>
65#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
66#include <openssl/x509_vfy.h> 65#include <openssl/x509_vfy.h>
67 66
diff --git a/src/lib/libcrypto/x509/x509_r2x.c b/src/lib/libcrypto/x509/x509_r2x.c
index 39b392259b..4ca8a87935 100644
--- a/src/lib/libcrypto/x509/x509_r2x.c
+++ b/src/lib/libcrypto/x509/x509_r2x.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_r2x.c,v 1.17 2023/04/25 09:46:36 job Exp $ */ 1/* $OpenBSD: x509_r2x.c,v 1.18 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -61,11 +61,11 @@
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h>
65#include <openssl/evp.h> 64#include <openssl/evp.h>
66#include <openssl/objects.h> 65#include <openssl/objects.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68 67
68#include "err_local.h"
69#include "x509_local.h" 69#include "x509_local.h"
70 70
71X509 * 71X509 *
diff --git a/src/lib/libcrypto/x509/x509_req.c b/src/lib/libcrypto/x509/x509_req.c
index 704acbd897..df1119a55c 100644
--- a/src/lib/libcrypto/x509/x509_req.c
+++ b/src/lib/libcrypto/x509/x509_req.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_req.c,v 1.43 2024/08/31 10:16:52 tb Exp $ */ 1/* $OpenBSD: x509_req.c,v 1.44 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -64,13 +64,13 @@
64#include <openssl/asn1t.h> 64#include <openssl/asn1t.h>
65#include <openssl/bn.h> 65#include <openssl/bn.h>
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#include <openssl/err.h>
68#include <openssl/evp.h> 67#include <openssl/evp.h>
69#include <openssl/objects.h> 68#include <openssl/objects.h>
70#include <openssl/pem.h> 69#include <openssl/pem.h>
71#include <openssl/x509.h> 70#include <openssl/x509.h>
72 71
73#include "asn1_local.h" 72#include "asn1_local.h"
73#include "err_local.h"
74#include "evp_local.h" 74#include "evp_local.h"
75#include "x509_local.h" 75#include "x509_local.h"
76 76
diff --git a/src/lib/libcrypto/x509/x509_skey.c b/src/lib/libcrypto/x509/x509_skey.c
index d2c90b6f1c..e9e915a0c7 100644
--- a/src/lib/libcrypto/x509/x509_skey.c
+++ b/src/lib/libcrypto/x509/x509_skey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_skey.c,v 1.6 2024/07/13 15:08:58 tb Exp $ */ 1/* $OpenBSD: x509_skey.c,v 1.7 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -59,9 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/err.h>
63#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
64 63
64#include "err_local.h"
65#include "x509_local.h" 65#include "x509_local.h"
66 66
67static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, 67static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509/x509_utl.c b/src/lib/libcrypto/x509/x509_utl.c
index 08383849c9..4be8630d89 100644
--- a/src/lib/libcrypto/x509/x509_utl.c
+++ b/src/lib/libcrypto/x509/x509_utl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_utl.c,v 1.26 2025/01/26 13:51:41 tb Exp $ */ 1/* $OpenBSD: x509_utl.c,v 1.27 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -64,11 +64,11 @@
64#include <openssl/asn1.h> 64#include <openssl/asn1.h>
65#include <openssl/bn.h> 65#include <openssl/bn.h>
66#include <openssl/conf.h> 66#include <openssl/conf.h>
67#include <openssl/err.h>
68#include <openssl/x509v3.h> 67#include <openssl/x509v3.h>
69 68
70#include "bytestring.h" 69#include "bytestring.h"
71#include "conf_local.h" 70#include "conf_local.h"
71#include "err_local.h"
72 72
73/* 73/*
74 * Match reference identifiers starting with "." to any sub-domain. This 74 * Match reference identifiers starting with "." to any sub-domain. This
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index 688aed15a2..ee14d2dcef 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_v3.c,v 1.43 2024/07/12 09:57:04 tb Exp $ */ 1/* $OpenBSD: x509_v3.c,v 1.44 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -59,12 +59,12 @@
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/err.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
64#include <openssl/stack.h> 63#include <openssl/stack.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
67 66
67#include "err_local.h"
68#include "x509_local.h" 68#include "x509_local.h"
69 69
70int 70int
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index c93ae81bd8..3d0abda615 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vfy.c,v 1.147 2025/03/04 08:43:25 tb Exp $ */ 1/* $OpenBSD: x509_vfy.c,v 1.148 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -67,7 +67,6 @@
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68#include <openssl/buffer.h> 68#include <openssl/buffer.h>
69#include <openssl/crypto.h> 69#include <openssl/crypto.h>
70#include <openssl/err.h>
71#include <openssl/evp.h> 70#include <openssl/evp.h>
72#include <openssl/lhash.h> 71#include <openssl/lhash.h>
73#include <openssl/objects.h> 72#include <openssl/objects.h>
@@ -75,6 +74,7 @@
75#include <openssl/x509v3.h> 74#include <openssl/x509v3.h>
76 75
77#include "asn1_local.h" 76#include "asn1_local.h"
77#include "err_local.h"
78#include "x509_internal.h" 78#include "x509_internal.h"
79#include "x509_issuer_cache.h" 79#include "x509_issuer_cache.h"
80#include "x509_local.h" 80#include "x509_local.h"
diff --git a/src/lib/libcrypto/x509/x509_vpm.c b/src/lib/libcrypto/x509/x509_vpm.c
index 9efe473fc3..19091b12aa 100644
--- a/src/lib/libcrypto/x509/x509_vpm.c
+++ b/src/lib/libcrypto/x509/x509_vpm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vpm.c,v 1.55 2025/03/19 17:11:21 tb Exp $ */ 1/* $OpenBSD: x509_vpm.c,v 1.56 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2004. 3 * project 2004.
4 */ 4 */
@@ -61,12 +61,12 @@
61 61
62#include <openssl/buffer.h> 62#include <openssl/buffer.h>
63#include <openssl/crypto.h> 63#include <openssl/crypto.h>
64#include <openssl/err.h>
65#include <openssl/lhash.h> 64#include <openssl/lhash.h>
66#include <openssl/stack.h> 65#include <openssl/stack.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68#include <openssl/x509v3.h> 67#include <openssl/x509v3.h>
69 68
69#include "err_local.h"
70#include "x509_local.h" 70#include "x509_local.h"
71 71
72/* X509_VERIFY_PARAM functions */ 72/* X509_VERIFY_PARAM functions */
diff --git a/src/lib/libcrypto/x509/x509name.c b/src/lib/libcrypto/x509/x509name.c
index d2df06ccc6..9a582d34e4 100644
--- a/src/lib/libcrypto/x509/x509name.c
+++ b/src/lib/libcrypto/x509/x509name.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509name.c,v 1.35 2023/05/29 11:54:50 beck Exp $ */ 1/* $OpenBSD: x509name.c,v 1.36 2025/05/10 05:54:39 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,13 +60,13 @@
60#include <string.h> 60#include <string.h>
61 61
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/err.h>
64#include <openssl/evp.h> 63#include <openssl/evp.h>
65#include <openssl/objects.h> 64#include <openssl/objects.h>
66#include <openssl/stack.h> 65#include <openssl/stack.h>
67#include <openssl/x509.h> 66#include <openssl/x509.h>
68 67
69#include "bytestring.h" 68#include "bytestring.h"
69#include "err_local.h"
70#include "x509_local.h" 70#include "x509_local.h"
71 71
72int 72int
diff --git a/src/lib/libcrypto/x509/x509spki.c b/src/lib/libcrypto/x509/x509spki.c
index 04c9a6f01b..ef5f9e34c8 100644
--- a/src/lib/libcrypto/x509/x509spki.c
+++ b/src/lib/libcrypto/x509/x509spki.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509spki.c,v 1.16 2023/02/16 08:38:17 tb Exp $ */ 1/* $OpenBSD: x509spki.c,v 1.17 2025/05/10 05:54:39 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -60,9 +60,10 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/err.h>
64#include <openssl/x509.h> 63#include <openssl/x509.h>
65 64
65#include "err_local.h"
66
66int 67int
67NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey) 68NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey)
68{ 69{
diff --git a/src/lib/libcrypto/x509/x_all.c b/src/lib/libcrypto/x509/x_all.c
index 5997714061..b5d50ae4ee 100644
--- a/src/lib/libcrypto/x509/x_all.c
+++ b/src/lib/libcrypto/x509/x_all.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_all.c,v 1.32 2024/06/19 08:00:53 tb Exp $ */ 1/* $OpenBSD: x_all.c,v 1.33 2025/07/10 18:50:23 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -399,7 +399,11 @@ LCRYPTO_ALIAS(i2d_PKCS8PrivateKeyInfo_fp);
399int 399int
400X509_verify(X509 *a, EVP_PKEY *r) 400X509_verify(X509 *a, EVP_PKEY *r)
401{ 401{
402 if (X509_ALGOR_cmp(a->sig_alg, a->cert_info->signature)) 402 /*
403 * The Certificate's signature AlgorithmIdentifier must match the one
404 * inside the TBSCertificate, see RFC 5280, 4.1.1.2, 4.1.2.3.
405 */
406 if (X509_ALGOR_cmp(a->sig_alg, a->cert_info->signature) != 0)
403 return 0; 407 return 0;
404 return ASN1_item_verify(&X509_CINF_it, a->sig_alg, 408 return ASN1_item_verify(&X509_CINF_it, a->sig_alg,
405 a->signature, a->cert_info, r); 409 a->signature, a->cert_info, r);
diff --git a/src/lib/libssl/LICENSE b/src/lib/libssl/LICENSE
index 892e14a450..c41ff4d1ca 100644
--- a/src/lib/libssl/LICENSE
+++ b/src/lib/libssl/LICENSE
@@ -1,7 +1,7 @@
1 1
2 LibReSSL files are retained under the copyright of the authors. New 2 LibreSSL files are retained under the copyright of the authors. New
3 additions are ISC licensed as per OpenBSD's normal licensing policy, 3 additions are ISC licensed as per OpenBSD's normal licensing policy,
4 or are placed in the public domain. 4 or are placed in the public domain.
5 5
6 The OpenSSL code is distributed under the terms of the original OpenSSL 6 The OpenSSL code is distributed under the terms of the original OpenSSL
7 licenses which follow: 7 licenses which follow:
@@ -25,7 +25,7 @@
25 * are met: 25 * are met:
26 * 26 *
27 * 1. Redistributions of source code must retain the above copyright 27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer. 28 * notice, this list of conditions and the following disclaimer.
29 * 29 *
30 * 2. Redistributions in binary form must reproduce the above copyright 30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in 31 * notice, this list of conditions and the following disclaimer in
@@ -80,21 +80,21 @@
80 * This package is an SSL implementation written 80 * This package is an SSL implementation written
81 * by Eric Young (eay@cryptsoft.com). 81 * by Eric Young (eay@cryptsoft.com).
82 * The implementation was written so as to conform with Netscapes SSL. 82 * The implementation was written so as to conform with Netscapes SSL.
83 * 83 *
84 * This library is free for commercial and non-commercial use as long as 84 * This library is free for commercial and non-commercial use as long as
85 * the following conditions are aheared to. The following conditions 85 * the following conditions are aheared to. The following conditions
86 * apply to all code found in this distribution, be it the RC4, RSA, 86 * apply to all code found in this distribution, be it the RC4, RSA,
87 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 87 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
88 * included with this distribution is covered by the same copyright terms 88 * included with this distribution is covered by the same copyright terms
89 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 89 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
90 * 90 *
91 * Copyright remains Eric Young's, and as such any Copyright notices in 91 * Copyright remains Eric Young's, and as such any Copyright notices in
92 * the code are not to be removed. 92 * the code are not to be removed.
93 * If this package is used in a product, Eric Young should be given attribution 93 * If this package is used in a product, Eric Young should be given attribution
94 * as the author of the parts of the library used. 94 * as the author of the parts of the library used.
95 * This can be in the form of a textual message at program startup or 95 * This can be in the form of a textual message at program startup or
96 * in documentation (online or textual) provided with the package. 96 * in documentation (online or textual) provided with the package.
97 * 97 *
98 * Redistribution and use in source and binary forms, with or without 98 * Redistribution and use in source and binary forms, with or without
99 * modification, are permitted provided that the following conditions 99 * modification, are permitted provided that the following conditions
100 * are met: 100 * are met:
@@ -109,10 +109,10 @@
109 * Eric Young (eay@cryptsoft.com)" 109 * Eric Young (eay@cryptsoft.com)"
110 * The word 'cryptographic' can be left out if the rouines from the library 110 * The word 'cryptographic' can be left out if the rouines from the library
111 * being used are not cryptographic related :-). 111 * being used are not cryptographic related :-).
112 * 4. If you include any Windows specific code (or a derivative thereof) from 112 * 4. If you include any Windows specific code (or a derivative thereof) from
113 * the apps directory (application code) you must include an acknowledgement: 113 * the apps directory (application code) you must include an acknowledgement:
114 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 114 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
115 * 115 *
116 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 116 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
117 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 117 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
118 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 118 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -124,7 +124,7 @@
124 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 124 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
125 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 125 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
126 * SUCH DAMAGE. 126 * SUCH DAMAGE.
127 * 127 *
128 * The licence and distribution terms for any publically available version or 128 * The licence and distribution terms for any publically available version or
129 * derivative of this code cannot be changed. i.e. this code cannot simply be 129 * derivative of this code cannot be changed. i.e. this code cannot simply be
130 * copied and put under another distribution licence 130 * copied and put under another distribution licence
diff --git a/src/lib/libssl/bio_ssl.c b/src/lib/libssl/bio_ssl.c
index 6dd1699606..13e4f30539 100644
--- a/src/lib/libssl/bio_ssl.c
+++ b/src/lib/libssl/bio_ssl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_ssl.c,v 1.40 2023/07/19 13:34:33 tb Exp $ */ 1/* $OpenBSD: bio_ssl.c,v 1.41 2025/06/02 12:18:22 jsg Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -229,9 +229,7 @@ ssl_write(BIO *b, const char *out, int outl)
229 229
230 BIO_clear_retry_flags(b); 230 BIO_clear_retry_flags(b);
231 231
232/* ret=SSL_do_handshake(ssl); 232 ret = SSL_write(ssl, out, outl);
233 if (ret > 0) */
234 ret = SSL_write(ssl, out, outl);
235 233
236 switch (SSL_get_error(ssl, ret)) { 234 switch (SSL_get_error(ssl, ret)) {
237 case SSL_ERROR_NONE: 235 case SSL_ERROR_NONE:
diff --git a/src/lib/libssl/hidden/ssl_namespace.h b/src/lib/libssl/hidden/ssl_namespace.h
index 5d26516f3c..763dcd700f 100644
--- a/src/lib/libssl/hidden/ssl_namespace.h
+++ b/src/lib/libssl/hidden/ssl_namespace.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_namespace.h,v 1.3 2024/07/12 05:26:34 miod Exp $ */ 1/* $OpenBSD: ssl_namespace.h,v 1.4 2025/08/18 16:00:53 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> 3 * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org>
4 * 4 *
@@ -35,7 +35,11 @@
35#else 35#else
36#define LSSL_UNUSED(x) 36#define LSSL_UNUSED(x)
37#define LSSL_USED(x) 37#define LSSL_USED(x)
38#ifdef _MSC_VER
39#define LSSL_ALIAS(x)
40#else
38#define LSSL_ALIAS(x) asm("") 41#define LSSL_ALIAS(x) asm("")
42#endif /* _MSC_VER */
39#endif 43#endif
40 44
41#endif /* _LIBSSL_SSL_NAMESPACE_H_ */ 45#endif /* _LIBSSL_SSL_NAMESPACE_H_ */
diff --git a/src/lib/libssl/man/BIO_f_ssl.3 b/src/lib/libssl/man/BIO_f_ssl.3
index 3b74a3d6a4..e23a15e121 100644
--- a/src/lib/libssl/man/BIO_f_ssl.3
+++ b/src/lib/libssl/man/BIO_f_ssl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BIO_f_ssl.3,v 1.16 2024/01/13 18:37:51 tb Exp $ 1.\" $OpenBSD: BIO_f_ssl.3,v 1.17 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL f672aee4 Feb 9 11:52:40 2016 -0500 2.\" full merge up to: OpenSSL f672aee4 Feb 9 11:52:40 2016 -0500
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: January 13 2024 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt BIO_F_SSL 3 54.Dt BIO_F_SSL 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -69,6 +69,7 @@
69.Nm BIO_do_handshake 69.Nm BIO_do_handshake
70.Nd SSL BIO 70.Nd SSL BIO
71.Sh SYNOPSIS 71.Sh SYNOPSIS
72.Lb libssl libcrypto
72.In openssl/bio.h 73.In openssl/bio.h
73.In openssl/ssl.h 74.In openssl/ssl.h
74.Ft const BIO_METHOD * 75.Ft const BIO_METHOD *
diff --git a/src/lib/libssl/man/DTLSv1_listen.3 b/src/lib/libssl/man/DTLSv1_listen.3
index 047ec0a7ff..bdba1c59b0 100644
--- a/src/lib/libssl/man/DTLSv1_listen.3
+++ b/src/lib/libssl/man/DTLSv1_listen.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: DTLSv1_listen.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: DTLSv1_listen.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 7795475f Dec 18 13:18:31 2015 -0500 2.\" OpenSSL 7795475f Dec 18 13:18:31 2015 -0500
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 4.\" This file was written by Matt Caswell <matt@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt DTLSV1_LISTEN 3 52.Dt DTLSV1_LISTEN 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm DTLSv1_listen 55.Nm DTLSv1_listen
56.Nd listen for incoming DTLS connections 56.Nd listen for incoming DTLS connections
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fo DTLSv1_listen 61.Fo DTLSv1_listen
diff --git a/src/lib/libssl/man/OPENSSL_init_ssl.3 b/src/lib/libssl/man/OPENSSL_init_ssl.3
index f37dccfaac..ec840f5e1c 100644
--- a/src/lib/libssl/man/OPENSSL_init_ssl.3
+++ b/src/lib/libssl/man/OPENSSL_init_ssl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OPENSSL_init_ssl.3,v 1.4 2019/06/14 13:41:31 schwarze Exp $ 1.\" $OpenBSD: OPENSSL_init_ssl.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 2.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
3.\" 3.\"
4.\" Permission to use, copy, modify, and distribute this software for any 4.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,13 +13,14 @@
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\" 15.\"
16.Dd $Mdocdate: June 14 2019 $ 16.Dd $Mdocdate: June 8 2025 $
17.Dt OPENSSL_INIT_SSL 3 17.Dt OPENSSL_INIT_SSL 3
18.Os 18.Os
19.Sh NAME 19.Sh NAME
20.Nm OPENSSL_init_ssl 20.Nm OPENSSL_init_ssl
21.Nd initialise the crypto and ssl libraries 21.Nd initialise the crypto and ssl libraries
22.Sh SYNOPSIS 22.Sh SYNOPSIS
23.Lb libssl libcrypto
23.In openssl/ssl.h 24.In openssl/ssl.h
24.Ft int 25.Ft int
25.Fo OPENSSL_init_ssl 26.Fo OPENSSL_init_ssl
diff --git a/src/lib/libssl/man/PEM_read_SSL_SESSION.3 b/src/lib/libssl/man/PEM_read_SSL_SESSION.3
index 3eb1414c62..93bd0b8ebd 100644
--- a/src/lib/libssl/man/PEM_read_SSL_SESSION.3
+++ b/src/lib/libssl/man/PEM_read_SSL_SESSION.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PEM_read_SSL_SESSION.3,v 1.4 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: PEM_read_SSL_SESSION.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL doc/man3/PEM_read_CMS.pod b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL doc/man3/PEM_read_CMS.pod b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Rich Salz <rsalz@openssl.org>. 4.\" This file was written by Rich Salz <rsalz@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 12 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt PEM_READ_SSL_SESSION 3 52.Dt PEM_READ_SSL_SESSION 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm PEM_write_bio_SSL_SESSION 58.Nm PEM_write_bio_SSL_SESSION
59.Nd encode and decode SSL session objects in PEM format 59.Nd encode and decode SSL session objects in PEM format
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft SSL_SESSION * 63.Ft SSL_SESSION *
63.Fo PEM_read_SSL_SESSION 64.Fo PEM_read_SSL_SESSION
diff --git a/src/lib/libssl/man/SSL_CIPHER_get_name.3 b/src/lib/libssl/man/SSL_CIPHER_get_name.3
index 86c1d3c0ba..fc92eb9723 100644
--- a/src/lib/libssl/man/SSL_CIPHER_get_name.3
+++ b/src/lib/libssl/man/SSL_CIPHER_get_name.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CIPHER_get_name.3,v 1.17 2024/07/16 10:19:38 tb Exp $ 1.\" $OpenBSD: SSL_CIPHER_get_name.3,v 1.19 2025/06/13 18:34:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -52,7 +52,7 @@
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE. 53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\" 54.\"
55.Dd $Mdocdate: July 16 2024 $ 55.Dd $Mdocdate: June 13 2025 $
56.Dt SSL_CIPHER_GET_NAME 3 56.Dt SSL_CIPHER_GET_NAME 3
57.Os 57.Os
58.Sh NAME 58.Sh NAME
@@ -70,6 +70,7 @@
70.Nm SSL_CIPHER_description 70.Nm SSL_CIPHER_description
71.Nd get SSL_CIPHER properties 71.Nd get SSL_CIPHER properties
72.Sh SYNOPSIS 72.Sh SYNOPSIS
73.Lb libssl libcrypto
73.In openssl/ssl.h 74.In openssl/ssl.h
74.Ft const char * 75.Ft const char *
75.Fn SSL_CIPHER_get_name "const SSL_CIPHER *cipher" 76.Fn SSL_CIPHER_get_name "const SSL_CIPHER *cipher"
@@ -81,7 +82,7 @@
81.Fn SSL_CIPHER_get_cipher_nid "const SSL_CIPHER *cipher" 82.Fn SSL_CIPHER_get_cipher_nid "const SSL_CIPHER *cipher"
82.Ft int 83.Ft int
83.Fn SSL_CIPHER_get_digest_nid "const SSL_CIPHER *cipher" 84.Fn SSL_CIPHER_get_digest_nid "const SSL_CIPHER *cipher"
84.Ft "const EVP_MD *" 85.Ft const EVP_MD *
85.Fn SSL_CIPHER_get_handshake_digest "const SSL_CIPHER *cipher" 86.Fn SSL_CIPHER_get_handshake_digest "const SSL_CIPHER *cipher"
86.Ft int 87.Ft int
87.Fn SSL_CIPHER_get_kx_nid "const SSL_CIPHER *cipher" 88.Fn SSL_CIPHER_get_kx_nid "const SSL_CIPHER *cipher"
diff --git a/src/lib/libssl/man/SSL_COMP_add_compression_method.3 b/src/lib/libssl/man/SSL_COMP_add_compression_method.3
index f9e25358d7..0b990ca88e 100644
--- a/src/lib/libssl/man/SSL_COMP_add_compression_method.3
+++ b/src/lib/libssl/man/SSL_COMP_add_compression_method.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_COMP_add_compression_method.3,v 1.7 2024/08/31 10:51:48 tb Exp $ 1.\" $OpenBSD: SSL_COMP_add_compression_method.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 31 2024 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_COMP_ADD_COMPRESSION_METHOD 3 18.Dt SSL_COMP_ADD_COMPRESSION_METHOD 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SSL_COMP_get_compression_methods 21.Nm SSL_COMP_get_compression_methods
22.Nd handle SSL/TLS integrated compression methods 22.Nd handle SSL/TLS integrated compression methods
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libssl libcrypto
24.In openssl/ssl.h 25.In openssl/ssl.h
25.Ft STACK_OF(SSL_COMP) * 26.Ft STACK_OF(SSL_COMP) *
26.Fn SSL_COMP_get_compression_methods void 27.Fn SSL_COMP_get_compression_methods void
diff --git a/src/lib/libssl/man/SSL_CTX_add1_chain_cert.3 b/src/lib/libssl/man/SSL_CTX_add1_chain_cert.3
index 86eb27a523..91c4c80758 100644
--- a/src/lib/libssl/man/SSL_CTX_add1_chain_cert.3
+++ b/src/lib/libssl/man/SSL_CTX_add1_chain_cert.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_add1_chain_cert.3,v 1.2 2025/01/18 10:45:12 tb Exp $ 1.\" $OpenBSD: SSL_CTX_add1_chain_cert.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org> 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: January 18 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_ADD1_CHAIN_CERT 3 53.Dt SSL_CTX_ADD1_CHAIN_CERT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -67,6 +67,7 @@
67.Nm SSL_clear_chain_certs 67.Nm SSL_clear_chain_certs
68.Nd extra chain certificate processing 68.Nd extra chain certificate processing
69.Sh SYNOPSIS 69.Sh SYNOPSIS
70.Lb libssl libcrypto
70.In openssl/ssl.h 71.In openssl/ssl.h
71.Ft int 72.Ft int
72.Fo SSL_CTX_set0_chain 73.Fo SSL_CTX_set0_chain
diff --git a/src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.3 b/src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.3
index b9694b0cbc..891c22a40a 100644
--- a/src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.3
+++ b/src/lib/libssl/man/SSL_CTX_add_extra_chain_cert.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_add_extra_chain_cert.3,v 1.8 2025/01/18 10:45:12 tb Exp $ 1.\" $OpenBSD: SSL_CTX_add_extra_chain_cert.3,v 1.9 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: January 18 2025 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_CTX_ADD_EXTRA_CHAIN_CERT 3 54.Dt SSL_CTX_ADD_EXTRA_CHAIN_CERT 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -60,6 +60,7 @@
60.Nm SSL_CTX_clear_extra_chain_certs 60.Nm SSL_CTX_clear_extra_chain_certs
61.Nd add, retrieve, and clear extra chain certificates 61.Nd add, retrieve, and clear extra chain certificates
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libssl libcrypto
63.In openssl/ssl.h 64.In openssl/ssl.h
64.Ft long 65.Ft long
65.Fn SSL_CTX_add_extra_chain_cert "SSL_CTX *ctx" "X509 *x509" 66.Fn SSL_CTX_add_extra_chain_cert "SSL_CTX *ctx" "X509 *x509"
diff --git a/src/lib/libssl/man/SSL_CTX_add_session.3 b/src/lib/libssl/man/SSL_CTX_add_session.3
index 443bdb542a..df634bcdda 100644
--- a/src/lib/libssl/man/SSL_CTX_add_session.3
+++ b/src/lib/libssl/man/SSL_CTX_add_session.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_add_session.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_add_session.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_CTX_add_session.pod 1722496f Jun 8 15:18:38 2017 -0400 2.\" OpenSSL SSL_CTX_add_session.pod 1722496f Jun 8 15:18:38 2017 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 27 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_ADD_SESSION 3 53.Dt SSL_CTX_ADD_SESSION 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_CTX_remove_session 57.Nm SSL_CTX_remove_session
58.Nd manipulate session cache 58.Nd manipulate session cache
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fn SSL_CTX_add_session "SSL_CTX *ctx" "SSL_SESSION *c" 63.Fn SSL_CTX_add_session "SSL_CTX *ctx" "SSL_SESSION *c"
diff --git a/src/lib/libssl/man/SSL_CTX_ctrl.3 b/src/lib/libssl/man/SSL_CTX_ctrl.3
index c91ddff374..4d254d8f48 100644
--- a/src/lib/libssl/man/SSL_CTX_ctrl.3
+++ b/src/lib/libssl/man/SSL_CTX_ctrl.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_ctrl.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_ctrl.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_CTRL 3 52.Dt SSL_CTX_CTRL 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_callback_ctrl 58.Nm SSL_callback_ctrl
59.Nd internal handling functions for SSL_CTX and SSL objects 59.Nd internal handling functions for SSL_CTX and SSL objects
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft long 63.Ft long
63.Fn SSL_CTX_ctrl "SSL_CTX *ctx" "int cmd" "long larg" "void *parg" 64.Fn SSL_CTX_ctrl "SSL_CTX *ctx" "int cmd" "long larg" "void *parg"
diff --git a/src/lib/libssl/man/SSL_CTX_flush_sessions.3 b/src/lib/libssl/man/SSL_CTX_flush_sessions.3
index 2ef781cb4a..deabf5200a 100644
--- a/src/lib/libssl/man/SSL_CTX_flush_sessions.3
+++ b/src/lib/libssl/man/SSL_CTX_flush_sessions.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_flush_sessions.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_flush_sessions.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_CTX_flush_sessions.pod 1722496f Jun 8 15:18:38 2017 -0400 2.\" OpenSSL SSL_CTX_flush_sessions.pod 1722496f Jun 8 15:18:38 2017 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_FLUSH_SESSIONS 3 52.Dt SSL_CTX_FLUSH_SESSIONS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_CTX_flush_sessions 55.Nm SSL_CTX_flush_sessions
56.Nd remove expired sessions 56.Nd remove expired sessions
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft void 60.Ft void
60.Fn SSL_CTX_flush_sessions "SSL_CTX *ctx" "long tm" 61.Fn SSL_CTX_flush_sessions "SSL_CTX *ctx" "long tm"
diff --git a/src/lib/libssl/man/SSL_CTX_free.3 b/src/lib/libssl/man/SSL_CTX_free.3
index 47f247631b..0afef7cd0e 100644
--- a/src/lib/libssl/man/SSL_CTX_free.3
+++ b/src/lib/libssl/man/SSL_CTX_free.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_free.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_free.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_FREE 3 52.Dt SSL_CTX_FREE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_CTX_free 55.Nm SSL_CTX_free
56.Nd free an allocated SSL_CTX object 56.Nd free an allocated SSL_CTX object
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft void 60.Ft void
60.Fn SSL_CTX_free "SSL_CTX *ctx" 61.Fn SSL_CTX_free "SSL_CTX *ctx"
diff --git a/src/lib/libssl/man/SSL_CTX_get0_certificate.3 b/src/lib/libssl/man/SSL_CTX_get0_certificate.3
index 63c86bd5e0..226e6cd87a 100644
--- a/src/lib/libssl/man/SSL_CTX_get0_certificate.3
+++ b/src/lib/libssl/man/SSL_CTX_get0_certificate.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_get0_certificate.3,v 1.3 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_get0_certificate.3,v 1.4 2025/06/08 22:47:20 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,15 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_CTX_GET0_CERTIFICATE 3 18.Dt SSL_CTX_GET0_CERTIFICATE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SSL_CTX_get0_certificate 21.Nm SSL_CTX_get0_certificate
22.Nd get the active certificate from an SSL context 22.Nd get the active certificate from an SSL context
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libssl libcrypto
25.In openssl/ssl.h
24.Ft X509 * 26.Ft X509 *
25.Fo SSL_CTX_get0_certificate 27.Fo SSL_CTX_get0_certificate
26.Fa "const SSL_CTX *ctx" 28.Fa "const SSL_CTX *ctx"
diff --git a/src/lib/libssl/man/SSL_CTX_get_ex_new_index.3 b/src/lib/libssl/man/SSL_CTX_get_ex_new_index.3
index 3dbaf2e981..30a02cc317 100644
--- a/src/lib/libssl/man/SSL_CTX_get_ex_new_index.3
+++ b/src/lib/libssl/man/SSL_CTX_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_get_ex_new_index.3,v 1.3 2018/03/21 08:06:34 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_get_ex_new_index.3,v 1.4 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 21 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_GET_EX_NEW_INDEX 3 52.Dt SSL_CTX_GET_EX_NEW_INDEX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_CTX_get_ex_data 57.Nm SSL_CTX_get_ex_data
58.Nd internal application specific data functions 58.Nd internal application specific data functions
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fo SSL_CTX_get_ex_new_index 63.Fo SSL_CTX_get_ex_new_index
diff --git a/src/lib/libssl/man/SSL_CTX_get_verify_mode.3 b/src/lib/libssl/man/SSL_CTX_get_verify_mode.3
index 7c87775069..88187f7f3c 100644
--- a/src/lib/libssl/man/SSL_CTX_get_verify_mode.3
+++ b/src/lib/libssl/man/SSL_CTX_get_verify_mode.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_get_verify_mode.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_get_verify_mode.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_GET_VERIFY_MODE 3 52.Dt SSL_CTX_GET_VERIFY_MODE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -60,6 +60,7 @@
60.Nm SSL_CTX_get_verify_callback 60.Nm SSL_CTX_get_verify_callback
61.Nd get currently set verification parameters 61.Nd get currently set verification parameters
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libssl libcrypto
63.In openssl/ssl.h 64.In openssl/ssl.h
64.Ft int 65.Ft int
65.Fn SSL_CTX_get_verify_mode "const SSL_CTX *ctx" 66.Fn SSL_CTX_get_verify_mode "const SSL_CTX *ctx"
diff --git a/src/lib/libssl/man/SSL_CTX_load_verify_locations.3 b/src/lib/libssl/man/SSL_CTX_load_verify_locations.3
index 373df2402e..0cc22f433d 100644
--- a/src/lib/libssl/man/SSL_CTX_load_verify_locations.3
+++ b/src/lib/libssl/man/SSL_CTX_load_verify_locations.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_load_verify_locations.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_load_verify_locations.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 27 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_LOAD_VERIFY_LOCATIONS 3 53.Dt SSL_CTX_LOAD_VERIFY_LOCATIONS 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_CTX_set_default_verify_paths 57.Nm SSL_CTX_set_default_verify_paths
58.Nd set default locations for trusted CA certificates 58.Nd set default locations for trusted CA certificates
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fo SSL_CTX_load_verify_locations 63.Fo SSL_CTX_load_verify_locations
diff --git a/src/lib/libssl/man/SSL_CTX_new.3 b/src/lib/libssl/man/SSL_CTX_new.3
index 4b50a03de4..2afad5378c 100644
--- a/src/lib/libssl/man/SSL_CTX_new.3
+++ b/src/lib/libssl/man/SSL_CTX_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_new.3,v 1.17 2022/07/13 22:05:53 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_new.3,v 1.18 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 21cd6e00 Oct 21 14:40:15 2015 +0100 2.\" full merge up to: OpenSSL 21cd6e00 Oct 21 14:40:15 2015 +0100
3.\" selective merge up to: OpenSSL 8f75443f May 24 14:04:26 2019 +0200 3.\" selective merge up to: OpenSSL 8f75443f May 24 14:04:26 2019 +0200
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: July 13 2022 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_CTX_NEW 3 54.Dt SSL_CTX_NEW 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -82,6 +82,7 @@
82.Nm DTLSv1_2_client_method 82.Nm DTLSv1_2_client_method
83.Nd create a new SSL_CTX object as a framework for TLS enabled functions 83.Nd create a new SSL_CTX object as a framework for TLS enabled functions
84.Sh SYNOPSIS 84.Sh SYNOPSIS
85.Lb libssl libcrypto
85.In openssl/ssl.h 86.In openssl/ssl.h
86.Ft SSL_CTX * 87.Ft SSL_CTX *
87.Fn SSL_CTX_new "const SSL_METHOD *method" 88.Fn SSL_CTX_new "const SSL_METHOD *method"
diff --git a/src/lib/libssl/man/SSL_CTX_sess_number.3 b/src/lib/libssl/man/SSL_CTX_sess_number.3
index 76d436cd17..854f6256eb 100644
--- a/src/lib/libssl/man/SSL_CTX_sess_number.3
+++ b/src/lib/libssl/man/SSL_CTX_sess_number.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_sess_number.3,v 1.9 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_sess_number.3,v 1.10 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_CTX_sess_number.pod 7bd27895 Mar 29 11:45:29 2017 +1000 2.\" OpenSSL SSL_CTX_sess_number.pod 7bd27895 Mar 29 11:45:29 2017 +1000
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 12 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SESS_NUMBER 3 52.Dt SSL_CTX_SESS_NUMBER 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -66,6 +66,7 @@
66.Nm SSL_CTX_sess_cache_full 66.Nm SSL_CTX_sess_cache_full
67.Nd obtain session cache statistics 67.Nd obtain session cache statistics
68.Sh SYNOPSIS 68.Sh SYNOPSIS
69.Lb libssl libcrypto
69.In openssl/ssl.h 70.In openssl/ssl.h
70.Ft long 71.Ft long
71.Fn SSL_CTX_sess_number "SSL_CTX *ctx" 72.Fn SSL_CTX_sess_number "SSL_CTX *ctx"
diff --git a/src/lib/libssl/man/SSL_CTX_sess_set_cache_size.3 b/src/lib/libssl/man/SSL_CTX_sess_set_cache_size.3
index 6d5fede0b6..e8bfe50a3c 100644
--- a/src/lib/libssl/man/SSL_CTX_sess_set_cache_size.3
+++ b/src/lib/libssl/man/SSL_CTX_sess_set_cache_size.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_sess_set_cache_size.3,v 1.5 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_sess_set_cache_size.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 12 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SESS_SET_CACHE_SIZE 3 52.Dt SSL_CTX_SESS_SET_CACHE_SIZE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_CTX_sess_get_cache_size 56.Nm SSL_CTX_sess_get_cache_size
57.Nd manipulate session cache size 57.Nd manipulate session cache size
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft long 61.Ft long
61.Fn SSL_CTX_sess_set_cache_size "SSL_CTX *ctx" "long t" 62.Fn SSL_CTX_sess_set_cache_size "SSL_CTX *ctx" "long t"
diff --git a/src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3 b/src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3
index e99f2be671..62a6698399 100644
--- a/src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3
+++ b/src/lib/libssl/man/SSL_CTX_sess_set_get_cb.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_sess_set_get_cb.3,v 1.7 2022/03/29 18:15:52 naddy Exp $ 1.\" $OpenBSD: SSL_CTX_sess_set_get_cb.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 29 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_SESS_SET_GET_CB 3 53.Dt SSL_CTX_SESS_SET_GET_CB 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -61,6 +61,7 @@
61.Nm SSL_CTX_sess_get_get_cb 61.Nm SSL_CTX_sess_get_get_cb
62.Nd provide callback functions for server side external session caching 62.Nd provide callback functions for server side external session caching
63.Sh SYNOPSIS 63.Sh SYNOPSIS
64.Lb libssl libcrypto
64.In openssl/ssl.h 65.In openssl/ssl.h
65.Ft void 66.Ft void
66.Fo SSL_CTX_sess_set_new_cb 67.Fo SSL_CTX_sess_set_new_cb
diff --git a/src/lib/libssl/man/SSL_CTX_sessions.3 b/src/lib/libssl/man/SSL_CTX_sessions.3
index 964d1a7346..627c694cd8 100644
--- a/src/lib/libssl/man/SSL_CTX_sessions.3
+++ b/src/lib/libssl/man/SSL_CTX_sessions.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_sessions.3,v 1.5 2018/04/25 14:19:39 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_sessions.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 25 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SESSIONS 3 52.Dt SSL_CTX_SESSIONS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_CTX_sessions 55.Nm SSL_CTX_sessions
56.Nd access internal session cache 56.Nd access internal session cache
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft LHASH_OF(SSL_SESSION) * 60.Ft LHASH_OF(SSL_SESSION) *
60.Fn SSL_CTX_sessions "SSL_CTX *ctx" 61.Fn SSL_CTX_sessions "SSL_CTX *ctx"
diff --git a/src/lib/libssl/man/SSL_CTX_set1_groups.3 b/src/lib/libssl/man/SSL_CTX_set1_groups.3
index 0d1eb36ea7..8cd620d3b4 100644
--- a/src/lib/libssl/man/SSL_CTX_set1_groups.3
+++ b/src/lib/libssl/man/SSL_CTX_set1_groups.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set1_groups.3,v 1.2 2017/08/19 19:36:39 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set1_groups.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_CTX_set1_curves.pod de4d764e Nov 9 14:51:06 2016 +0000 2.\" OpenSSL SSL_CTX_set1_curves.pod de4d764e Nov 9 14:51:06 2016 +0000
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 19 2017 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET1_GROUPS 3 52.Dt SSL_CTX_SET1_GROUPS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -62,6 +62,7 @@
62.Nm SSL_set1_curves_list 62.Nm SSL_set1_curves_list
63.Nd choose supported EC groups 63.Nd choose supported EC groups
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libssl libcrypto
65.In openssl/ssl.h 66.In openssl/ssl.h
66.Ft int 67.Ft int
67.Fo SSL_CTX_set1_groups 68.Fo SSL_CTX_set1_groups
diff --git a/src/lib/libssl/man/SSL_CTX_set_alpn_select_cb.3 b/src/lib/libssl/man/SSL_CTX_set_alpn_select_cb.3
index 2317c57af4..ff69408247 100644
--- a/src/lib/libssl/man/SSL_CTX_set_alpn_select_cb.3
+++ b/src/lib/libssl/man/SSL_CTX_set_alpn_select_cb.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_alpn_select_cb.3,v 1.11 2025/02/04 14:00:05 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_alpn_select_cb.3,v 1.12 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 87b81496 Apr 19 12:38:27 2017 -0400 2.\" OpenSSL 87b81496 Apr 19 12:38:27 2017 -0400
3.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 3.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: February 4 2025 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_SET_ALPN_SELECT_CB 3 53.Dt SSL_CTX_SET_ALPN_SELECT_CB 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -60,6 +60,7 @@
60.Nm SSL_get0_alpn_selected 60.Nm SSL_get0_alpn_selected
61.Nd handle application layer protocol negotiation (ALPN) 61.Nd handle application layer protocol negotiation (ALPN)
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libssl libcrypto
63.In openssl/ssl.h 64.In openssl/ssl.h
64.Ft int 65.Ft int
65.Fo SSL_CTX_set_alpn_protos 66.Fo SSL_CTX_set_alpn_protos
diff --git a/src/lib/libssl/man/SSL_CTX_set_cert_store.3 b/src/lib/libssl/man/SSL_CTX_set_cert_store.3
index 1be1ba2f68..75c145fd78 100644
--- a/src/lib/libssl/man/SSL_CTX_set_cert_store.3
+++ b/src/lib/libssl/man/SSL_CTX_set_cert_store.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_cert_store.3,v 1.8 2024/08/03 04:53:01 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_cert_store.3,v 1.9 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: August 3 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_CERT_STORE 3 52.Dt SSL_CTX_SET_CERT_STORE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_CTX_get_cert_store 57.Nm SSL_CTX_get_cert_store
58.Nd manipulate X509 certificate verification storage 58.Nd manipulate X509 certificate verification storage
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft void 62.Ft void
62.Fn SSL_CTX_set_cert_store "SSL_CTX *ctx" "X509_STORE *store" 63.Fn SSL_CTX_set_cert_store "SSL_CTX *ctx" "X509_STORE *store"
diff --git a/src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3 b/src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3
index 0e12b48c78..2e2beac850 100644
--- a/src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_cert_verify_callback.3,v 1.5 2019/06/08 15:25:43 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_cert_verify_callback.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 8 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_CERT_VERIFY_CALLBACK 3 52.Dt SSL_CTX_SET_CERT_VERIFY_CALLBACK 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_CTX_set_cert_verify_callback 55.Nm SSL_CTX_set_cert_verify_callback
56.Nd set peer certificate verification procedure 56.Nd set peer certificate verification procedure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft void 60.Ft void
60.Fo SSL_CTX_set_cert_verify_callback 61.Fo SSL_CTX_set_cert_verify_callback
diff --git a/src/lib/libssl/man/SSL_CTX_set_cipher_list.3 b/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
index b3f0dc3541..6201dc9f55 100644
--- a/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
+++ b/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_cipher_list.3,v 1.18 2025/01/18 12:20:02 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_cipher_list.3,v 1.19 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: January 18 2025 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt SSL_CTX_SET_CIPHER_LIST 3 69.Dt SSL_CTX_SET_CIPHER_LIST 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -73,6 +73,7 @@
73.Nm SSL_set_cipher_list 73.Nm SSL_set_cipher_list
74.Nd choose list of available SSL_CIPHERs 74.Nd choose list of available SSL_CIPHERs
75.Sh SYNOPSIS 75.Sh SYNOPSIS
76.Lb libssl libcrypto
76.In openssl/ssl.h 77.In openssl/ssl.h
77.Ft int 78.Ft int
78.Fn SSL_CTX_set_cipher_list "SSL_CTX *ctx" "const char *control" 79.Fn SSL_CTX_set_cipher_list "SSL_CTX *ctx" "const char *control"
diff --git a/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3 b/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3
index d19fb93ed0..520be04318 100644
--- a/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3
+++ b/src/lib/libssl/man/SSL_CTX_set_client_CA_list.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_client_CA_list.3,v 1.6 2020/03/30 10:28:59 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_client_CA_list.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,16 +48,17 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 30 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_CLIENT_CA_LIST 3 52.Dt SSL_CTX_SET_CLIENT_CA_LIST 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_CTX_set_client_CA_list , 55.Nm SSL_CTX_set_client_CA_list ,
56.Nm SSL_set_client_CA_list , 56.Nm SSL_set_client_CA_list ,
57.Nm SSL_CTX_add_client_CA , 57.Nm SSL_CTX_add_client_CA ,
58.Nm SSL_add_client_CA 58.Nm SSL_add_client_CA
59.Nd set list of CAs sent to the client when requesting a client certificate 59.Nd set list of CAs sent to the client when requesting a client certificate
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft void 63.Ft void
63.Fn SSL_CTX_set_client_CA_list "SSL_CTX *ctx" "STACK_OF(X509_NAME) *list" 64.Fn SSL_CTX_set_client_CA_list "SSL_CTX *ctx" "STACK_OF(X509_NAME) *list"
diff --git a/src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3 b/src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3
index a2433b5e92..2cf8275602 100644
--- a/src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3
+++ b/src/lib/libssl/man/SSL_CTX_set_client_cert_cb.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_client_cert_cb.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_client_cert_cb.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_CLIENT_CERT_CB 3 52.Dt SSL_CTX_SET_CLIENT_CERT_CB 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_CTX_get_client_cert_cb 56.Nm SSL_CTX_get_client_cert_cb
57.Nd handle client certificate callback function 57.Nd handle client certificate callback function
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft void 61.Ft void
61.Fo SSL_CTX_set_client_cert_cb 62.Fo SSL_CTX_set_client_cert_cb
diff --git a/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 b/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3
index 94b4ea543d..e3da1bec66 100644
--- a/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3
+++ b/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_default_passwd_cb.3,v 1.9 2023/09/19 09:40:35 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_default_passwd_cb.3,v 1.10 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" selective merge up to: OpenSSL 18bad535 Apr 9 15:13:55 2019 +0100 3.\" selective merge up to: OpenSSL 18bad535 Apr 9 15:13:55 2019 +0100
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: September 19 2023 $ 70.Dd $Mdocdate: June 8 2025 $
71.Dt SSL_CTX_SET_DEFAULT_PASSWD_CB 3 71.Dt SSL_CTX_SET_DEFAULT_PASSWD_CB 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -77,6 +77,7 @@
77.Nm SSL_CTX_get_default_passwd_cb_userdata 77.Nm SSL_CTX_get_default_passwd_cb_userdata
78.Nd set or get passwd callback for encrypted PEM file handling 78.Nd set or get passwd callback for encrypted PEM file handling
79.Sh SYNOPSIS 79.Sh SYNOPSIS
80.Lb libssl libcrypto
80.In openssl/ssl.h 81.In openssl/ssl.h
81.Ft void 82.Ft void
82.Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb" 83.Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb"
diff --git a/src/lib/libssl/man/SSL_CTX_set_generate_session_id.3 b/src/lib/libssl/man/SSL_CTX_set_generate_session_id.3
index d85383d776..29c102ac50 100644
--- a/src/lib/libssl/man/SSL_CTX_set_generate_session_id.3
+++ b/src/lib/libssl/man/SSL_CTX_set_generate_session_id.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_generate_session_id.3,v 1.5 2018/03/22 21:09:18 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_generate_session_id.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 22 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_GENERATE_SESSION_ID 3 52.Dt SSL_CTX_SET_GENERATE_SESSION_ID 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm GEN_SESSION_CB 58.Nm GEN_SESSION_CB
59.Nd manipulate generation of SSL session IDs (server only) 59.Nd manipulate generation of SSL session IDs (server only)
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft typedef int 63.Ft typedef int
63.Fo (*GEN_SESSION_CB) 64.Fo (*GEN_SESSION_CB)
diff --git a/src/lib/libssl/man/SSL_CTX_set_info_callback.3 b/src/lib/libssl/man/SSL_CTX_set_info_callback.3
index 76eb8bee61..ec251b5b69 100644
--- a/src/lib/libssl/man/SSL_CTX_set_info_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_info_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_info_callback.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_info_callback.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_INFO_CALLBACK 3 52.Dt SSL_CTX_SET_INFO_CALLBACK 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_get_info_callback 58.Nm SSL_get_info_callback
59.Nd handle information callback for SSL connections 59.Nd handle information callback for SSL connections
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft void 63.Ft void
63.Fo SSL_CTX_set_info_callback 64.Fo SSL_CTX_set_info_callback
diff --git a/src/lib/libssl/man/SSL_CTX_set_keylog_callback.3 b/src/lib/libssl/man/SSL_CTX_set_keylog_callback.3
index 24b8f9992f..0cb36b07c6 100644
--- a/src/lib/libssl/man/SSL_CTX_set_keylog_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_keylog_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_keylog_callback.3,v 1.3 2024/05/16 08:39:30 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_keylog_callback.3,v 1.4 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL pod checked up to: 61f805c1 Jan 16 01:01:46 2018 +0800 2.\" OpenSSL pod checked up to: 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 3.\"
4.\" Copyright (c) 2021 Bob Beck <beck@openbsd.org> 4.\" Copyright (c) 2021 Bob Beck <beck@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: May 16 2024 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt SSL_CTX_SET_KEYLOG_CALLBACK 3 19.Dt SSL_CTX_SET_KEYLOG_CALLBACK 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -23,6 +23,7 @@
23.Nm SSL_CTX_get_keylog_callback 23.Nm SSL_CTX_get_keylog_callback
24.Nd set and get the unused key logging callback 24.Nd set and get the unused key logging callback
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libssl libcrypto
26.In openssl/ssl.h 27.In openssl/ssl.h
27.Ft typedef void 28.Ft typedef void
28.Fo (*SSL_CTX_keylog_cb_func) 29.Fo (*SSL_CTX_keylog_cb_func)
diff --git a/src/lib/libssl/man/SSL_CTX_set_max_cert_list.3 b/src/lib/libssl/man/SSL_CTX_set_max_cert_list.3
index 89513b1006..700f534f54 100644
--- a/src/lib/libssl/man/SSL_CTX_set_max_cert_list.3
+++ b/src/lib/libssl/man/SSL_CTX_set_max_cert_list.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_max_cert_list.3,v 1.6 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_max_cert_list.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 12 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_MAX_CERT_LIST 3 52.Dt SSL_CTX_SET_MAX_CERT_LIST 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_get_max_cert_list 58.Nm SSL_get_max_cert_list
59.Nd manipulate allowed size for the peer's certificate chain 59.Nd manipulate allowed size for the peer's certificate chain
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft long 63.Ft long
63.Fn SSL_CTX_set_max_cert_list "SSL_CTX *ctx" "long size" 64.Fn SSL_CTX_set_max_cert_list "SSL_CTX *ctx" "long size"
diff --git a/src/lib/libssl/man/SSL_CTX_set_min_proto_version.3 b/src/lib/libssl/man/SSL_CTX_set_min_proto_version.3
index a2597cda83..50a5fc448d 100644
--- a/src/lib/libssl/man/SSL_CTX_set_min_proto_version.3
+++ b/src/lib/libssl/man/SSL_CTX_set_min_proto_version.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_min_proto_version.3,v 1.5 2021/04/15 16:40:32 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_min_proto_version.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 3edabd3c Sep 14 09:28:39 2017 +0200 2.\" full merge up to: OpenSSL 3edabd3c Sep 14 09:28:39 2017 +0200
3.\" 3.\"
4.\" This file was written by Kurt Roeckx <kurt@roeckx.be> and 4.\" This file was written by Kurt Roeckx <kurt@roeckx.be> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 15 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_SET_MIN_PROTO_VERSION 3 53.Dt SSL_CTX_SET_MIN_PROTO_VERSION 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -63,6 +63,7 @@
63.Nm SSL_get_max_proto_version 63.Nm SSL_get_max_proto_version
64.Nd get and set minimum and maximum supported protocol version 64.Nd get and set minimum and maximum supported protocol version
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libssl libcrypto
66.In openssl/ssl.h 67.In openssl/ssl.h
67.Ft int 68.Ft int
68.Fo SSL_CTX_set_min_proto_version 69.Fo SSL_CTX_set_min_proto_version
diff --git a/src/lib/libssl/man/SSL_CTX_set_mode.3 b/src/lib/libssl/man/SSL_CTX_set_mode.3
index fca1a977d0..62a7a6deda 100644
--- a/src/lib/libssl/man/SSL_CTX_set_mode.3
+++ b/src/lib/libssl/man/SSL_CTX_set_mode.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_mode.3,v 1.7 2020/10/08 16:02:38 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_mode.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 8671b898 Jun 3 02:48:34 2008 +0000 2.\" full merge up to: OpenSSL 8671b898 Jun 3 02:48:34 2008 +0000
3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: October 8 2020 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_CTX_SET_MODE 3 54.Dt SSL_CTX_SET_MODE 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -62,6 +62,7 @@
62.Nm SSL_get_mode 62.Nm SSL_get_mode
63.Nd manipulate SSL engine mode 63.Nd manipulate SSL engine mode
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libssl libcrypto
65.In openssl/ssl.h 66.In openssl/ssl.h
66.Ft long 67.Ft long
67.Fn SSL_CTX_set_mode "SSL_CTX *ctx" "long mode" 68.Fn SSL_CTX_set_mode "SSL_CTX *ctx" "long mode"
diff --git a/src/lib/libssl/man/SSL_CTX_set_msg_callback.3 b/src/lib/libssl/man/SSL_CTX_set_msg_callback.3
index a27333e6d9..65df06016a 100644
--- a/src/lib/libssl/man/SSL_CTX_set_msg_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_msg_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_msg_callback.3,v 1.5 2021/04/15 16:43:27 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_msg_callback.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_CTX_set_msg_callback.pod e9b77246 Jan 20 19:58:49 2017 +0100 2.\" OpenSSL SSL_CTX_set_msg_callback.pod e9b77246 Jan 20 19:58:49 2017 +0100
3.\" OpenSSL SSL_CTX_set_msg_callback.pod b97fdb57 Nov 11 09:33:09 2016 +0100 3.\" OpenSSL SSL_CTX_set_msg_callback.pod b97fdb57 Nov 11 09:33:09 2016 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 15 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_SET_MSG_CALLBACK 3 53.Dt SSL_CTX_SET_MSG_CALLBACK 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -59,6 +59,7 @@
59.Nm SSL_set_msg_callback_arg 59.Nm SSL_set_msg_callback_arg
60.Nd install callback for observing protocol messages 60.Nd install callback for observing protocol messages
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libssl libcrypto
62.In openssl/ssl.h 63.In openssl/ssl.h
63.Ft void 64.Ft void
64.Fo SSL_CTX_set_msg_callback 65.Fo SSL_CTX_set_msg_callback
diff --git a/src/lib/libssl/man/SSL_CTX_set_num_tickets.3 b/src/lib/libssl/man/SSL_CTX_set_num_tickets.3
index cb6d7e000a..093387725a 100644
--- a/src/lib/libssl/man/SSL_CTX_set_num_tickets.3
+++ b/src/lib/libssl/man/SSL_CTX_set_num_tickets.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_num_tickets.3,v 1.2 2021/10/23 17:20:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_num_tickets.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL pod checked up to: 5402f96a Sep 11 09:58:52 2021 +0100 2.\" OpenSSL pod checked up to: 5402f96a Sep 11 09:58:52 2021 +0100
3.\" 3.\"
4.\" Copyright (c) 2021 Bob Beck <beck@openbsd.org> 4.\" Copyright (c) 2021 Bob Beck <beck@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: October 23 2021 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt SSL_CTX_SET_NUM_TICKETS 3 19.Dt SSL_CTX_SET_NUM_TICKETS 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -25,6 +25,7 @@
25.Nm SSL_get_num_tickets 25.Nm SSL_get_num_tickets
26.Nd set and get the number of TLS 1.3 session tickets to be sent 26.Nd set and get the number of TLS 1.3 session tickets to be sent
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libssl libcrypto
28.In openssl/ssl.h 29.In openssl/ssl.h
29.Ft int 30.Ft int
30.Fn SSL_CTX_set_num_tickets "SSL_CTX *ctx" "size_t num_tickets" 31.Fn SSL_CTX_set_num_tickets "SSL_CTX *ctx" "size_t num_tickets"
diff --git a/src/lib/libssl/man/SSL_CTX_set_options.3 b/src/lib/libssl/man/SSL_CTX_set_options.3
index 5df0b07785..5e81c978bd 100644
--- a/src/lib/libssl/man/SSL_CTX_set_options.3
+++ b/src/lib/libssl/man/SSL_CTX_set_options.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_options.3,v 1.16 2022/03/31 17:27:18 naddy Exp $ 1.\" $OpenBSD: SSL_CTX_set_options.3,v 1.17 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 7946ab33 Dec 6 17:56:41 2015 +0100 2.\" full merge up to: OpenSSL 7946ab33 Dec 6 17:56:41 2015 +0100
3.\" selective merge up to: OpenSSL edb79c3a Mar 29 10:07:14 2017 +1000 3.\" selective merge up to: OpenSSL edb79c3a Mar 29 10:07:14 2017 +1000
4.\" 4.\"
@@ -52,7 +52,7 @@
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE. 53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\" 54.\"
55.Dd $Mdocdate: March 31 2022 $ 55.Dd $Mdocdate: June 8 2025 $
56.Dt SSL_CTX_SET_OPTIONS 3 56.Dt SSL_CTX_SET_OPTIONS 3
57.Os 57.Os
58.Sh NAME 58.Sh NAME
@@ -65,6 +65,7 @@
65.Nm SSL_get_secure_renegotiation_support 65.Nm SSL_get_secure_renegotiation_support
66.Nd manipulate SSL options 66.Nd manipulate SSL options
67.Sh SYNOPSIS 67.Sh SYNOPSIS
68.Lb libssl libcrypto
68.In openssl/ssl.h 69.In openssl/ssl.h
69.Ft long 70.Ft long
70.Fn SSL_CTX_set_options "SSL_CTX *ctx" "long options" 71.Fn SSL_CTX_set_options "SSL_CTX *ctx" "long options"
diff --git a/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3 b/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3
index 71463f1eca..20b882167b 100644
--- a/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3
+++ b/src/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_quiet_shutdown.3,v 1.6 2020/03/30 10:28:59 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_quiet_shutdown.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 30 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_QUIET_SHUTDOWN 3 52.Dt SSL_CTX_SET_QUIET_SHUTDOWN 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_get_quiet_shutdown 58.Nm SSL_get_quiet_shutdown
59.Nd manipulate shutdown behaviour 59.Nd manipulate shutdown behaviour
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft void 63.Ft void
63.Fn SSL_CTX_set_quiet_shutdown "SSL_CTX *ctx" "int mode" 64.Fn SSL_CTX_set_quiet_shutdown "SSL_CTX *ctx" "int mode"
diff --git a/src/lib/libssl/man/SSL_CTX_set_read_ahead.3 b/src/lib/libssl/man/SSL_CTX_set_read_ahead.3
index eae76eb472..208ecfbf1a 100644
--- a/src/lib/libssl/man/SSL_CTX_set_read_ahead.3
+++ b/src/lib/libssl/man/SSL_CTX_set_read_ahead.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_read_ahead.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_read_ahead.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 4.\" This file was written by Matt Caswell <matt@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_READ_AHEAD 3 52.Dt SSL_CTX_SET_READ_AHEAD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm SSL_CTX_get_default_read_ahead 59.Nm SSL_CTX_get_default_read_ahead
60.Nd manage whether to read as many input bytes as possible 60.Nd manage whether to read as many input bytes as possible
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libssl libcrypto
62.In openssl/ssl.h 63.In openssl/ssl.h
63.Ft void 64.Ft void
64.Fo SSL_CTX_set_read_ahead 65.Fo SSL_CTX_set_read_ahead
diff --git a/src/lib/libssl/man/SSL_CTX_set_security_level.3 b/src/lib/libssl/man/SSL_CTX_set_security_level.3
index 89adb3d65d..2d3afa5785 100644
--- a/src/lib/libssl/man/SSL_CTX_set_security_level.3
+++ b/src/lib/libssl/man/SSL_CTX_set_security_level.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_security_level.3,v 1.2 2025/01/18 10:45:12 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_security_level.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 18 2025 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_CTX_SET_SECURITY_LEVEL 3 18.Dt SSL_CTX_SET_SECURITY_LEVEL 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm SSL_get_security_level 24.Nm SSL_get_security_level
25.Nd change security level for TLS 25.Nd change security level for TLS
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libssl libcrypto
27.In openssl/ssl.h 28.In openssl/ssl.h
28.Ft void 29.Ft void
29.Fo SSL_CTX_set_security_level 30.Fo SSL_CTX_set_security_level
diff --git a/src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3 b/src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3
index 1fe67b2a7e..d19ff79545 100644
--- a/src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3
+++ b/src/lib/libssl/man/SSL_CTX_set_session_cache_mode.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_session_cache_mode.3,v 1.7 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_session_cache_mode.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 67adf0a7 Dec 25 19:58:38 2016 +0100 2.\" OpenSSL 67adf0a7 Dec 25 19:58:38 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 12 2019 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_SET_SESSION_CACHE_MODE 3 53.Dt SSL_CTX_SET_SESSION_CACHE_MODE 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_CTX_get_session_cache_mode 57.Nm SSL_CTX_get_session_cache_mode
58.Nd enable/disable session caching 58.Nd enable/disable session caching
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft long 62.Ft long
62.Fn SSL_CTX_set_session_cache_mode "SSL_CTX ctx" "long mode" 63.Fn SSL_CTX_set_session_cache_mode "SSL_CTX ctx" "long mode"
diff --git a/src/lib/libssl/man/SSL_CTX_set_session_id_context.3 b/src/lib/libssl/man/SSL_CTX_set_session_id_context.3
index 06fd9348ae..53923888db 100644
--- a/src/lib/libssl/man/SSL_CTX_set_session_id_context.3
+++ b/src/lib/libssl/man/SSL_CTX_set_session_id_context.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_session_id_context.3,v 1.6 2019/06/08 15:25:43 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_session_id_context.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 8 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_SESSION_ID_CONTEXT 3 52.Dt SSL_CTX_SET_SESSION_ID_CONTEXT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_set_session_id_context 56.Nm SSL_set_session_id_context
57.Nd set context within which session can be reused (server side only) 57.Nd set context within which session can be reused (server side only)
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft int 61.Ft int
61.Fo SSL_CTX_set_session_id_context 62.Fo SSL_CTX_set_session_id_context
diff --git a/src/lib/libssl/man/SSL_CTX_set_ssl_version.3 b/src/lib/libssl/man/SSL_CTX_set_ssl_version.3
index b1bdb92bb0..fe9febe431 100644
--- a/src/lib/libssl/man/SSL_CTX_set_ssl_version.3
+++ b/src/lib/libssl/man/SSL_CTX_set_ssl_version.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_ssl_version.3,v 1.5 2021/05/11 19:48:56 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_ssl_version.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: May 11 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_SSL_VERSION 3 52.Dt SSL_CTX_SET_SSL_VERSION 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_get_ssl_method 58.Nm SSL_get_ssl_method
59.Nd choose a new TLS/SSL method 59.Nd choose a new TLS/SSL method
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft int 63.Ft int
63.Fn SSL_CTX_set_ssl_version "SSL_CTX *ctx" "const SSL_METHOD *method" 64.Fn SSL_CTX_set_ssl_version "SSL_CTX *ctx" "const SSL_METHOD *method"
diff --git a/src/lib/libssl/man/SSL_CTX_set_timeout.3 b/src/lib/libssl/man/SSL_CTX_set_timeout.3
index ab99e2016e..da2f811528 100644
--- a/src/lib/libssl/man/SSL_CTX_set_timeout.3
+++ b/src/lib/libssl/man/SSL_CTX_set_timeout.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_timeout.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_timeout.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_TIMEOUT 3 52.Dt SSL_CTX_SET_TIMEOUT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_CTX_get_timeout 56.Nm SSL_CTX_get_timeout
57.Nd manipulate timeout values for session caching 57.Nd manipulate timeout values for session caching
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft long 61.Ft long
61.Fn SSL_CTX_set_timeout "SSL_CTX *ctx" "long t" 62.Fn SSL_CTX_set_timeout "SSL_CTX *ctx" "long t"
diff --git a/src/lib/libssl/man/SSL_CTX_set_tlsext_servername_callback.3 b/src/lib/libssl/man/SSL_CTX_set_tlsext_servername_callback.3
index 79169a004b..b6cece259c 100644
--- a/src/lib/libssl/man/SSL_CTX_set_tlsext_servername_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_tlsext_servername_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_tlsext_servername_callback.3,v 1.7 2025/04/18 08:35:34 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_tlsext_servername_callback.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 190b9a03 Jun 28 15:46:13 2017 +0800 2.\" full merge up to: OpenSSL 190b9a03 Jun 28 15:46:13 2017 +0800
3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200 3.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
4.\" 4.\"
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: April 18 2025 $ 54.Dd $Mdocdate: June 8 2025 $
55.Dt SSL_CTX_SET_TLSEXT_SERVERNAME_CALLBACK 3 55.Dt SSL_CTX_SET_TLSEXT_SERVERNAME_CALLBACK 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -62,6 +62,7 @@
62.Nm SSL_set_tlsext_host_name 62.Nm SSL_set_tlsext_host_name
63.Nd handle server name indication (SNI) 63.Nd handle server name indication (SNI)
64.Sh SYNOPSIS 64.Sh SYNOPSIS
65.Lb libssl libcrypto
65.In openssl/ssl.h 66.In openssl/ssl.h
66.Ft long 67.Ft long
67.Fo SSL_CTX_set_tlsext_servername_callback 68.Fo SSL_CTX_set_tlsext_servername_callback
diff --git a/src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3 b/src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3
index d5979af1e8..c9763f9d2f 100644
--- a/src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3
+++ b/src/lib/libssl/man/SSL_CTX_set_tlsext_status_cb.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_tlsext_status_cb.3,v 1.8 2021/09/11 18:58:41 schwarze Exp $ 1.\" $OpenBSD: SSL_CTX_set_tlsext_status_cb.3,v 1.9 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 43c34894 Nov 30 16:04:51 2015 +0000 2.\" full merge up to: OpenSSL 43c34894 Nov 30 16:04:51 2015 +0000
3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: September 11 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CTX_SET_TLSEXT_STATUS_CB 3 53.Dt SSL_CTX_SET_TLSEXT_STATUS_CB 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -63,6 +63,7 @@
63.Nm SSL_set_tlsext_status_ocsp_resp 63.Nm SSL_set_tlsext_status_ocsp_resp
64.Nd OCSP Certificate Status Request functions 64.Nd OCSP Certificate Status Request functions
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libssl libcrypto
66.In openssl/tls1.h 67.In openssl/tls1.h
67.Ft long 68.Ft long
68.Fo SSL_CTX_set_tlsext_status_cb 69.Fo SSL_CTX_set_tlsext_status_cb
diff --git a/src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3 b/src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3
index b6ccabaeca..0427f7dcf5 100644
--- a/src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3
+++ b/src/lib/libssl/man/SSL_CTX_set_tlsext_ticket_key_cb.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_tlsext_ticket_key_cb.3,v 1.8 2022/01/25 18:01:20 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_tlsext_ticket_key_cb.3,v 1.9 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Rich Salz <rsalz@akamai.com> 4.\" This file was written by Rich Salz <rsalz@akamai.com>
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: January 25 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_TLSEXT_TICKET_KEY_CB 3 52.Dt SSL_CTX_SET_TLSEXT_TICKET_KEY_CB 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_CTX_set_tlsext_ticket_key_cb 55.Nm SSL_CTX_set_tlsext_ticket_key_cb
56.Nd set a callback for session ticket processing 56.Nd set a callback for session ticket processing
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/tls1.h 59.In openssl/tls1.h
59.Ft long 60.Ft long
60.Fo SSL_CTX_set_tlsext_ticket_key_cb 61.Fo SSL_CTX_set_tlsext_ticket_key_cb
diff --git a/src/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3 b/src/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3
index 04c4833c6a..4acd452ad5 100644
--- a/src/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3
+++ b/src/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_tlsext_use_srtp.3,v 1.6 2021/06/11 19:41:39 jmc Exp $ 1.\" $OpenBSD: SSL_CTX_set_tlsext_use_srtp.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000 2.\" full merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 4.\" This file was written by Matt Caswell <matt@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 11 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_TLSEXT_USE_SRTP 3 52.Dt SSL_CTX_SET_TLSEXT_USE_SRTP 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_get_selected_srtp_profile 58.Nm SSL_get_selected_srtp_profile
59.Nd Configure and query SRTP support 59.Nd Configure and query SRTP support
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/srtp.h 62.In openssl/srtp.h
62.Ft int 63.Ft int
63.Fo SSL_CTX_set_tlsext_use_srtp 64.Fo SSL_CTX_set_tlsext_use_srtp
diff --git a/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 b/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
index c6f5253431..9fa830656a 100644
--- a/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.11 2025/01/18 10:45:12 tb Exp $ 1.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.12 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: January 18 2025 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_TMP_DH_CALLBACK 3 52.Dt SSL_CTX_SET_TMP_DH_CALLBACK 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_set_tmp_dh 58.Nm SSL_set_tmp_dh
59.Nd handle DH keys for ephemeral key exchange 59.Nd handle DH keys for ephemeral key exchange
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft void 63.Ft void
63.Fo SSL_CTX_set_tmp_dh_callback 64.Fo SSL_CTX_set_tmp_dh_callback
diff --git a/src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3 b/src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3
index b4c3a3c647..7009ac6ab5 100644
--- a/src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_tmp_rsa_callback.3,v 1.9 2022/03/29 14:27:59 naddy Exp $ 1.\" $OpenBSD: SSL_CTX_set_tmp_rsa_callback.3,v 1.10 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 0b30fc90 Dec 19 15:23:05 2013 -0500 2.\" OpenSSL 0b30fc90 Dec 19 15:23:05 2013 -0500
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 29 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_CTX_SET_TMP_RSA_CALLBACK 3 52.Dt SSL_CTX_SET_TMP_RSA_CALLBACK 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -60,6 +60,7 @@
60.Nm SSL_need_tmp_RSA 60.Nm SSL_need_tmp_RSA
61.Nd handle RSA keys for ephemeral key exchange 61.Nd handle RSA keys for ephemeral key exchange
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libssl libcrypto
63.In openssl/ssl.h 64.In openssl/ssl.h
64.Ft void 65.Ft void
65.Fo SSL_CTX_set_tmp_rsa_callback 66.Fo SSL_CTX_set_tmp_rsa_callback
diff --git a/src/lib/libssl/man/SSL_CTX_set_verify.3 b/src/lib/libssl/man/SSL_CTX_set_verify.3
index 1ed86407e9..656c85afd4 100644
--- a/src/lib/libssl/man/SSL_CTX_set_verify.3
+++ b/src/lib/libssl/man/SSL_CTX_set_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_set_verify.3,v 1.9 2021/06/12 16:59:53 jmc Exp $ 1.\" $OpenBSD: SSL_CTX_set_verify.3,v 1.10 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" selective merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100 3.\" selective merge up to: OpenSSL 1cb7eff4 Sep 10 13:56:40 2019 +0100
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: June 12 2021 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_CTX_SET_VERIFY 3 54.Dt SSL_CTX_SET_VERIFY 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -60,6 +60,7 @@
60.Nm SSL_set_verify_depth 60.Nm SSL_set_verify_depth
61.Nd set peer certificate verification parameters 61.Nd set peer certificate verification parameters
62.Sh SYNOPSIS 62.Sh SYNOPSIS
63.Lb libssl libcrypto
63.In openssl/ssl.h 64.In openssl/ssl.h
64.Ft void 65.Ft void
65.Fo SSL_CTX_set_verify 66.Fo SSL_CTX_set_verify
diff --git a/src/lib/libssl/man/SSL_CTX_use_certificate.3 b/src/lib/libssl/man/SSL_CTX_use_certificate.3
index c88a6971b2..27ec834d16 100644
--- a/src/lib/libssl/man/SSL_CTX_use_certificate.3
+++ b/src/lib/libssl/man/SSL_CTX_use_certificate.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_CTX_use_certificate.3,v 1.17 2025/01/18 10:45:12 tb Exp $ 1.\" $OpenBSD: SSL_CTX_use_certificate.3,v 1.18 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 3aaa1bd0 Mar 28 16:35:25 2017 +1000 2.\" full merge up to: OpenSSL 3aaa1bd0 Mar 28 16:35:25 2017 +1000
3.\" selective merge up to: OpenSSL d1f7a1e6 Apr 26 14:05:40 2018 +0100 3.\" selective merge up to: OpenSSL d1f7a1e6 Apr 26 14:05:40 2018 +0100
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: January 18 2025 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_CTX_USE_CERTIFICATE 3 54.Dt SSL_CTX_USE_CERTIFICATE 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -79,6 +79,7 @@
79.Nm SSL_check_private_key 79.Nm SSL_check_private_key
80.Nd load certificate and key data 80.Nd load certificate and key data
81.Sh SYNOPSIS 81.Sh SYNOPSIS
82.Lb libssl libcrypto
82.In openssl/ssl.h 83.In openssl/ssl.h
83.Ft int 84.Ft int
84.Fn SSL_CTX_use_certificate "SSL_CTX *ctx" "X509 *x" 85.Fn SSL_CTX_use_certificate "SSL_CTX *ctx" "X509 *x"
diff --git a/src/lib/libssl/man/SSL_SESSION_free.3 b/src/lib/libssl/man/SSL_SESSION_free.3
index 3f785e95e5..af02a273a0 100644
--- a/src/lib/libssl/man/SSL_SESSION_free.3
+++ b/src/lib/libssl/man/SSL_SESSION_free.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_free.3,v 1.7 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_free.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b31db505 Mar 24 16:01:50 2017 +0000 2.\" full merge up to: OpenSSL b31db505 Mar 24 16:01:50 2017 +0000
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: June 12 2019 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_SESSION_FREE 3 54.Dt SSL_SESSION_FREE 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_SESSION_free 58.Nm SSL_SESSION_free
59.Nd SSL_SESSION reference counting 59.Nd SSL_SESSION reference counting
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft int 63.Ft int
63.Fn SSL_SESSION_up_ref "SSL_SESSION *session" 64.Fn SSL_SESSION_up_ref "SSL_SESSION *session"
diff --git a/src/lib/libssl/man/SSL_SESSION_get0_cipher.3 b/src/lib/libssl/man/SSL_SESSION_get0_cipher.3
index 239a426dbd..4e5b0bb057 100644
--- a/src/lib/libssl/man/SSL_SESSION_get0_cipher.3
+++ b/src/lib/libssl/man/SSL_SESSION_get0_cipher.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_get0_cipher.3,v 1.1 2021/05/12 14:16:25 tb Exp $ 1.\" $OpenBSD: SSL_SESSION_get0_cipher.3,v 1.2 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL d42e7759f Mar 30 19:40:04 2017 +0200 2.\" full merge up to: OpenSSL d42e7759f Mar 30 19:40:04 2017 +0200
3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
4.\" 4.\"
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: May 12 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_SESSION_GET0_CIPHER 3 53.Dt SSL_SESSION_GET0_CIPHER 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm SSL_SESSION_get0_cipher 56.Nm SSL_SESSION_get0_cipher
57.Nd retrieve the SSL cipher associated with a session 57.Nd retrieve the SSL cipher associated with a session
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft const SSL_CIPHER * 61.Ft const SSL_CIPHER *
61.Fo SSL_SESSION_get0_cipher 62.Fo SSL_SESSION_get0_cipher
diff --git a/src/lib/libssl/man/SSL_SESSION_get0_peer.3 b/src/lib/libssl/man/SSL_SESSION_get0_peer.3
index 6b1ef6680e..98ae1bab9d 100644
--- a/src/lib/libssl/man/SSL_SESSION_get0_peer.3
+++ b/src/lib/libssl/man/SSL_SESSION_get0_peer.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_get0_peer.3,v 1.2 2018/03/23 05:50:30 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_get0_peer.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_SESSION_get0_peer.pod b31db505 Mar 24 16:01:50 2017 +0000 2.\" OpenSSL SSL_SESSION_get0_peer.pod b31db505 Mar 24 16:01:50 2017 +0000
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org> 4.\" This file was written by Matt Caswell <matt@openssl.org>
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 23 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SESSION_GET0_PEER 3 52.Dt SSL_SESSION_GET0_PEER 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_SESSION_get0_peer 55.Nm SSL_SESSION_get0_peer
56.Nd get details about peer's certificate for a session 56.Nd get details about peer's certificate for a session
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft X509 * 60.Ft X509 *
60.Fo SSL_SESSION_get0_peer 61.Fo SSL_SESSION_get0_peer
diff --git a/src/lib/libssl/man/SSL_SESSION_get_compress_id.3 b/src/lib/libssl/man/SSL_SESSION_get_compress_id.3
index aedc216a15..da0d48ff6c 100644
--- a/src/lib/libssl/man/SSL_SESSION_get_compress_id.3
+++ b/src/lib/libssl/man/SSL_SESSION_get_compress_id.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_get_compress_id.3,v 1.3 2018/03/23 05:50:30 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_get_compress_id.3,v 1.4 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_SESSION_get_compress_id.pod b31db505 Mar 24 16:01:50 2017 2.\" OpenSSL SSL_SESSION_get_compress_id.pod b31db505 Mar 24 16:01:50 2017
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org> 4.\" This file was written by Matt Caswell <matt@openssl.org>
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 23 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SESSION_GET_COMPRESS_ID 3 52.Dt SSL_SESSION_GET_COMPRESS_ID 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_SESSION_get_compress_id 55.Nm SSL_SESSION_get_compress_id
56.Nd get details about the compression associated with a session 56.Nd get details about the compression associated with a session
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft unsigned int 60.Ft unsigned int
60.Fo SSL_SESSION_get_compress_id 61.Fo SSL_SESSION_get_compress_id
diff --git a/src/lib/libssl/man/SSL_SESSION_get_ex_new_index.3 b/src/lib/libssl/man/SSL_SESSION_get_ex_new_index.3
index 9fd6949b6a..55cde1c66b 100644
--- a/src/lib/libssl/man/SSL_SESSION_get_ex_new_index.3
+++ b/src/lib/libssl/man/SSL_SESSION_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_get_ex_new_index.3,v 1.3 2018/03/21 08:06:34 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_get_ex_new_index.3,v 1.4 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 21 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SESSION_GET_EX_NEW_INDEX 3 52.Dt SSL_SESSION_GET_EX_NEW_INDEX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_SESSION_get_ex_data 57.Nm SSL_SESSION_get_ex_data
58.Nd internal application specific data functions 58.Nd internal application specific data functions
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fo SSL_SESSION_get_ex_new_index 63.Fo SSL_SESSION_get_ex_new_index
diff --git a/src/lib/libssl/man/SSL_SESSION_get_id.3 b/src/lib/libssl/man/SSL_SESSION_get_id.3
index 6d0de1e52e..eb14d24111 100644
--- a/src/lib/libssl/man/SSL_SESSION_get_id.3
+++ b/src/lib/libssl/man/SSL_SESSION_get_id.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_get_id.3,v 1.6 2018/03/24 00:55:37 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_get_id.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL SSL_SESSION_set1_id 17b60280 Dec 21 09:08:25 2017 +0100 3.\" OpenSSL SSL_SESSION_set1_id 17b60280 Dec 21 09:08:25 2017 +0100
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: March 24 2018 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_SESSION_GET_ID 3 54.Dt SSL_SESSION_GET_ID 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_SESSION_set1_id 58.Nm SSL_SESSION_set1_id
59.Nd get and set the SSL session ID 59.Nd get and set the SSL session ID
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft const unsigned char * 63.Ft const unsigned char *
63.Fo SSL_SESSION_get_id 64.Fo SSL_SESSION_get_id
diff --git a/src/lib/libssl/man/SSL_SESSION_get_protocol_version.3 b/src/lib/libssl/man/SSL_SESSION_get_protocol_version.3
index f14c0490e9..dad9eab7ef 100644
--- a/src/lib/libssl/man/SSL_SESSION_get_protocol_version.3
+++ b/src/lib/libssl/man/SSL_SESSION_get_protocol_version.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_get_protocol_version.3,v 1.2 2018/03/24 00:55:37 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_get_protocol_version.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by TJ Saunders <tj@castaglia.org> 4.\" This file was written by TJ Saunders <tj@castaglia.org>
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 24 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SESSION_GET_PROTOCOL_VERSION 3 52.Dt SSL_SESSION_GET_PROTOCOL_VERSION 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_SESSION_get_protocol_version 55.Nm SSL_SESSION_get_protocol_version
56.Nd get the session protocol version 56.Nd get the session protocol version
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fo SSL_SESSION_get_protocol_version 61.Fo SSL_SESSION_get_protocol_version
diff --git a/src/lib/libssl/man/SSL_SESSION_get_time.3 b/src/lib/libssl/man/SSL_SESSION_get_time.3
index aaadec5137..28aeedf72c 100644
--- a/src/lib/libssl/man/SSL_SESSION_get_time.3
+++ b/src/lib/libssl/man/SSL_SESSION_get_time.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_get_time.3,v 1.8 2019/06/08 15:25:43 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_get_time.3,v 1.9 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 8 2019 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_SESSION_GET_TIME 3 53.Dt SSL_SESSION_GET_TIME 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -63,6 +63,7 @@
63.Nm SSL_set_timeout 63.Nm SSL_set_timeout
64.Nd retrieve and manipulate session time and timeout settings 64.Nd retrieve and manipulate session time and timeout settings
65.Sh SYNOPSIS 65.Sh SYNOPSIS
66.Lb libssl libcrypto
66.In openssl/ssl.h 67.In openssl/ssl.h
67.Ft long 68.Ft long
68.Fn SSL_SESSION_get_time "const SSL_SESSION *s" 69.Fn SSL_SESSION_get_time "const SSL_SESSION *s"
diff --git a/src/lib/libssl/man/SSL_SESSION_has_ticket.3 b/src/lib/libssl/man/SSL_SESSION_has_ticket.3
index 322b49feef..07b894c4f8 100644
--- a/src/lib/libssl/man/SSL_SESSION_has_ticket.3
+++ b/src/lib/libssl/man/SSL_SESSION_has_ticket.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_has_ticket.3,v 1.2 2018/03/24 00:55:37 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_has_ticket.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL f2baac27 Feb 8 15:43:16 2015 +0000 2.\" full merge up to: OpenSSL f2baac27 Feb 8 15:43:16 2015 +0000
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 24 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_SESSION_HAS_TICKET 3 53.Dt SSL_SESSION_HAS_TICKET 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_SESSION_get_ticket_lifetime_hint 57.Nm SSL_SESSION_get_ticket_lifetime_hint
58.Nd get details about the ticket associated with a session 58.Nd get details about the ticket associated with a session
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fo SSL_SESSION_has_ticket 63.Fo SSL_SESSION_has_ticket
diff --git a/src/lib/libssl/man/SSL_SESSION_is_resumable.3 b/src/lib/libssl/man/SSL_SESSION_is_resumable.3
index 48d7d17889..ddc037c1aa 100644
--- a/src/lib/libssl/man/SSL_SESSION_is_resumable.3
+++ b/src/lib/libssl/man/SSL_SESSION_is_resumable.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_is_resumable.3,v 1.1 2021/09/14 14:08:15 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_is_resumable.3,v 1.2 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 4.\" This file was written by Matt Caswell <matt@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: September 14 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SESSION_IS_RESUMABLE 3 52.Dt SSL_SESSION_IS_RESUMABLE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_SESSION_is_resumable 55.Nm SSL_SESSION_is_resumable
56.Nd determine whether an SSL_SESSION object can be used for resumption 56.Nd determine whether an SSL_SESSION object can be used for resumption
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fo SSL_SESSION_is_resumable 61.Fo SSL_SESSION_is_resumable
diff --git a/src/lib/libssl/man/SSL_SESSION_new.3 b/src/lib/libssl/man/SSL_SESSION_new.3
index 2dcdb264c1..88d1995850 100644
--- a/src/lib/libssl/man/SSL_SESSION_new.3
+++ b/src/lib/libssl/man/SSL_SESSION_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_new.3,v 1.9 2021/09/14 14:08:15 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_new.3,v 1.10 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 14 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_SESSION_NEW 3 18.Dt SSL_SESSION_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SSL_SESSION_new 21.Nm SSL_SESSION_new
22.Nd construct a new SSL_SESSION object 22.Nd construct a new SSL_SESSION object
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libssl libcrypto
24.In openssl/ssl.h 25.In openssl/ssl.h
25.Ft SSL_SESSION * 26.Ft SSL_SESSION *
26.Fn SSL_SESSION_new void 27.Fn SSL_SESSION_new void
diff --git a/src/lib/libssl/man/SSL_SESSION_print.3 b/src/lib/libssl/man/SSL_SESSION_print.3
index e92debde0e..65742140d0 100644
--- a/src/lib/libssl/man/SSL_SESSION_print.3
+++ b/src/lib/libssl/man/SSL_SESSION_print.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_print.3,v 1.4 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_print.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_SESSION_PRINT 3 18.Dt SSL_SESSION_PRINT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm SSL_SESSION_print_fp 22.Nm SSL_SESSION_print_fp
23.Nd print some properties of an SSL_SESSION object 23.Nd print some properties of an SSL_SESSION object
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libssl libcrypto
25.In openssl/ssl.h 26.In openssl/ssl.h
26.Ft int 27.Ft int
27.Fo SSL_SESSION_print 28.Fo SSL_SESSION_print
diff --git a/src/lib/libssl/man/SSL_SESSION_set1_id_context.3 b/src/lib/libssl/man/SSL_SESSION_set1_id_context.3
index dd7595baca..24f1de4fda 100644
--- a/src/lib/libssl/man/SSL_SESSION_set1_id_context.3
+++ b/src/lib/libssl/man/SSL_SESSION_set1_id_context.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_SESSION_set1_id_context.3,v 1.4 2018/03/24 00:55:37 schwarze Exp $ 1.\" $OpenBSD: SSL_SESSION_set1_id_context.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL SSL_SESSION_get0_id_context b31db505 Mar 24 16:01:50 2017 3.\" OpenSSL SSL_SESSION_get0_id_context b31db505 Mar 24 16:01:50 2017
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 24 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_SESSION_SET1_ID_CONTEXT 3 53.Dt SSL_SESSION_SET1_ID_CONTEXT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_SESSION_set1_id_context 57.Nm SSL_SESSION_set1_id_context
58.Nd get and set the SSL ID context associated with a session 58.Nd get and set the SSL ID context associated with a session
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft const unsigned char * 62.Ft const unsigned char *
62.Fo SSL_SESSION_get0_id_context 63.Fo SSL_SESSION_get0_id_context
diff --git a/src/lib/libssl/man/SSL_accept.3 b/src/lib/libssl/man/SSL_accept.3
index fb1d89eb57..ecb757aaa5 100644
--- a/src/lib/libssl/man/SSL_accept.3
+++ b/src/lib/libssl/man/SSL_accept.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_accept.3,v 1.6 2019/06/08 15:25:43 schwarze Exp $ 1.\" $OpenBSD: SSL_accept.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 8 2019 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_ACCEPT 3 53.Dt SSL_ACCEPT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm SSL_accept 56.Nm SSL_accept
57.Nd wait for a TLS/SSL client to initiate a TLS/SSL handshake 57.Nd wait for a TLS/SSL client to initiate a TLS/SSL handshake
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft int 61.Ft int
61.Fn SSL_accept "SSL *ssl" 62.Fn SSL_accept "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_alert_type_string.3 b/src/lib/libssl/man/SSL_alert_type_string.3
index 354865e546..0f051cc0a6 100644
--- a/src/lib/libssl/man/SSL_alert_type_string.3
+++ b/src/lib/libssl/man/SSL_alert_type_string.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_alert_type_string.3,v 1.7 2024/10/13 08:25:09 jsg Exp $ 1.\" $OpenBSD: SSL_alert_type_string.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: October 13 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_ALERT_TYPE_STRING 3 52.Dt SSL_ALERT_TYPE_STRING 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_alert_desc_string_long 58.Nm SSL_alert_desc_string_long
59.Nd get textual description of alert information 59.Nd get textual description of alert information
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft const char * 63.Ft const char *
63.Fn SSL_alert_type_string "int value" 64.Fn SSL_alert_type_string "int value"
diff --git a/src/lib/libssl/man/SSL_clear.3 b/src/lib/libssl/man/SSL_clear.3
index 809c3b20f4..5e4da1257f 100644
--- a/src/lib/libssl/man/SSL_clear.3
+++ b/src/lib/libssl/man/SSL_clear.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_clear.3,v 1.5 2021/06/11 19:41:39 jmc Exp $ 1.\" $OpenBSD: SSL_clear.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 11 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CLEAR 3 53.Dt SSL_CLEAR 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm SSL_clear 56.Nm SSL_clear
57.Nd reset SSL object to allow another connection 57.Nd reset SSL object to allow another connection
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft int 61.Ft int
61.Fn SSL_clear "SSL *ssl" 62.Fn SSL_clear "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_connect.3 b/src/lib/libssl/man/SSL_connect.3
index d5b962a480..a0cd8f8443 100644
--- a/src/lib/libssl/man/SSL_connect.3
+++ b/src/lib/libssl/man/SSL_connect.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_connect.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_connect.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 27 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_CONNECT 3 53.Dt SSL_CONNECT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm SSL_connect 56.Nm SSL_connect
57.Nd initiate the TLS/SSL handshake with a TLS/SSL server 57.Nd initiate the TLS/SSL handshake with a TLS/SSL server
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft int 61.Ft int
61.Fn SSL_connect "SSL *ssl" 62.Fn SSL_connect "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_copy_session_id.3 b/src/lib/libssl/man/SSL_copy_session_id.3
index a7a7a8aa99..75a52e8879 100644
--- a/src/lib/libssl/man/SSL_copy_session_id.3
+++ b/src/lib/libssl/man/SSL_copy_session_id.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_copy_session_id.3,v 1.7 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_copy_session_id.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_COPY_SESSION_ID 3 18.Dt SSL_COPY_SESSION_ID 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SSL_copy_session_id 21.Nm SSL_copy_session_id
22.Nd copy session details between SSL objects 22.Nd copy session details between SSL objects
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libssl libcrypto
24.In openssl/ssl.h 25.In openssl/ssl.h
25.Ft int 26.Ft int
26.Fo SSL_copy_session_id 27.Fo SSL_copy_session_id
diff --git a/src/lib/libssl/man/SSL_do_handshake.3 b/src/lib/libssl/man/SSL_do_handshake.3
index e9327b4229..78b41db2f4 100644
--- a/src/lib/libssl/man/SSL_do_handshake.3
+++ b/src/lib/libssl/man/SSL_do_handshake.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_do_handshake.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_do_handshake.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Martin Sjoegren <martin@strakt.com>. 4.\" This file was written by Martin Sjoegren <martin@strakt.com>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_DO_HANDSHAKE 3 52.Dt SSL_DO_HANDSHAKE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_do_handshake 55.Nm SSL_do_handshake
56.Nd perform a TLS/SSL handshake 56.Nd perform a TLS/SSL handshake
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fn SSL_do_handshake "SSL *ssl" 61.Fn SSL_do_handshake "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_dup.3 b/src/lib/libssl/man/SSL_dup.3
index a83440b431..f7d999fb62 100644
--- a/src/lib/libssl/man/SSL_dup.3
+++ b/src/lib/libssl/man/SSL_dup.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_dup.3,v 1.5 2022/07/13 22:05:53 schwarze Exp $ 1.\" $OpenBSD: SSL_dup.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 13 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_DUP 3 18.Dt SSL_DUP 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SSL_dup 21.Nm SSL_dup
22.Nd deep copy of an SSL object 22.Nd deep copy of an SSL object
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libssl libcrypto
24.In openssl/ssl.h 25.In openssl/ssl.h
25.Ft SSL * 26.Ft SSL *
26.Fo SSL_dup 27.Fo SSL_dup
diff --git a/src/lib/libssl/man/SSL_dup_CA_list.3 b/src/lib/libssl/man/SSL_dup_CA_list.3
index d073b07176..553c03bd8c 100644
--- a/src/lib/libssl/man/SSL_dup_CA_list.3
+++ b/src/lib/libssl/man/SSL_dup_CA_list.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_dup_CA_list.3,v 1.6 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_dup_CA_list.3,v 1.7 2025/06/08 22:47:20 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_DUP_CA_LIST 3 18.Dt SSL_DUP_CA_LIST 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,8 @@
22.Nd deep copy of a stack of X.509 Name objects 22.Nd deep copy of a stack of X.509 Name objects
23.\" The capital "N" in "Name" is intentional (X.509 syntax). 23.\" The capital "N" in "Name" is intentional (X.509 syntax).
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libssl libcrypto
26.In openssl/ssl.h
25.Ft STACK_OF(X509_NAME) * 27.Ft STACK_OF(X509_NAME) *
26.Fo SSL_dup_CA_list 28.Fo SSL_dup_CA_list
27.Fa "const STACK_OF(X509_NAME) *sk" 29.Fa "const STACK_OF(X509_NAME) *sk"
diff --git a/src/lib/libssl/man/SSL_export_keying_material.3 b/src/lib/libssl/man/SSL_export_keying_material.3
index e32a5c5d61..d3daa3a5a3 100644
--- a/src/lib/libssl/man/SSL_export_keying_material.3
+++ b/src/lib/libssl/man/SSL_export_keying_material.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_export_keying_material.3,v 1.3 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_export_keying_material.3,v 1.4 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL a599574b Jun 28 17:18:27 2017 +0100 2.\" OpenSSL a599574b Jun 28 17:18:27 2017 +0100
3.\" OpenSSL 23cec1f4 Jun 21 13:55:02 2017 +0100 3.\" OpenSSL 23cec1f4 Jun 21 13:55:02 2017 +0100
4.\" 4.\"
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 12 2019 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_EXPORT_KEYING_MATERIAL 3 53.Dt SSL_EXPORT_KEYING_MATERIAL 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm SSL_export_keying_material 56.Nm SSL_export_keying_material
57.Nd obtain keying material for application use 57.Nd obtain keying material for application use
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft int 61.Ft int
61.Fo SSL_export_keying_material 62.Fo SSL_export_keying_material
diff --git a/src/lib/libssl/man/SSL_free.3 b/src/lib/libssl/man/SSL_free.3
index c713ded121..b630bc8a2e 100644
--- a/src/lib/libssl/man/SSL_free.3
+++ b/src/lib/libssl/man/SSL_free.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_free.3,v 1.6 2021/06/11 19:41:39 jmc Exp $ 1.\" $OpenBSD: SSL_free.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 11 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_FREE 3 52.Dt SSL_FREE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_free 55.Nm SSL_free
56.Nd free an allocated SSL structure 56.Nd free an allocated SSL structure
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft void 60.Ft void
60.Fn SSL_free "SSL *ssl" 61.Fn SSL_free "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_SSL_CTX.3 b/src/lib/libssl/man/SSL_get_SSL_CTX.3
index 60fda555bc..eaf1b6ff11 100644
--- a/src/lib/libssl/man/SSL_get_SSL_CTX.3
+++ b/src/lib/libssl/man/SSL_get_SSL_CTX.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_SSL_CTX.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_SSL_CTX.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_SSL_CTX 3 52.Dt SSL_GET_SSL_CTX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_SSL_CTX 55.Nm SSL_get_SSL_CTX
56.Nd get the SSL_CTX from which an SSL is created 56.Nd get the SSL_CTX from which an SSL is created
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft SSL_CTX * 60.Ft SSL_CTX *
60.Fn SSL_get_SSL_CTX "const SSL *ssl" 61.Fn SSL_get_SSL_CTX "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_certificate.3 b/src/lib/libssl/man/SSL_get_certificate.3
index eb53ea49bf..72ae7ec541 100644
--- a/src/lib/libssl/man/SSL_get_certificate.3
+++ b/src/lib/libssl/man/SSL_get_certificate.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_certificate.3,v 1.5 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_get_certificate.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_GET_CERTIFICATE 3 18.Dt SSL_GET_CERTIFICATE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm SSL_get_privatekey 22.Nm SSL_get_privatekey
23.Nd get SSL certificate and private key 23.Nd get SSL certificate and private key
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libssl libcrypto
25.In openssl/ssl.h 26.In openssl/ssl.h
26.Ft X509 * 27.Ft X509 *
27.Fo SSL_get_certificate 28.Fo SSL_get_certificate
diff --git a/src/lib/libssl/man/SSL_get_ciphers.3 b/src/lib/libssl/man/SSL_get_ciphers.3
index 8030f0bbb1..d723f7959e 100644
--- a/src/lib/libssl/man/SSL_get_ciphers.3
+++ b/src/lib/libssl/man/SSL_get_ciphers.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_ciphers.3,v 1.11 2020/09/16 07:25:15 schwarze Exp $ 1.\" $OpenBSD: SSL_get_ciphers.3,v 1.12 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" selective merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 3.\" selective merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
4.\" 4.\"
@@ -69,7 +69,7 @@
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE. 70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\" 71.\"
72.Dd $Mdocdate: September 16 2020 $ 72.Dd $Mdocdate: June 8 2025 $
73.Dt SSL_GET_CIPHERS 3 73.Dt SSL_GET_CIPHERS 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
@@ -80,6 +80,7 @@
80.Nm SSL_get_cipher_list 80.Nm SSL_get_cipher_list
81.Nd get lists of available SSL_CIPHERs 81.Nd get lists of available SSL_CIPHERs
82.Sh SYNOPSIS 82.Sh SYNOPSIS
83.Lb libssl libcrypto
83.In openssl/ssl.h 84.In openssl/ssl.h
84.Ft STACK_OF(SSL_CIPHER) * 85.Ft STACK_OF(SSL_CIPHER) *
85.Fn SSL_get_ciphers "const SSL *ssl" 86.Fn SSL_get_ciphers "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_client_CA_list.3 b/src/lib/libssl/man/SSL_get_client_CA_list.3
index e80e5cb6f5..8be7020489 100644
--- a/src/lib/libssl/man/SSL_get_client_CA_list.3
+++ b/src/lib/libssl/man/SSL_get_client_CA_list.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_client_CA_list.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_client_CA_list.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 27 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_GET_CLIENT_CA_LIST 3 53.Dt SSL_GET_CLIENT_CA_LIST 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_CTX_get_client_CA_list 57.Nm SSL_CTX_get_client_CA_list
58.Nd get list of client CAs 58.Nd get list of client CAs
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft STACK_OF(X509_NAME) * 62.Ft STACK_OF(X509_NAME) *
62.Fn SSL_get_client_CA_list "const SSL *s" 63.Fn SSL_get_client_CA_list "const SSL *s"
diff --git a/src/lib/libssl/man/SSL_get_client_random.3 b/src/lib/libssl/man/SSL_get_client_random.3
index eda74db355..131972b688 100644
--- a/src/lib/libssl/man/SSL_get_client_random.3
+++ b/src/lib/libssl/man/SSL_get_client_random.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_client_random.3,v 1.2 2018/03/24 00:55:37 schwarze Exp $ 1.\" $OpenBSD: SSL_get_client_random.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\" 3.\"
4.\" This file was written by Nick Mathewson <nickm@torproject.org> 4.\" This file was written by Nick Mathewson <nickm@torproject.org>
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 24 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_CLIENT_RANDOM 3 52.Dt SSL_GET_CLIENT_RANDOM 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_SESSION_get_master_key 57.Nm SSL_SESSION_get_master_key
58.Nd get internal TLS handshake random values and master key 58.Nd get internal TLS handshake random values and master key
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft size_t 62.Ft size_t
62.Fo SSL_get_client_random 63.Fo SSL_get_client_random
diff --git a/src/lib/libssl/man/SSL_get_current_cipher.3 b/src/lib/libssl/man/SSL_get_current_cipher.3
index 6b951d03ca..37f6409023 100644
--- a/src/lib/libssl/man/SSL_get_current_cipher.3
+++ b/src/lib/libssl/man/SSL_get_current_cipher.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_current_cipher.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_current_cipher.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,17 +48,18 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_CURRENT_CIPHER 3 52.Dt SSL_GET_CURRENT_CIPHER 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_current_cipher , 55.Nm SSL_get_current_cipher ,
56.Nm SSL_get_cipher , 56.Nm SSL_get_cipher ,
57.Nm SSL_get_cipher_name , 57.Nm SSL_get_cipher_name ,
58.Nm SSL_get_cipher_bits , 58.Nm SSL_get_cipher_bits ,
59.Nm SSL_get_cipher_version 59.Nm SSL_get_cipher_version
60.Nd get SSL_CIPHER of a connection 60.Nd get SSL_CIPHER of a connection
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libssl libcrypto
62.In openssl/ssl.h 63.In openssl/ssl.h
63.Ft const SSL_CIPHER * 64.Ft const SSL_CIPHER *
64.Fn SSL_get_current_cipher "const SSL *ssl" 65.Fn SSL_get_current_cipher "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_default_timeout.3 b/src/lib/libssl/man/SSL_get_default_timeout.3
index 47737d8ee0..ef119780a3 100644
--- a/src/lib/libssl/man/SSL_get_default_timeout.3
+++ b/src/lib/libssl/man/SSL_get_default_timeout.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_default_timeout.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_default_timeout.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_DEFAULT_TIMEOUT 3 52.Dt SSL_GET_DEFAULT_TIMEOUT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_default_timeout 55.Nm SSL_get_default_timeout
56.Nd get default session timeout value 56.Nd get default session timeout value
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft long 60.Ft long
60.Fn SSL_get_default_timeout "const SSL *ssl" 61.Fn SSL_get_default_timeout "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_error.3 b/src/lib/libssl/man/SSL_get_error.3
index 5d325b3f56..ba64b779ac 100644
--- a/src/lib/libssl/man/SSL_get_error.3
+++ b/src/lib/libssl/man/SSL_get_error.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_error.3,v 1.5 2018/04/29 07:37:01 guenther Exp $ 1.\" $OpenBSD: SSL_get_error.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" 3.\"
4.\" This file was written by Bodo Moeller <bodo@openssl.org>. 4.\" This file was written by Bodo Moeller <bodo@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: April 29 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_ERROR 3 52.Dt SSL_GET_ERROR 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_error 55.Nm SSL_get_error
56.Nd obtain result code for TLS/SSL I/O operation 56.Nd obtain result code for TLS/SSL I/O operation
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fn SSL_get_error "const SSL *ssl" "int ret" 61.Fn SSL_get_error "const SSL *ssl" "int ret"
diff --git a/src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.3 b/src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.3
index a249cda6ac..234034ac2d 100644
--- a/src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.3
+++ b/src/lib/libssl/man/SSL_get_ex_data_X509_STORE_CTX_idx.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_ex_data_X509_STORE_CTX_idx.3,v 1.5 2022/02/06 00:29:02 jsg Exp $ 1.\" $OpenBSD: SSL_get_ex_data_X509_STORE_CTX_idx.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: February 6 2022 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_EX_DATA_X509_STORE_CTX_IDX 3 52.Dt SSL_GET_EX_DATA_X509_STORE_CTX_IDX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_ex_data_X509_STORE_CTX_idx 55.Nm SSL_get_ex_data_X509_STORE_CTX_idx
56.Nd get ex_data index to access SSL structure from X509_STORE_CTX 56.Nd get ex_data index to access SSL structure from X509_STORE_CTX
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fn SSL_get_ex_data_X509_STORE_CTX_idx void 61.Fn SSL_get_ex_data_X509_STORE_CTX_idx void
diff --git a/src/lib/libssl/man/SSL_get_ex_new_index.3 b/src/lib/libssl/man/SSL_get_ex_new_index.3
index cecd25fa44..811df94fc7 100644
--- a/src/lib/libssl/man/SSL_get_ex_new_index.3
+++ b/src/lib/libssl/man/SSL_get_ex_new_index.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_ex_new_index.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_ex_new_index.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_EX_NEW_INDEX 3 52.Dt SSL_GET_EX_NEW_INDEX 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_get_ex_data 57.Nm SSL_get_ex_data
58.Nd internal application specific data functions 58.Nd internal application specific data functions
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fo SSL_get_ex_new_index 63.Fo SSL_get_ex_new_index
diff --git a/src/lib/libssl/man/SSL_get_fd.3 b/src/lib/libssl/man/SSL_get_fd.3
index 1e093424cb..3a7948d35f 100644
--- a/src/lib/libssl/man/SSL_get_fd.3
+++ b/src/lib/libssl/man/SSL_get_fd.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_fd.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_fd.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_FD 3 52.Dt SSL_GET_FD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_get_wfd 57.Nm SSL_get_wfd
58.Nd get file descriptor linked to an SSL object 58.Nd get file descriptor linked to an SSL object
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fn SSL_get_fd "const SSL *ssl" 63.Fn SSL_get_fd "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_finished.3 b/src/lib/libssl/man/SSL_get_finished.3
index 3cfb655ea0..e5c8a36cf6 100644
--- a/src/lib/libssl/man/SSL_get_finished.3
+++ b/src/lib/libssl/man/SSL_get_finished.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_finished.3,v 1.2 2021/01/30 10:48:15 tb Exp $ 1.\" $OpenBSD: SSL_get_finished.3,v 1.3 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2020 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 30 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_GET_FINISHED 3 18.Dt SSL_GET_FINISHED 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -22,6 +22,7 @@
22.Nm SSL_get_peer_finished 22.Nm SSL_get_peer_finished
23.Nd get last sent or last expected finished message 23.Nd get last sent or last expected finished message
24.Sh SYNOPSIS 24.Sh SYNOPSIS
25.Lb libssl libcrypto
25.In openssl/ssl.h 26.In openssl/ssl.h
26.Ft size_t 27.Ft size_t
27.Fn SSL_get_finished "const SSL *ssl" "void *buf" "size_t count" 28.Fn SSL_get_finished "const SSL *ssl" "void *buf" "size_t count"
diff --git a/src/lib/libssl/man/SSL_get_peer_cert_chain.3 b/src/lib/libssl/man/SSL_get_peer_cert_chain.3
index eb2ae53dc4..c4f778aac6 100644
--- a/src/lib/libssl/man/SSL_get_peer_cert_chain.3
+++ b/src/lib/libssl/man/SSL_get_peer_cert_chain.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_peer_cert_chain.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_peer_cert_chain.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_get_peer_cert_chain.pod 1f164c6f Jan 18 01:40:36 2017 +0100 2.\" OpenSSL SSL_get_peer_cert_chain.pod 1f164c6f Jan 18 01:40:36 2017 +0100
3.\" OpenSSL SSL_get_peer_cert_chain.pod 9b86974e Aug 17 15:21:33 2015 -0400 3.\" OpenSSL SSL_get_peer_cert_chain.pod 9b86974e Aug 17 15:21:33 2015 -0400
4.\" 4.\"
@@ -50,13 +50,14 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: March 27 2018 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_GET_PEER_CERT_CHAIN 3 54.Dt SSL_GET_PEER_CERT_CHAIN 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
57.Nm SSL_get_peer_cert_chain 57.Nm SSL_get_peer_cert_chain
58.Nd get the X509 certificate chain sent by the peer 58.Nd get the X509 certificate chain sent by the peer
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft STACK_OF(X509) * 62.Ft STACK_OF(X509) *
62.Fn SSL_get_peer_cert_chain "const SSL *ssl" 63.Fn SSL_get_peer_cert_chain "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_peer_certificate.3 b/src/lib/libssl/man/SSL_get_peer_certificate.3
index 99f9330288..9ac35a607d 100644
--- a/src/lib/libssl/man/SSL_get_peer_certificate.3
+++ b/src/lib/libssl/man/SSL_get_peer_certificate.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_peer_certificate.3,v 1.6 2021/06/26 17:36:28 tb Exp $ 1.\" $OpenBSD: SSL_get_peer_certificate.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 26 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_PEER_CERTIFICATE 3 52.Dt SSL_GET_PEER_CERTIFICATE 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_peer_certificate 55.Nm SSL_get_peer_certificate
56.Nd get the X509 certificate of the peer 56.Nd get the X509 certificate of the peer
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft X509 * 60.Ft X509 *
60.Fn SSL_get_peer_certificate "const SSL *ssl" 61.Fn SSL_get_peer_certificate "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_rbio.3 b/src/lib/libssl/man/SSL_get_rbio.3
index 38096fbecf..7179277f71 100644
--- a/src/lib/libssl/man/SSL_get_rbio.3
+++ b/src/lib/libssl/man/SSL_get_rbio.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_rbio.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_get_rbio.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_RBIO 3 52.Dt SSL_GET_RBIO 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_get_wbio 56.Nm SSL_get_wbio
57.Nd get BIO linked to an SSL object 57.Nd get BIO linked to an SSL object
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft BIO * 61.Ft BIO *
61.Fn SSL_get_rbio "SSL *ssl" 62.Fn SSL_get_rbio "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_server_tmp_key.3 b/src/lib/libssl/man/SSL_get_server_tmp_key.3
index aeeb358240..c55036d526 100644
--- a/src/lib/libssl/man/SSL_get_server_tmp_key.3
+++ b/src/lib/libssl/man/SSL_get_server_tmp_key.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_server_tmp_key.3,v 1.4 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_get_server_tmp_key.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_get_server_tmp_key.pod 508fafd8 Apr 3 15:41:21 2017 +0100 2.\" OpenSSL SSL_get_server_tmp_key.pod 508fafd8 Apr 3 15:41:21 2017 +0100
3.\" 3.\"
4.\" This file was written by Matt Caswell <matt@openssl.org> 4.\" This file was written by Matt Caswell <matt@openssl.org>
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 12 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_SERVER_TMP_KEY 3 52.Dt SSL_GET_SERVER_TMP_KEY 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_server_tmp_key 55.Nm SSL_get_server_tmp_key
56.Nd temporary server key during a handshake 56.Nd temporary server key during a handshake
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft long 60.Ft long
60.Fo SSL_get_server_tmp_key 61.Fo SSL_get_server_tmp_key
diff --git a/src/lib/libssl/man/SSL_get_session.3 b/src/lib/libssl/man/SSL_get_session.3
index 2ab43fdd3e..597888a0bd 100644
--- a/src/lib/libssl/man/SSL_get_session.3
+++ b/src/lib/libssl/man/SSL_get_session.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_session.3,v 1.8 2022/03/31 17:27:18 naddy Exp $ 1.\" $OpenBSD: SSL_get_session.3,v 1.9 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 31 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_GET_SESSION 3 53.Dt SSL_GET_SESSION 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -58,6 +58,7 @@
58.Nm SSL_get1_session 58.Nm SSL_get1_session
59.Nd retrieve TLS/SSL session data 59.Nd retrieve TLS/SSL session data
60.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
61.In openssl/ssl.h 62.In openssl/ssl.h
62.Ft SSL_SESSION * 63.Ft SSL_SESSION *
63.Fn SSL_get_session "const SSL *ssl" 64.Fn SSL_get_session "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_shared_ciphers.3 b/src/lib/libssl/man/SSL_get_shared_ciphers.3
index 207e8c42eb..9011780527 100644
--- a/src/lib/libssl/man/SSL_get_shared_ciphers.3
+++ b/src/lib/libssl/man/SSL_get_shared_ciphers.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_shared_ciphers.3,v 1.5 2021/01/09 10:50:02 tb Exp $ 1.\" $OpenBSD: SSL_get_shared_ciphers.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 9 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_GET_SHARED_CIPHERS 3 18.Dt SSL_GET_SHARED_CIPHERS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SSL_get_shared_ciphers 21.Nm SSL_get_shared_ciphers
22.Nd ciphers supported by both client and server 22.Nd ciphers supported by both client and server
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libssl libcrypto
24.In openssl/ssl.h 25.In openssl/ssl.h
25.Ft char * 26.Ft char *
26.Fo SSL_get_shared_ciphers 27.Fo SSL_get_shared_ciphers
diff --git a/src/lib/libssl/man/SSL_get_state.3 b/src/lib/libssl/man/SSL_get_state.3
index 297bbce876..0e1a20e6f7 100644
--- a/src/lib/libssl/man/SSL_get_state.3
+++ b/src/lib/libssl/man/SSL_get_state.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_state.3,v 1.5 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_get_state.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_GET_STATE 3 18.Dt SSL_GET_STATE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -27,6 +27,7 @@
27.Nm SSL_is_init_finished 27.Nm SSL_is_init_finished
28.Nd inspect the state of the SSL state machine 28.Nd inspect the state of the SSL state machine
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libssl libcrypto
30.In openssl/ssl.h 31.In openssl/ssl.h
31.Ft int 32.Ft int
32.Fo SSL_get_state 33.Fo SSL_get_state
diff --git a/src/lib/libssl/man/SSL_get_verify_result.3 b/src/lib/libssl/man/SSL_get_verify_result.3
index 180cf1bb73..32a397f4a2 100644
--- a/src/lib/libssl/man/SSL_get_verify_result.3
+++ b/src/lib/libssl/man/SSL_get_verify_result.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_verify_result.3,v 1.6 2021/06/26 17:36:28 tb Exp $ 1.\" $OpenBSD: SSL_get_verify_result.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 26 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_GET_VERIFY_RESULT 3 52.Dt SSL_GET_VERIFY_RESULT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_get_verify_result 55.Nm SSL_get_verify_result
56.Nd get result of peer certificate verification 56.Nd get result of peer certificate verification
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft long 60.Ft long
60.Fn SSL_get_verify_result "const SSL *ssl" 61.Fn SSL_get_verify_result "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_get_version.3 b/src/lib/libssl/man/SSL_get_version.3
index a6cefb055b..d32dd34e0e 100644
--- a/src/lib/libssl/man/SSL_get_version.3
+++ b/src/lib/libssl/man/SSL_get_version.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_get_version.3,v 1.9 2021/04/15 16:13:22 tb Exp $ 1.\" $OpenBSD: SSL_get_version.3,v 1.10 2025/06/08 22:49:42 schwarze Exp $
2.\" full merge up to: OpenSSL e417070c Jun 8 11:37:06 2016 -0400 2.\" full merge up to: OpenSSL e417070c Jun 8 11:37:06 2016 -0400
3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
4.\" 4.\"
@@ -49,21 +49,16 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: April 15 2021 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_GET_VERSION 3 53.Dt SSL_GET_VERSION 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm SSL_get_version , 56.Nm SSL_get_version ,
57.Nm SSL_is_dtls , 57.Nm SSL_is_dtls ,
58.Nm SSL_version 58.Nm SSL_version
59.\" The following are intentionally undocumented because
60.\" - the longer term plan is to remove them
61.\" - nothing appears to be using them in the wild
62.\" - and they have the wrong namespace prefix
63.\" Nm TLS1_get_version
64.\" Nm TLS1_get_client_version
65.Nd get the protocol information of a connection 59.Nd get the protocol information of a connection
66.Sh SYNOPSIS 60.Sh SYNOPSIS
61.Lb libssl libcrypto
67.In openssl/ssl.h 62.In openssl/ssl.h
68.Ft const char * 63.Ft const char *
69.Fn SSL_get_version "const SSL *ssl" 64.Fn SSL_get_version "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_library_init.3 b/src/lib/libssl/man/SSL_library_init.3
index 053c1e6fcb..d25a248617 100644
--- a/src/lib/libssl/man/SSL_library_init.3
+++ b/src/lib/libssl/man/SSL_library_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_library_init.3,v 1.7 2019/06/14 13:41:31 schwarze Exp $ 1.\" $OpenBSD: SSL_library_init.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 14 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_LIBRARY_INIT 3 52.Dt SSL_LIBRARY_INIT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSLeay_add_ssl_algorithms 57.Nm SSLeay_add_ssl_algorithms
58.Nd initialize SSL library by registering algorithms 58.Nd initialize SSL library by registering algorithms
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fn SSL_library_init void 63.Fn SSL_library_init void
diff --git a/src/lib/libssl/man/SSL_load_client_CA_file.3 b/src/lib/libssl/man/SSL_load_client_CA_file.3
index f782d96dce..e57900c941 100644
--- a/src/lib/libssl/man/SSL_load_client_CA_file.3
+++ b/src/lib/libssl/man/SSL_load_client_CA_file.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_load_client_CA_file.3,v 1.9 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_load_client_CA_file.3,v 1.10 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: June 12 2019 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt SSL_LOAD_CLIENT_CA_FILE 3 69.Dt SSL_LOAD_CLIENT_CA_FILE 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -74,6 +74,7 @@
74.Nm SSL_add_dir_cert_subjects_to_stack 74.Nm SSL_add_dir_cert_subjects_to_stack
75.Nd load certificate names from files 75.Nd load certificate names from files
76.Sh SYNOPSIS 76.Sh SYNOPSIS
77.Lb libssl libcrypto
77.In openssl/ssl.h 78.In openssl/ssl.h
78.Ft STACK_OF(X509_NAME) * 79.Ft STACK_OF(X509_NAME) *
79.Fn SSL_load_client_CA_file "const char *file" 80.Fn SSL_load_client_CA_file "const char *file"
diff --git a/src/lib/libssl/man/SSL_new.3 b/src/lib/libssl/man/SSL_new.3
index 22c5dbf2db..3906a346d7 100644
--- a/src/lib/libssl/man/SSL_new.3
+++ b/src/lib/libssl/man/SSL_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_new.3,v 1.7 2022/07/13 22:05:53 schwarze Exp $ 1.\" $OpenBSD: SSL_new.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 1c7ae3dd Mar 29 19:17:55 2017 +1000 2.\" full merge up to: OpenSSL 1c7ae3dd Mar 29 19:17:55 2017 +1000
3.\" 3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org> 4.\" This file was written by Richard Levitte <levitte@openssl.org>
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: July 13 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_NEW 3 53.Dt SSL_NEW 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_up_ref 57.Nm SSL_up_ref
58.Nd create a new SSL structure for a connection 58.Nd create a new SSL structure for a connection
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft SSL * 62.Ft SSL *
62.Fn SSL_new "SSL_CTX *ctx" 63.Fn SSL_new "SSL_CTX *ctx"
diff --git a/src/lib/libssl/man/SSL_num_renegotiations.3 b/src/lib/libssl/man/SSL_num_renegotiations.3
index 6a81b76a60..d366f97c4a 100644
--- a/src/lib/libssl/man/SSL_num_renegotiations.3
+++ b/src/lib/libssl/man/SSL_num_renegotiations.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_num_renegotiations.3,v 1.5 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_num_renegotiations.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 12 2019 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_NUM_RENEGOTIATIONS 3 18.Dt SSL_NUM_RENEGOTIATIONS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -23,6 +23,7 @@
23.Nm SSL_total_renegotiations 23.Nm SSL_total_renegotiations
24.Nd renegotiation counters 24.Nd renegotiation counters
25.Sh SYNOPSIS 25.Sh SYNOPSIS
26.Lb libssl libcrypto
26.In openssl/ssl.h 27.In openssl/ssl.h
27.Ft long 28.Ft long
28.Fo SSL_num_renegotiations 29.Fo SSL_num_renegotiations
diff --git a/src/lib/libssl/man/SSL_pending.3 b/src/lib/libssl/man/SSL_pending.3
index bbc2e9bdd2..c304302ed8 100644
--- a/src/lib/libssl/man/SSL_pending.3
+++ b/src/lib/libssl/man/SSL_pending.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_pending.3,v 1.5 2020/01/23 03:40:18 beck Exp $ 1.\" $OpenBSD: SSL_pending.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>, 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>,
@@ -50,13 +50,14 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: January 23 2020 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_PENDING 3 54.Dt SSL_PENDING 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
57.Nm SSL_pending 57.Nm SSL_pending
58.Nd obtain number of readable bytes buffered in an SSL object 58.Nd obtain number of readable bytes buffered in an SSL object
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fn SSL_pending "const SSL *ssl" 63.Fn SSL_pending "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_read.3 b/src/lib/libssl/man/SSL_read.3
index bb72a8ed82..3d42fd8a90 100644
--- a/src/lib/libssl/man/SSL_read.3
+++ b/src/lib/libssl/man/SSL_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_read.3,v 1.8 2021/10/24 15:10:13 schwarze Exp $ 1.\" $OpenBSD: SSL_read.3,v 1.9 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL 5a2443ae Nov 14 11:37:36 2016 +0000 2.\" full merge up to: OpenSSL 5a2443ae Nov 14 11:37:36 2016 +0000
3.\" partial merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" partial merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: October 24 2021 $ 54.Dd $Mdocdate: June 8 2025 $
55.Dt SSL_READ 3 55.Dt SSL_READ 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -61,6 +61,7 @@
61.Nm SSL_peek 61.Nm SSL_peek
62.Nd read bytes from a TLS connection 62.Nd read bytes from a TLS connection
63.Sh SYNOPSIS 63.Sh SYNOPSIS
64.Lb libssl libcrypto
64.In openssl/ssl.h 65.In openssl/ssl.h
65.Ft int 66.Ft int
66.Fn SSL_read_ex "SSL *ssl" "void *buf" "size_t num" "size_t *readbytes" 67.Fn SSL_read_ex "SSL *ssl" "void *buf" "size_t num" "size_t *readbytes"
diff --git a/src/lib/libssl/man/SSL_read_early_data.3 b/src/lib/libssl/man/SSL_read_early_data.3
index 1435c15935..d36b1e49f7 100644
--- a/src/lib/libssl/man/SSL_read_early_data.3
+++ b/src/lib/libssl/man/SSL_read_early_data.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_read_early_data.3,v 1.4 2021/11/26 13:48:22 jsg Exp $ 1.\" $OpenBSD: SSL_read_early_data.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" content checked up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200 2.\" content checked up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
3.\" 3.\"
4.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: November 26 2021 $ 18.Dd $Mdocdate: June 8 2025 $
19.Dt SSL_READ_EARLY_DATA 3 19.Dt SSL_READ_EARLY_DATA 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -30,6 +30,7 @@
30.Nm SSL_get_early_data_status 30.Nm SSL_get_early_data_status
31.Nd transmit application data during the handshake 31.Nd transmit application data during the handshake
32.Sh SYNOPSIS 32.Sh SYNOPSIS
33.Lb libssl libcrypto
33.In openssl/ssl.h 34.In openssl/ssl.h
34.Ft int 35.Ft int
35.Fo SSL_CTX_set_max_early_data 36.Fo SSL_CTX_set_max_early_data
diff --git a/src/lib/libssl/man/SSL_renegotiate.3 b/src/lib/libssl/man/SSL_renegotiate.3
index 8188d37323..badfe8c6cb 100644
--- a/src/lib/libssl/man/SSL_renegotiate.3
+++ b/src/lib/libssl/man/SSL_renegotiate.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_renegotiate.3,v 1.9 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_renegotiate.3,v 1.10 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL SSL_key_update.pod 4fbfe86a Feb 16 17:04:40 2017 +0000 2.\" OpenSSL SSL_key_update.pod 4fbfe86a Feb 16 17:04:40 2017 +0000
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: June 12 2019 $ 68.Dd $Mdocdate: June 8 2025 $
69.Dt SSL_RENEGOTIATE 3 69.Dt SSL_RENEGOTIATE 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -74,6 +74,7 @@
74.Nm SSL_renegotiate_pending 74.Nm SSL_renegotiate_pending
75.Nd initiate a new TLS handshake 75.Nd initiate a new TLS handshake
76.Sh SYNOPSIS 76.Sh SYNOPSIS
77.Lb libssl libcrypto
77.In openssl/ssl.h 78.In openssl/ssl.h
78.Ft int 79.Ft int
79.Fo SSL_renegotiate 80.Fo SSL_renegotiate
diff --git a/src/lib/libssl/man/SSL_rstate_string.3 b/src/lib/libssl/man/SSL_rstate_string.3
index 99613ba3c0..624c1b08ab 100644
--- a/src/lib/libssl/man/SSL_rstate_string.3
+++ b/src/lib/libssl/man/SSL_rstate_string.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_rstate_string.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_rstate_string.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_RSTATE_STRING 3 52.Dt SSL_RSTATE_STRING 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_rstate_string_long 56.Nm SSL_rstate_string_long
57.Nd get textual description of state of an SSL object during read operation 57.Nd get textual description of state of an SSL object during read operation
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft const char * 61.Ft const char *
61.Fn SSL_rstate_string "SSL *ssl" 62.Fn SSL_rstate_string "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_session_reused.3 b/src/lib/libssl/man/SSL_session_reused.3
index add61a904b..3340144660 100644
--- a/src/lib/libssl/man/SSL_session_reused.3
+++ b/src/lib/libssl/man/SSL_session_reused.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_session_reused.3,v 1.6 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_session_reused.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 12 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SESSION_REUSED 3 52.Dt SSL_SESSION_REUSED 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_session_reused 55.Nm SSL_session_reused
56.Nd query whether a reused session was negotiated during handshake 56.Nd query whether a reused session was negotiated during handshake
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fn SSL_session_reused "SSL *ssl" 61.Fn SSL_session_reused "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_set1_host.3 b/src/lib/libssl/man/SSL_set1_host.3
index 2a3935c3f2..2c6cdbe5a1 100644
--- a/src/lib/libssl/man/SSL_set1_host.3
+++ b/src/lib/libssl/man/SSL_set1_host.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set1_host.3,v 1.4 2021/03/31 16:56:46 tb Exp $ 1.\" $OpenBSD: SSL_set1_host.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200 2.\" selective merge up to: OpenSSL 6328d367 Jul 4 21:58:30 2020 +0200
3.\" 3.\"
4.\" This file was written by Viktor Dukhovni <viktor@openssl.org> 4.\" This file was written by Viktor Dukhovni <viktor@openssl.org>
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 31 2021 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SET1_HOST 3 52.Dt SSL_SET1_HOST 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_get0_peername 57.Nm SSL_get0_peername
58.Nd SSL server verification parameters 58.Nd SSL server verification parameters
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fo SSL_set1_host 63.Fo SSL_set1_host
diff --git a/src/lib/libssl/man/SSL_set1_param.3 b/src/lib/libssl/man/SSL_set1_param.3
index cd8ad40ad0..2d255a0991 100644
--- a/src/lib/libssl/man/SSL_set1_param.3
+++ b/src/lib/libssl/man/SSL_set1_param.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set1_param.3,v 1.6 2022/09/10 10:22:46 jsg Exp $ 1.\" $OpenBSD: SSL_set1_param.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL man3/SSL_CTX_get0_param 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" OpenSSL man3/SSL_CTX_get0_param 99d63d46 Oct 26 13:56:48 2016 -0400
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: September 10 2022 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_SET1_PARAM 3 53.Dt SSL_SET1_PARAM 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -59,6 +59,7 @@
59.Nm SSL_set1_param 59.Nm SSL_set1_param
60.Nd get and set verification parameters 60.Nd get and set verification parameters
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libssl libcrypto
62.In openssl/ssl.h 63.In openssl/ssl.h
63.Ft X509_VERIFY_PARAM * 64.Ft X509_VERIFY_PARAM *
64.Fo SSL_CTX_get0_param 65.Fo SSL_CTX_get0_param
diff --git a/src/lib/libssl/man/SSL_set_SSL_CTX.3 b/src/lib/libssl/man/SSL_set_SSL_CTX.3
index 2abaefb292..3a909dabe6 100644
--- a/src/lib/libssl/man/SSL_set_SSL_CTX.3
+++ b/src/lib/libssl/man/SSL_set_SSL_CTX.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_SSL_CTX.3,v 1.4 2022/07/13 22:05:53 schwarze Exp $ 1.\" $OpenBSD: SSL_set_SSL_CTX.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 13 2022 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_SET_SSL_CTX 3 18.Dt SSL_SET_SSL_CTX 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm SSL_set_SSL_CTX 21.Nm SSL_set_SSL_CTX
22.Nd modify an SSL connection object to use another context 22.Nd modify an SSL connection object to use another context
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libssl libcrypto
24.In openssl/ssl.h 25.In openssl/ssl.h
25.Ft SSL_CTX * 26.Ft SSL_CTX *
26.Fo SSL_set_SSL_CTX 27.Fo SSL_set_SSL_CTX
diff --git a/src/lib/libssl/man/SSL_set_bio.3 b/src/lib/libssl/man/SSL_set_bio.3
index e727f442d6..98ce9a7080 100644
--- a/src/lib/libssl/man/SSL_set_bio.3
+++ b/src/lib/libssl/man/SSL_set_bio.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_bio.3,v 1.6 2020/10/08 18:21:30 tb Exp $ 1.\" $OpenBSD: SSL_set_bio.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL acb5b343 Sep 16 16:00:38 2000 +0000 2.\" OpenSSL acb5b343 Sep 16 16:00:38 2000 +0000
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: October 8 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SET_BIO 3 52.Dt SSL_SET_BIO 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_set_bio 55.Nm SSL_set_bio
56.Nd connect the SSL object with a BIO 56.Nd connect the SSL object with a BIO
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft void 60.Ft void
60.Fn SSL_set_bio "SSL *ssl" "BIO *rbio" "BIO *wbio" 61.Fn SSL_set_bio "SSL *ssl" "BIO *rbio" "BIO *wbio"
diff --git a/src/lib/libssl/man/SSL_set_connect_state.3 b/src/lib/libssl/man/SSL_set_connect_state.3
index c2072c4370..b7d126d046 100644
--- a/src/lib/libssl/man/SSL_set_connect_state.3
+++ b/src/lib/libssl/man/SSL_set_connect_state.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_connect_state.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_set_connect_state.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 2.\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\" selective merge up to: OpenSSL dbd007d7 Jul 28 13:31:27 2017 +0800 3.\" selective merge up to: OpenSSL dbd007d7 Jul 28 13:31:27 2017 +0800
4.\" 4.\"
@@ -50,7 +50,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 52.\"
53.Dd $Mdocdate: March 27 2018 $ 53.Dd $Mdocdate: June 8 2025 $
54.Dt SSL_SET_CONNECT_STATE 3 54.Dt SSL_SET_CONNECT_STATE 3
55.Os 55.Os
56.Sh NAME 56.Sh NAME
@@ -59,6 +59,7 @@
59.Nm SSL_is_server 59.Nm SSL_is_server
60.Nd prepare SSL object to work in client or server mode 60.Nd prepare SSL object to work in client or server mode
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libssl libcrypto
62.In openssl/ssl.h 63.In openssl/ssl.h
63.Ft void 64.Ft void
64.Fn SSL_set_connect_state "SSL *ssl" 65.Fn SSL_set_connect_state "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_set_fd.3 b/src/lib/libssl/man/SSL_set_fd.3
index 7b9727e9ad..3c4441e677 100644
--- a/src/lib/libssl/man/SSL_set_fd.3
+++ b/src/lib/libssl/man/SSL_set_fd.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_fd.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_set_fd.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SET_FD 3 52.Dt SSL_SET_FD 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_set_wfd 57.Nm SSL_set_wfd
58.Nd connect the SSL object with a file descriptor 58.Nd connect the SSL object with a file descriptor
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft int 62.Ft int
62.Fn SSL_set_fd "SSL *ssl" "int fd" 63.Fn SSL_set_fd "SSL *ssl" "int fd"
diff --git a/src/lib/libssl/man/SSL_set_max_send_fragment.3 b/src/lib/libssl/man/SSL_set_max_send_fragment.3
index 7de087a743..d5265ebb74 100644
--- a/src/lib/libssl/man/SSL_set_max_send_fragment.3
+++ b/src/lib/libssl/man/SSL_set_max_send_fragment.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_max_send_fragment.3,v 1.5 2019/06/12 09:36:30 schwarze Exp $ 1.\" $OpenBSD: SSL_set_max_send_fragment.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL doc/man3/SSL_CTX_set_split_send_fragment.pod 2.\" OpenSSL doc/man3/SSL_CTX_set_split_send_fragment.pod
3.\" OpenSSL 6782e5fd Oct 21 16:16:20 2016 +0100 3.\" OpenSSL 6782e5fd Oct 21 16:16:20 2016 +0100
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: June 12 2019 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_SET_MAX_SEND_FRAGMENT 3 53.Dt SSL_SET_MAX_SEND_FRAGMENT 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -57,6 +57,7 @@
57.Nm SSL_set_max_send_fragment 57.Nm SSL_set_max_send_fragment
58.Nd control fragment sizes 58.Nd control fragment sizes
59.Sh SYNOPSIS 59.Sh SYNOPSIS
60.Lb libssl libcrypto
60.In openssl/ssl.h 61.In openssl/ssl.h
61.Ft long 62.Ft long
62.Fo SSL_CTX_set_max_send_fragment 63.Fo SSL_CTX_set_max_send_fragment
diff --git a/src/lib/libssl/man/SSL_set_psk_use_session_callback.3 b/src/lib/libssl/man/SSL_set_psk_use_session_callback.3
index 7f2bfcc010..d53f5b97c9 100644
--- a/src/lib/libssl/man/SSL_set_psk_use_session_callback.3
+++ b/src/lib/libssl/man/SSL_set_psk_use_session_callback.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_psk_use_session_callback.3,v 1.1 2021/09/14 14:30:57 schwarze Exp $ 1.\" $OpenBSD: SSL_set_psk_use_session_callback.3,v 1.2 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL man3/SSL_CTX_set_psk_client_callback.pod 2.\" OpenSSL man3/SSL_CTX_set_psk_client_callback.pod
3.\" checked up to 24a535ea Sep 22 13:14:20 2020 +0100 3.\" checked up to 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: September 14 2021 $ 19.Dd $Mdocdate: June 8 2025 $
20.Dt SSL_SET_PSK_USE_SESSION_CALLBACK 3 20.Dt SSL_SET_PSK_USE_SESSION_CALLBACK 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -24,6 +24,7 @@
24.Nm SSL_psk_use_session_cb_func 24.Nm SSL_psk_use_session_cb_func
25.Nd set TLS pre-shared key client callback 25.Nd set TLS pre-shared key client callback
26.Sh SYNOPSIS 26.Sh SYNOPSIS
27.Lb libssl libcrypto
27.In openssl/ssl.h 28.In openssl/ssl.h
28.Ft typedef int 29.Ft typedef int
29.Fo (*SSL_psk_use_session_cb_func) 30.Fo (*SSL_psk_use_session_cb_func)
diff --git a/src/lib/libssl/man/SSL_set_session.3 b/src/lib/libssl/man/SSL_set_session.3
index 7d85f5ad0c..db3fc6a85c 100644
--- a/src/lib/libssl/man/SSL_set_session.3
+++ b/src/lib/libssl/man/SSL_set_session.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_session.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_set_session.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 2.\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SET_SESSION 3 52.Dt SSL_SET_SESSION 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_set_session 55.Nm SSL_set_session
56.Nd set a TLS/SSL session to be used during TLS/SSL connect 56.Nd set a TLS/SSL session to be used during TLS/SSL connect
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft int 60.Ft int
60.Fn SSL_set_session "SSL *ssl" "SSL_SESSION *session" 61.Fn SSL_set_session "SSL *ssl" "SSL_SESSION *session"
diff --git a/src/lib/libssl/man/SSL_set_shutdown.3 b/src/lib/libssl/man/SSL_set_shutdown.3
index ef8c004f76..1c1d59e927 100644
--- a/src/lib/libssl/man/SSL_set_shutdown.3
+++ b/src/lib/libssl/man/SSL_set_shutdown.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_shutdown.3,v 1.7 2024/12/19 06:45:21 jmc Exp $ 1.\" $OpenBSD: SSL_set_shutdown.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 19 2024 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SET_SHUTDOWN 3 52.Dt SSL_SET_SHUTDOWN 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_get_shutdown 56.Nm SSL_get_shutdown
57.Nd manipulate shutdown state of an SSL connection 57.Nd manipulate shutdown state of an SSL connection
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft void 61.Ft void
61.Fn SSL_set_shutdown "SSL *ssl" "int mode" 62.Fn SSL_set_shutdown "SSL *ssl" "int mode"
diff --git a/src/lib/libssl/man/SSL_set_tmp_ecdh.3 b/src/lib/libssl/man/SSL_set_tmp_ecdh.3
index 8fd2d9fd5b..0794efdfb7 100644
--- a/src/lib/libssl/man/SSL_set_tmp_ecdh.3
+++ b/src/lib/libssl/man/SSL_set_tmp_ecdh.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_tmp_ecdh.3,v 1.6 2021/11/30 15:58:08 jsing Exp $ 1.\" $OpenBSD: SSL_set_tmp_ecdh.3,v 1.7 2025/06/08 22:52:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 30 2021 $ 17.Dd $Mdocdate: June 8 2025 $
18.Dt SSL_SET_TMP_ECDH 3 18.Dt SSL_SET_TMP_ECDH 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -26,6 +26,7 @@
26.Nm SSL_CTX_set_tmp_ecdh_callback 26.Nm SSL_CTX_set_tmp_ecdh_callback
27.Nd select a curve for ECDH ephemeral key exchange 27.Nd select a curve for ECDH ephemeral key exchange
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libssl libcrypto
29.In openssl/ssl.h 30.In openssl/ssl.h
30.Ft long 31.Ft long
31.Fo SSL_set_tmp_ecdh 32.Fo SSL_set_tmp_ecdh
diff --git a/src/lib/libssl/man/SSL_set_verify_result.3 b/src/lib/libssl/man/SSL_set_verify_result.3
index 4b7cc6ec3c..f43d375bc9 100644
--- a/src/lib/libssl/man/SSL_set_verify_result.3
+++ b/src/lib/libssl/man/SSL_set_verify_result.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_set_verify_result.3,v 1.5 2020/03/29 17:05:02 schwarze Exp $ 1.\" $OpenBSD: SSL_set_verify_result.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,13 +48,14 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 29 2020 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_SET_VERIFY_RESULT 3 52.Dt SSL_SET_VERIFY_RESULT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
55.Nm SSL_set_verify_result 55.Nm SSL_set_verify_result
56.Nd override result of peer certificate verification 56.Nd override result of peer certificate verification
57.Sh SYNOPSIS 57.Sh SYNOPSIS
58.Lb libssl libcrypto
58.In openssl/ssl.h 59.In openssl/ssl.h
59.Ft void 60.Ft void
60.Fn SSL_set_verify_result "SSL *ssl" "long verify_result" 61.Fn SSL_set_verify_result "SSL *ssl" "long verify_result"
diff --git a/src/lib/libssl/man/SSL_shutdown.3 b/src/lib/libssl/man/SSL_shutdown.3
index bfb1e91ea7..ad49a47d8e 100644
--- a/src/lib/libssl/man/SSL_shutdown.3
+++ b/src/lib/libssl/man/SSL_shutdown.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_shutdown.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_shutdown.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -49,13 +49,14 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: March 27 2018 $ 52.Dd $Mdocdate: June 8 2025 $
53.Dt SSL_SHUTDOWN 3 53.Dt SSL_SHUTDOWN 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
56.Nm SSL_shutdown 56.Nm SSL_shutdown
57.Nd shut down a TLS/SSL connection 57.Nd shut down a TLS/SSL connection
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft int 61.Ft int
61.Fn SSL_shutdown "SSL *ssl" 62.Fn SSL_shutdown "SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_state_string.3 b/src/lib/libssl/man/SSL_state_string.3
index 1070335448..d202056eec 100644
--- a/src/lib/libssl/man/SSL_state_string.3
+++ b/src/lib/libssl/man/SSL_state_string.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_state_string.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_state_string.3,v 1.5 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_STATE_STRING 3 52.Dt SSL_STATE_STRING 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm SSL_state_string_long 56.Nm SSL_state_string_long
57.Nd get textual description of state of an SSL object 57.Nd get textual description of state of an SSL object
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft const char * 61.Ft const char *
61.Fn SSL_state_string "const SSL *ssl" 62.Fn SSL_state_string "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_want.3 b/src/lib/libssl/man/SSL_want.3
index 24e8645ba8..c7c2ee4885 100644
--- a/src/lib/libssl/man/SSL_want.3
+++ b/src/lib/libssl/man/SSL_want.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_want.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 1.\" $OpenBSD: SSL_want.3,v 1.6 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 2.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: March 27 2018 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt SSL_WANT 3 52.Dt SSL_WANT 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -59,6 +59,7 @@
59.Nm SSL_want_x509_lookup 59.Nm SSL_want_x509_lookup
60.Nd obtain state information TLS/SSL I/O operation 60.Nd obtain state information TLS/SSL I/O operation
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libssl libcrypto
62.In openssl/ssl.h 63.In openssl/ssl.h
63.Ft int 64.Ft int
64.Fn SSL_want "const SSL *ssl" 65.Fn SSL_want "const SSL *ssl"
diff --git a/src/lib/libssl/man/SSL_write.3 b/src/lib/libssl/man/SSL_write.3
index 2c6fbcef08..54d0953e82 100644
--- a/src/lib/libssl/man/SSL_write.3
+++ b/src/lib/libssl/man/SSL_write.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: SSL_write.3,v 1.7 2021/10/24 15:10:13 schwarze Exp $ 1.\" $OpenBSD: SSL_write.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" partial merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" partial merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: October 24 2021 $ 54.Dd $Mdocdate: June 8 2025 $
55.Dt SSL_WRITE 3 55.Dt SSL_WRITE 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -59,6 +59,7 @@
59.Nm SSL_write 59.Nm SSL_write
60.Nd write bytes to a TLS connection 60.Nd write bytes to a TLS connection
61.Sh SYNOPSIS 61.Sh SYNOPSIS
62.Lb libssl libcrypto
62.In openssl/ssl.h 63.In openssl/ssl.h
63.Ft int 64.Ft int
64.Fn SSL_write_ex "SSL *ssl" "const void *buf" "size_t num" "size_t *written" 65.Fn SSL_write_ex "SSL *ssl" "const void *buf" "size_t num" "size_t *written"
diff --git a/src/lib/libssl/man/d2i_SSL_SESSION.3 b/src/lib/libssl/man/d2i_SSL_SESSION.3
index 7a2bc529ab..6b0dfc86b9 100644
--- a/src/lib/libssl/man/d2i_SSL_SESSION.3
+++ b/src/lib/libssl/man/d2i_SSL_SESSION.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_SSL_SESSION.3,v 1.7 2019/06/08 15:25:43 schwarze Exp $ 1.\" $OpenBSD: d2i_SSL_SESSION.3,v 1.8 2025/06/08 22:52:00 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: June 8 2019 $ 51.Dd $Mdocdate: June 8 2025 $
52.Dt D2I_SSL_SESSION 3 52.Dt D2I_SSL_SESSION 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -56,6 +56,7 @@
56.Nm i2d_SSL_SESSION 56.Nm i2d_SSL_SESSION
57.Nd convert SSL_SESSION object from/to ASN1 representation 57.Nd convert SSL_SESSION object from/to ASN1 representation
58.Sh SYNOPSIS 58.Sh SYNOPSIS
59.Lb libssl libcrypto
59.In openssl/ssl.h 60.In openssl/ssl.h
60.Ft SSL_SESSION * 61.Ft SSL_SESSION *
61.Fn d2i_SSL_SESSION "SSL_SESSION **a" "const unsigned char **pp" "long length" 62.Fn d2i_SSL_SESSION "SSL_SESSION **a" "const unsigned char **pp" "long length"
diff --git a/src/lib/libssl/pqueue.c b/src/lib/libssl/pqueue.c
index 602969deb0..aafd0a704e 100644
--- a/src/lib/libssl/pqueue.c
+++ b/src/lib/libssl/pqueue.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pqueue.c,v 1.5 2014/06/12 15:49:31 deraadt Exp $ */ 1/* $OpenBSD: pqueue.c,v 1.7 2025/05/04 10:53:38 tb Exp $ */
2/* 2/*
3 * DTLS implementation written by Nagendra Modadugu 3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -68,7 +68,7 @@ typedef struct _pqueue {
68} pqueue_s; 68} pqueue_s;
69 69
70pitem * 70pitem *
71pitem_new(unsigned char *prio64be, void *data) 71pitem_new(const unsigned char *prio64be, void *data)
72{ 72{
73 pitem *item = malloc(sizeof(pitem)); 73 pitem *item = malloc(sizeof(pitem));
74 74
@@ -154,7 +154,7 @@ pqueue_pop(pqueue_s *pq)
154} 154}
155 155
156pitem * 156pitem *
157pqueue_find(pqueue_s *pq, unsigned char *prio64be) 157pqueue_find(pqueue_s *pq, const unsigned char *prio64be)
158{ 158{
159 pitem *next; 159 pitem *next;
160 160
diff --git a/src/lib/libssl/pqueue.h b/src/lib/libssl/pqueue.h
index cdda4a3961..79ddf7a105 100644
--- a/src/lib/libssl/pqueue.h
+++ b/src/lib/libssl/pqueue.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pqueue.h,v 1.4 2016/11/04 18:28:58 guenther Exp $ */ 1/* $OpenBSD: pqueue.h,v 1.7 2025/05/04 10:53:38 tb Exp $ */
2 2
3/* 3/*
4 * DTLS implementation written by Nagendra Modadugu 4 * DTLS implementation written by Nagendra Modadugu
@@ -61,7 +61,7 @@
61#ifndef HEADER_PQUEUE_H 61#ifndef HEADER_PQUEUE_H
62#define HEADER_PQUEUE_H 62#define HEADER_PQUEUE_H
63 63
64__BEGIN_HIDDEN_DECLS 64__BEGIN_HIDDEN_DECLS
65 65
66typedef struct _pqueue *pqueue; 66typedef struct _pqueue *pqueue;
67 67
@@ -73,7 +73,7 @@ typedef struct _pitem {
73 73
74typedef struct _pitem *piterator; 74typedef struct _pitem *piterator;
75 75
76pitem *pitem_new(unsigned char *prio64be, void *data); 76pitem *pitem_new(const unsigned char *prio64be, void *data);
77void pitem_free(pitem *item); 77void pitem_free(pitem *item);
78 78
79pqueue pqueue_new(void); 79pqueue pqueue_new(void);
@@ -82,12 +82,12 @@ void pqueue_free(pqueue pq);
82pitem *pqueue_insert(pqueue pq, pitem *item); 82pitem *pqueue_insert(pqueue pq, pitem *item);
83pitem *pqueue_peek(pqueue pq); 83pitem *pqueue_peek(pqueue pq);
84pitem *pqueue_pop(pqueue pq); 84pitem *pqueue_pop(pqueue pq);
85pitem *pqueue_find(pqueue pq, unsigned char *prio64be); 85pitem *pqueue_find(pqueue pq, const unsigned char *prio64be);
86pitem *pqueue_iterator(pqueue pq); 86pitem *pqueue_iterator(pqueue pq);
87pitem *pqueue_next(piterator *iter); 87pitem *pqueue_next(piterator *iter);
88 88
89int pqueue_size(pqueue pq); 89int pqueue_size(pqueue pq);
90 90
91__END_HIDDEN_DECLS 91__END_HIDDEN_DECLS
92 92
93#endif /* ! HEADER_PQUEUE_H */ 93#endif /* ! HEADER_PQUEUE_H */
diff --git a/src/lib/libssl/shlib_version b/src/lib/libssl/shlib_version
index c2665004b4..97e30d617d 100644
--- a/src/lib/libssl/shlib_version
+++ b/src/lib/libssl/shlib_version
@@ -1,3 +1,3 @@
1# Don't forget to give libtls the same type of bump! 1# Don't forget to give libtls the same type of bump!
2major=59 2major=60
3minor=1 3minor=0
diff --git a/src/lib/libssl/ssl_err.c b/src/lib/libssl/ssl_err.c
index eac2d9e61f..90822490e2 100644
--- a/src/lib/libssl/ssl_err.c
+++ b/src/lib/libssl/ssl_err.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_err.c,v 1.53 2024/10/09 08:00:29 tb Exp $ */ 1/* $OpenBSD: ssl_err.c,v 1.55 2025/05/10 05:49:21 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -669,8 +669,7 @@ SSL_state_func_code(int state) {
669} 669}
670 670
671void 671void
672SSL_error_internal(const SSL *s, int r, char *f, int l) 672SSL_error_internal(const SSL *s, int r, const char *f, int l)
673{ 673{
674 ERR_PUT_error(ERR_LIB_SSL, 674 ERR_PUT_error(ERR_LIB_SSL, SSL_state_func_code(s->s3->hs.state), r, f, l);
675 (SSL_state_func_code(s->s3->hs.state)), r, f, l);
676} 675}
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index ce68981493..630724e670 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.331 2025/03/12 14:03:55 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.333 2025/06/09 10:14:38 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1298,7 +1298,7 @@ SSL_shutdown(SSL *s)
1298 return (-1); 1298 return (-1);
1299 } 1299 }
1300 1300
1301 if (s != NULL && !SSL_in_init(s)) 1301 if (!SSL_in_init(s))
1302 return (s->method->ssl_shutdown(s)); 1302 return (s->method->ssl_shutdown(s));
1303 1303
1304 return (1); 1304 return (1);
@@ -3008,8 +3008,9 @@ SSL_dup(SSL *s)
3008 3008
3009 /* Dup the client_CA list */ 3009 /* Dup the client_CA list */
3010 if (s->client_CA != NULL) { 3010 if (s->client_CA != NULL) {
3011 if ((sk = sk_X509_NAME_dup(s->client_CA)) == NULL) goto err; 3011 if ((sk = sk_X509_NAME_dup(s->client_CA)) == NULL)
3012 ret->client_CA = sk; 3012 goto err;
3013 ret->client_CA = sk;
3013 for (i = 0; i < sk_X509_NAME_num(sk); i++) { 3014 for (i = 0; i < sk_X509_NAME_num(sk); i++) {
3014 xn = sk_X509_NAME_value(sk, i); 3015 xn = sk_X509_NAME_value(sk, i);
3015 if (sk_X509_NAME_set(sk, i, 3016 if (sk_X509_NAME_set(sk, i,
diff --git a/src/lib/libssl/ssl_local.h b/src/lib/libssl/ssl_local.h
index 3a377030b0..acb87f8650 100644
--- a/src/lib/libssl/ssl_local.h
+++ b/src/lib/libssl/ssl_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_local.h,v 1.29 2025/04/18 08:07:36 tb Exp $ */ 1/* $OpenBSD: ssl_local.h,v 1.33 2025/05/10 06:04:36 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1439,9 +1439,10 @@ int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char *md_out,
1439 unsigned int mac_secret_length); 1439 unsigned int mac_secret_length);
1440int SSL_state_func_code(int _state); 1440int SSL_state_func_code(int _state);
1441 1441
1442#define SSLerror(s, r) SSL_error_internal(s, r, OPENSSL_FILE, OPENSSL_LINE) 1442void SSL_error_internal(const SSL *s, int r, const char *f, int l);
1443#define SSLerrorx(r) ERR_PUT_error(ERR_LIB_SSL,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE) 1443#define SSLerror(s, r) SSL_error_internal(s, r, OPENSSL_FILE, OPENSSL_LINE)
1444void SSL_error_internal(const SSL *s, int r, char *f, int l); 1444#define SSLerrorx(r) ERR_PUT_error(ERR_LIB_SSL,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
1445#define SYSerror(r) ERR_PUT_error(ERR_LIB_SYS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
1445 1446
1446#ifndef OPENSSL_NO_SRTP 1447#ifndef OPENSSL_NO_SRTP
1447 1448
diff --git a/src/lib/libssl/ssl_rsa.c b/src/lib/libssl/ssl_rsa.c
index 6c8a2be3d3..1490e10ba4 100644
--- a/src/lib/libssl/ssl_rsa.c
+++ b/src/lib/libssl/ssl_rsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_rsa.c,v 1.51 2023/12/30 06:25:56 tb Exp $ */ 1/* $OpenBSD: ssl_rsa.c,v 1.53 2025/08/14 15:55:54 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
diff --git a/src/lib/libssl/ssl_stat.c b/src/lib/libssl/ssl_stat.c
index b19944ca83..9966217ca3 100644
--- a/src/lib/libssl/ssl_stat.c
+++ b/src/lib/libssl/ssl_stat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_stat.c,v 1.23 2024/10/12 03:54:18 tb Exp $ */ 1/* $OpenBSD: ssl_stat.c,v 1.24 2025/05/22 08:25:26 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -438,72 +438,7 @@ LSSL_ALIAS(SSL_alert_type_string);
438const char * 438const char *
439SSL_alert_desc_string(int value) 439SSL_alert_desc_string(int value)
440{ 440{
441 switch (value & 0xff) { 441 return "!!";
442 case SSL_AD_CLOSE_NOTIFY:
443 return "CN";
444 case SSL_AD_UNEXPECTED_MESSAGE:
445 return "UM";
446 case SSL_AD_BAD_RECORD_MAC:
447 return "BM";
448 case SSL_AD_RECORD_OVERFLOW:
449 return "RO";
450 case SSL_AD_DECOMPRESSION_FAILURE:
451 return "DF";
452 case SSL_AD_HANDSHAKE_FAILURE:
453 return "HF";
454 case SSL_AD_BAD_CERTIFICATE:
455 return "BC";
456 case SSL_AD_UNSUPPORTED_CERTIFICATE:
457 return "UC";
458 case SSL_AD_CERTIFICATE_REVOKED:
459 return "CR";
460 case SSL_AD_CERTIFICATE_EXPIRED:
461 return "CE";
462 case SSL_AD_CERTIFICATE_UNKNOWN:
463 return "CU";
464 case SSL_AD_ILLEGAL_PARAMETER:
465 return "IP";
466 case SSL_AD_UNKNOWN_CA:
467 return "CA";
468 case SSL_AD_ACCESS_DENIED:
469 return "AD";
470 case SSL_AD_DECODE_ERROR:
471 return "DE";
472 case SSL_AD_DECRYPT_ERROR:
473 return "CY";
474 case SSL_AD_PROTOCOL_VERSION:
475 return "PV";
476 case SSL_AD_INSUFFICIENT_SECURITY:
477 return "IS";
478 case SSL_AD_INTERNAL_ERROR:
479 return "IE";
480 case SSL_AD_INAPPROPRIATE_FALLBACK:
481 return "IF";
482 case SSL_AD_USER_CANCELLED:
483 return "US";
484 case SSL_AD_NO_RENEGOTIATION:
485 return "NR";
486 case SSL_AD_MISSING_EXTENSION:
487 return "ME";
488 case SSL_AD_UNSUPPORTED_EXTENSION:
489 return "UE";
490 case SSL_AD_CERTIFICATE_UNOBTAINABLE:
491 return "CO";
492 case SSL_AD_UNRECOGNIZED_NAME:
493 return "UN";
494 case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
495 return "BR";
496 case SSL_AD_BAD_CERTIFICATE_HASH_VALUE:
497 return "BH";
498 case SSL_AD_UNKNOWN_PSK_IDENTITY:
499 return "UP";
500 case SSL_AD_CERTIFICATE_REQUIRED:
501 return "CQ"; /* XXX */
502 case SSL_AD_NO_APPLICATION_PROTOCOL:
503 return "AP";
504 default:
505 return "UK";
506 }
507} 442}
508LSSL_ALIAS(SSL_alert_desc_string); 443LSSL_ALIAS(SSL_alert_desc_string);
509 444
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c
index 08bf5593ec..9209597601 100644
--- a/src/lib/libssl/ssl_tlsext.c
+++ b/src/lib/libssl/ssl_tlsext.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_tlsext.c,v 1.154 2024/07/09 12:27:27 beck Exp $ */ 1/* $OpenBSD: ssl_tlsext.c,v 1.156 2025/06/07 10:23:21 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -2410,13 +2410,12 @@ tlsext_randomize_build_order(SSL *s)
2410{ 2410{
2411 const struct tls_extension *psk_ext; 2411 const struct tls_extension *psk_ext;
2412 size_t idx, new_idx; 2412 size_t idx, new_idx;
2413 size_t alpn_idx = 0, sni_idx = 0;
2414 2413
2415 free(s->tlsext_build_order); 2414 free(s->tlsext_build_order);
2416 s->tlsext_build_order_len = 0; 2415 s->tlsext_build_order_len = 0;
2417 2416
2418 if ((s->tlsext_build_order = calloc(sizeof(*s->tlsext_build_order), 2417 if ((s->tlsext_build_order = calloc(N_TLS_EXTENSIONS,
2419 N_TLS_EXTENSIONS)) == NULL) 2418 sizeof(*s->tlsext_build_order))) == NULL)
2420 return 0; 2419 return 0;
2421 s->tlsext_build_order_len = N_TLS_EXTENSIONS; 2420 s->tlsext_build_order_len = N_TLS_EXTENSIONS;
2422 2421
@@ -2433,28 +2432,6 @@ tlsext_randomize_build_order(SSL *s)
2433 s->tlsext_build_order[new_idx] = &tls_extensions[idx]; 2432 s->tlsext_build_order[new_idx] = &tls_extensions[idx];
2434 } 2433 }
2435 2434
2436 /*
2437 * XXX - Apache2 special until year 2025: ensure that SNI precedes ALPN
2438 * for clients so that virtual host setups work correctly.
2439 */
2440
2441 if (s->server)
2442 return 1;
2443
2444 for (idx = 0; idx < N_TLS_EXTENSIONS; idx++) {
2445 if (s->tlsext_build_order[idx]->type == TLSEXT_TYPE_alpn)
2446 alpn_idx = idx;
2447 if (s->tlsext_build_order[idx]->type == TLSEXT_TYPE_server_name)
2448 sni_idx = idx;
2449 }
2450 if (alpn_idx < sni_idx) {
2451 const struct tls_extension *tmp;
2452
2453 tmp = s->tlsext_build_order[alpn_idx];
2454 s->tlsext_build_order[alpn_idx] = s->tlsext_build_order[sni_idx];
2455 s->tlsext_build_order[sni_idx] = tmp;
2456 }
2457
2458 return 1; 2435 return 1;
2459} 2436}
2460 2437
@@ -2466,8 +2443,8 @@ tlsext_linearize_build_order(SSL *s)
2466 free(s->tlsext_build_order); 2443 free(s->tlsext_build_order);
2467 s->tlsext_build_order_len = 0; 2444 s->tlsext_build_order_len = 0;
2468 2445
2469 if ((s->tlsext_build_order = calloc(sizeof(*s->tlsext_build_order), 2446 if ((s->tlsext_build_order = calloc(N_TLS_EXTENSIONS,
2470 N_TLS_EXTENSIONS)) == NULL) 2447 sizeof(*s->tlsext_build_order))) == NULL)
2471 return 0; 2448 return 0;
2472 s->tlsext_build_order_len = N_TLS_EXTENSIONS; 2449 s->tlsext_build_order_len = N_TLS_EXTENSIONS;
2473 2450
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c
index b200f78098..57cd180d09 100644
--- a/src/lib/libssl/t1_lib.c
+++ b/src/lib/libssl/t1_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_lib.c,v 1.204 2025/01/18 14:17:05 tb Exp $ */ 1/* $OpenBSD: t1_lib.c,v 1.206 2025/05/31 15:17:11 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -151,6 +151,7 @@ tls1_clear(SSL *s)
151} 151}
152 152
153struct supported_group { 153struct supported_group {
154 uint16_t group_id;
154 int nid; 155 int nid;
155 int bits; 156 int bits;
156}; 157};
@@ -160,119 +161,148 @@ struct supported_group {
160 * https://www.iana.org/assignments/tls-parameters/#tls-parameters-8 161 * https://www.iana.org/assignments/tls-parameters/#tls-parameters-8
161 */ 162 */
162static const struct supported_group nid_list[] = { 163static const struct supported_group nid_list[] = {
163 [1] = { 164 {
165 .group_id = 1,
164 .nid = NID_sect163k1, 166 .nid = NID_sect163k1,
165 .bits = 80, 167 .bits = 80,
166 }, 168 },
167 [2] = { 169 {
170 .group_id = 2,
168 .nid = NID_sect163r1, 171 .nid = NID_sect163r1,
169 .bits = 80, 172 .bits = 80,
170 }, 173 },
171 [3] = { 174 {
175 .group_id = 3,
172 .nid = NID_sect163r2, 176 .nid = NID_sect163r2,
173 .bits = 80, 177 .bits = 80,
174 }, 178 },
175 [4] = { 179 {
180 .group_id = 4,
176 .nid = NID_sect193r1, 181 .nid = NID_sect193r1,
177 .bits = 80, 182 .bits = 80,
178 }, 183 },
179 [5] = { 184 {
185 .group_id = 5,
180 .nid = NID_sect193r2, 186 .nid = NID_sect193r2,
181 .bits = 80, 187 .bits = 80,
182 }, 188 },
183 [6] = { 189 {
190 .group_id = 6,
184 .nid = NID_sect233k1, 191 .nid = NID_sect233k1,
185 .bits = 112, 192 .bits = 112,
186 }, 193 },
187 [7] = { 194 {
195 .group_id = 7,
188 .nid = NID_sect233r1, 196 .nid = NID_sect233r1,
189 .bits = 112, 197 .bits = 112,
190 }, 198 },
191 [8] = { 199 {
200 .group_id = 8,
192 .nid = NID_sect239k1, 201 .nid = NID_sect239k1,
193 .bits = 112, 202 .bits = 112,
194 }, 203 },
195 [9] = { 204 {
205 .group_id = 9,
196 .nid = NID_sect283k1, 206 .nid = NID_sect283k1,
197 .bits = 128, 207 .bits = 128,
198 }, 208 },
199 [10] = { 209 {
210 .group_id = 10,
200 .nid = NID_sect283r1, 211 .nid = NID_sect283r1,
201 .bits = 128, 212 .bits = 128,
202 }, 213 },
203 [11] = { 214 {
215 .group_id = 11,
204 .nid = NID_sect409k1, 216 .nid = NID_sect409k1,
205 .bits = 192, 217 .bits = 192,
206 }, 218 },
207 [12] = { 219 {
220 .group_id = 12,
208 .nid = NID_sect409r1, 221 .nid = NID_sect409r1,
209 .bits = 192, 222 .bits = 192,
210 }, 223 },
211 [13] = { 224 {
225 .group_id = 13,
212 .nid = NID_sect571k1, 226 .nid = NID_sect571k1,
213 .bits = 256, 227 .bits = 256,
214 }, 228 },
215 [14] = { 229 {
230 .group_id = 14,
216 .nid = NID_sect571r1, 231 .nid = NID_sect571r1,
217 .bits = 256, 232 .bits = 256,
218 }, 233 },
219 [15] = { 234 {
235 .group_id = 15,
220 .nid = NID_secp160k1, 236 .nid = NID_secp160k1,
221 .bits = 80, 237 .bits = 80,
222 }, 238 },
223 [16] = { 239 {
240 .group_id = 16,
224 .nid = NID_secp160r1, 241 .nid = NID_secp160r1,
225 .bits = 80, 242 .bits = 80,
226 }, 243 },
227 [17] = { 244 {
245 .group_id = 17,
228 .nid = NID_secp160r2, 246 .nid = NID_secp160r2,
229 .bits = 80, 247 .bits = 80,
230 }, 248 },
231 [18] = { 249 {
250 .group_id = 18,
232 .nid = NID_secp192k1, 251 .nid = NID_secp192k1,
233 .bits = 80, 252 .bits = 80,
234 }, 253 },
235 [19] = { 254 {
255 .group_id = 19,
236 .nid = NID_X9_62_prime192v1, /* aka secp192r1 */ 256 .nid = NID_X9_62_prime192v1, /* aka secp192r1 */
237 .bits = 80, 257 .bits = 80,
238 }, 258 },
239 [20] = { 259 {
260 .group_id = 20,
240 .nid = NID_secp224k1, 261 .nid = NID_secp224k1,
241 .bits = 112, 262 .bits = 112,
242 }, 263 },
243 [21] = { 264 {
265 .group_id = 21,
244 .nid = NID_secp224r1, 266 .nid = NID_secp224r1,
245 .bits = 112, 267 .bits = 112,
246 }, 268 },
247 [22] = { 269 {
270 .group_id = 22,
248 .nid = NID_secp256k1, 271 .nid = NID_secp256k1,
249 .bits = 128, 272 .bits = 128,
250 }, 273 },
251 [23] = { 274 {
275 .group_id = 23,
252 .nid = NID_X9_62_prime256v1, /* aka secp256r1 */ 276 .nid = NID_X9_62_prime256v1, /* aka secp256r1 */
253 .bits = 128, 277 .bits = 128,
254 }, 278 },
255 [24] = { 279 {
280 .group_id = 24,
256 .nid = NID_secp384r1, 281 .nid = NID_secp384r1,
257 .bits = 192, 282 .bits = 192,
258 }, 283 },
259 [25] = { 284 {
285 .group_id = 25,
260 .nid = NID_secp521r1, 286 .nid = NID_secp521r1,
261 .bits = 256, 287 .bits = 256,
262 }, 288 },
263 [26] = { 289 {
290 .group_id = 26,
264 .nid = NID_brainpoolP256r1, 291 .nid = NID_brainpoolP256r1,
265 .bits = 128, 292 .bits = 128,
266 }, 293 },
267 [27] = { 294 {
295 .group_id = 27,
268 .nid = NID_brainpoolP384r1, 296 .nid = NID_brainpoolP384r1,
269 .bits = 192, 297 .bits = 192,
270 }, 298 },
271 [28] = { 299 {
300 .group_id = 28,
272 .nid = NID_brainpoolP512r1, 301 .nid = NID_brainpoolP512r1,
273 .bits = 256, 302 .bits = 256,
274 }, 303 },
275 [29] = { 304 {
305 .group_id = 29,
276 .nid = NID_X25519, 306 .nid = NID_X25519,
277 .bits = 128, 307 .bits = 128,
278 }, 308 },
@@ -339,18 +369,41 @@ static const uint16_t ecgroups_server_default[] = {
339 24, /* secp384r1 (24) */ 369 24, /* secp384r1 (24) */
340}; 370};
341 371
372static const struct supported_group *
373tls1_supported_group_by_id(uint16_t group_id)
374{
375 int i;
376
377 for (i = 0; i < NID_LIST_LEN; i++) {
378 if (group_id == nid_list[i].group_id)
379 return &nid_list[i];
380 }
381
382 return NULL;
383}
384
385static const struct supported_group *
386tls1_supported_group_by_nid(int nid)
387{
388 int i;
389
390 for (i = 0; i < NID_LIST_LEN; i++) {
391 if (nid == nid_list[i].nid)
392 return &nid_list[i];
393 }
394
395 return NULL;
396}
397
342int 398int
343tls1_ec_group_id2nid(uint16_t group_id, int *out_nid) 399tls1_ec_group_id2nid(uint16_t group_id, int *out_nid)
344{ 400{
345 int nid; 401 const struct supported_group *sg;
346
347 if (group_id >= NID_LIST_LEN)
348 return 0;
349 402
350 if ((nid = nid_list[group_id].nid) == 0) 403 if ((sg = tls1_supported_group_by_id(group_id)) == NULL)
351 return 0; 404 return 0;
352 405
353 *out_nid = nid; 406 *out_nid = sg->nid;
354 407
355 return 1; 408 return 1;
356} 409}
@@ -358,15 +411,12 @@ tls1_ec_group_id2nid(uint16_t group_id, int *out_nid)
358int 411int
359tls1_ec_group_id2bits(uint16_t group_id, int *out_bits) 412tls1_ec_group_id2bits(uint16_t group_id, int *out_bits)
360{ 413{
361 int bits; 414 const struct supported_group *sg;
362
363 if (group_id >= NID_LIST_LEN)
364 return 0;
365 415
366 if ((bits = nid_list[group_id].bits) == 0) 416 if ((sg = tls1_supported_group_by_id(group_id)) == NULL)
367 return 0; 417 return 0;
368 418
369 *out_bits = bits; 419 *out_bits = sg->bits;
370 420
371 return 1; 421 return 1;
372} 422}
@@ -374,19 +424,14 @@ tls1_ec_group_id2bits(uint16_t group_id, int *out_bits)
374int 424int
375tls1_ec_nid2group_id(int nid, uint16_t *out_group_id) 425tls1_ec_nid2group_id(int nid, uint16_t *out_group_id)
376{ 426{
377 uint16_t group_id; 427 const struct supported_group *sg;
378 428
379 if (nid == 0) 429 if ((sg = tls1_supported_group_by_nid(nid)) == NULL)
380 return 0; 430 return 0;
381 431
382 for (group_id = 0; group_id < NID_LIST_LEN; group_id++) { 432 *out_group_id = sg->group_id;
383 if (nid_list[group_id].nid == nid) {
384 *out_group_id = group_id;
385 return 1;
386 }
387 }
388 433
389 return 0; 434 return 1;
390} 435}
391 436
392/* 437/*
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c
index 331a3ad1a7..c3470b2931 100644
--- a/src/lib/libssl/tls13_lib.c
+++ b/src/lib/libssl/tls13_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_lib.c,v 1.77 2024/01/27 14:23:51 jsing Exp $ */ 1/* $OpenBSD: tls13_lib.c,v 1.78 2025/06/07 10:25:12 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2019 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2019 Bob Beck <beck@openbsd.org>
@@ -538,7 +538,7 @@ tls13_ctx_new(int mode, SSL *ssl)
538{ 538{
539 struct tls13_ctx *ctx = NULL; 539 struct tls13_ctx *ctx = NULL;
540 540
541 if ((ctx = calloc(sizeof(struct tls13_ctx), 1)) == NULL) 541 if ((ctx = calloc(1, sizeof(*ctx))) == NULL)
542 goto err; 542 goto err;
543 543
544 ctx->hs = &ssl->s3->hs; 544 ctx->hs = &ssl->s3->hs;
diff --git a/src/lib/libtls/man/tls_accept_socket.3 b/src/lib/libtls/man/tls_accept_socket.3
index 931b9346ec..8922708e0f 100644
--- a/src/lib/libtls/man/tls_accept_socket.3
+++ b/src/lib/libtls/man/tls_accept_socket.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_accept_socket.3,v 1.4 2018/05/26 12:35:26 schwarze Exp $ 1.\" $OpenBSD: tls_accept_socket.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: May 26 2018 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_ACCEPT_SOCKET 3 20.Dt TLS_ACCEPT_SOCKET 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_accept_cbs 25.Nm tls_accept_cbs
26.Nd accept an incoming client connection in a TLS server 26.Nd accept an incoming client connection in a TLS server
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft int 30.Ft int
30.Fo tls_accept_socket 31.Fo tls_accept_socket
diff --git a/src/lib/libtls/man/tls_client.3 b/src/lib/libtls/man/tls_client.3
index 98f58d4c20..235c779519 100644
--- a/src/lib/libtls/man/tls_client.3
+++ b/src/lib/libtls/man/tls_client.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_client.3,v 1.4 2017/08/12 03:41:48 jsing Exp $ 1.\" $OpenBSD: tls_client.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 12 2017 $ 17.Dd $Mdocdate: July 7 2025 $
18.Dt TLS_CLIENT 3 18.Dt TLS_CLIENT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_free 25.Nm tls_free
26.Nd configure a TLS connection 26.Nd configure a TLS connection
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft struct tls * 30.Ft struct tls *
30.Fn tls_client void 31.Fn tls_client void
diff --git a/src/lib/libtls/man/tls_config_ocsp_require_stapling.3 b/src/lib/libtls/man/tls_config_ocsp_require_stapling.3
index a0694d304f..d776b61ad6 100644
--- a/src/lib/libtls/man/tls_config_ocsp_require_stapling.3
+++ b/src/lib/libtls/man/tls_config_ocsp_require_stapling.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_ocsp_require_stapling.3,v 1.5 2017/01/31 20:53:50 jmc Exp $ 1.\" $OpenBSD: tls_config_ocsp_require_stapling.3,v 1.6 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org> 3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 31 2017 $ 17.Dd $Mdocdate: July 7 2025 $
18.Dt TLS_CONFIG_OCSP_REQUIRE_STAPLING 3 18.Dt TLS_CONFIG_OCSP_REQUIRE_STAPLING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm tls_config_ocsp_require_stapling 21.Nm tls_config_ocsp_require_stapling
22.Nd OCSP configuration for libtls 22.Nd OCSP configuration for libtls
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libtls libssl libcrypto
24.In tls.h 25.In tls.h
25.Ft void 26.Ft void
26.Fn tls_config_ocsp_require_stapling "struct tls_config *config" 27.Fn tls_config_ocsp_require_stapling "struct tls_config *config"
diff --git a/src/lib/libtls/man/tls_config_set_protocols.3 b/src/lib/libtls/man/tls_config_set_protocols.3
index 32b8cce757..403bc10b82 100644
--- a/src/lib/libtls/man/tls_config_set_protocols.3
+++ b/src/lib/libtls/man/tls_config_set_protocols.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_set_protocols.3,v 1.12 2023/07/02 06:37:27 beck Exp $ 1.\" $OpenBSD: tls_config_set_protocols.3,v 1.13 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015, 2016 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2015, 2016 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: July 2 2023 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_CONFIG_SET_PROTOCOLS 3 20.Dt TLS_CONFIG_SET_PROTOCOLS 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -26,10 +26,12 @@
26.Nm tls_config_set_ciphers , 26.Nm tls_config_set_ciphers ,
27.Nm tls_config_set_dheparams , 27.Nm tls_config_set_dheparams ,
28.Nm tls_config_set_ecdhecurves , 28.Nm tls_config_set_ecdhecurves ,
29.\" .Nm tls_config_set_ecdhecurve is intentionally undocumented.
29.Nm tls_config_prefer_ciphers_client , 30.Nm tls_config_prefer_ciphers_client ,
30.Nm tls_config_prefer_ciphers_server 31.Nm tls_config_prefer_ciphers_server
31.Nd TLS protocol and cipher selection 32.Nd TLS protocol and cipher selection
32.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Lb libtls libssl libcrypto
33.In tls.h 35.In tls.h
34.Ft int 36.Ft int
35.Fo tls_config_set_protocols 37.Fo tls_config_set_protocols
diff --git a/src/lib/libtls/man/tls_config_set_session_id.3 b/src/lib/libtls/man/tls_config_set_session_id.3
index d969e01e33..a869b3f24c 100644
--- a/src/lib/libtls/man/tls_config_set_session_id.3
+++ b/src/lib/libtls/man/tls_config_set_session_id.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_set_session_id.3,v 1.5 2018/02/10 06:07:43 jsing Exp $ 1.\" $OpenBSD: tls_config_set_session_id.3,v 1.6 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Claudio Jeker <claudio@openbsd.org> 3.\" Copyright (c) 2017 Claudio Jeker <claudio@openbsd.org>
4.\" Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: February 10 2018 $ 18.Dd $Mdocdate: July 7 2025 $
19.Dt TLS_CONFIG_SET_SESSION_ID 3 19.Dt TLS_CONFIG_SET_SESSION_ID 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_config_add_ticket_key 25.Nm tls_config_add_ticket_key
26.Nd configure resuming of TLS handshakes 26.Nd configure resuming of TLS handshakes
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft int 30.Ft int
30.Fo tls_config_set_session_fd 31.Fo tls_config_set_session_fd
diff --git a/src/lib/libtls/man/tls_config_verify.3 b/src/lib/libtls/man/tls_config_verify.3
index 4a43c834d7..d5b29e858e 100644
--- a/src/lib/libtls/man/tls_config_verify.3
+++ b/src/lib/libtls/man/tls_config_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_verify.3,v 1.4 2017/03/02 11:05:50 jmc Exp $ 1.\" $OpenBSD: tls_config_verify.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 2 2017 $ 18.Dd $Mdocdate: July 7 2025 $
19.Dt TLS_CONFIG_VERIFY 3 19.Dt TLS_CONFIG_VERIFY 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_config_insecure_noverifytime 25.Nm tls_config_insecure_noverifytime
26.Nd insecure TLS configuration 26.Nd insecure TLS configuration
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft void 30.Ft void
30.Fn tls_config_verify "struct tls_config *config" 31.Fn tls_config_verify "struct tls_config *config"
diff --git a/src/lib/libtls/man/tls_conn_version.3 b/src/lib/libtls/man/tls_conn_version.3
index 8fb30624d7..3a386cf11f 100644
--- a/src/lib/libtls/man/tls_conn_version.3
+++ b/src/lib/libtls/man/tls_conn_version.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_conn_version.3,v 1.11 2024/12/10 08:42:12 tb Exp $ 1.\" $OpenBSD: tls_conn_version.3,v 1.12 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3.\" Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4.\" Copyright (c) 2016, 2018 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2016, 2018 Joel Sing <jsing@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: December 10 2024 $ 18.Dd $Mdocdate: July 7 2025 $
19.Dt TLS_CONN_VERSION 3 19.Dt TLS_CONN_VERSION 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -36,6 +36,7 @@
36.Nm tls_peer_cert_notafter 36.Nm tls_peer_cert_notafter
37.Nd inspect an established TLS connection 37.Nd inspect an established TLS connection
38.Sh SYNOPSIS 38.Sh SYNOPSIS
39.Lb libtls libssl libcrypto
39.In tls.h 40.In tls.h
40.Ft const char * 41.Ft const char *
41.Fn tls_conn_version "struct tls *ctx" 42.Fn tls_conn_version "struct tls *ctx"
diff --git a/src/lib/libtls/man/tls_connect.3 b/src/lib/libtls/man/tls_connect.3
index 4c4f01c256..95a18864b2 100644
--- a/src/lib/libtls/man/tls_connect.3
+++ b/src/lib/libtls/man/tls_connect.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_connect.3,v 1.4 2018/07/09 19:51:18 tb Exp $ 1.\" $OpenBSD: tls_connect.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2014, 2015 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2014, 2015 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: July 9 2018 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_CONNECT 3 20.Dt TLS_CONNECT 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -27,6 +27,7 @@
27.Nm tls_connect_cbs 27.Nm tls_connect_cbs
28.Nd instruct a TLS client to establish a connection 28.Nd instruct a TLS client to establish a connection
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libtls libssl libcrypto
30.In tls.h 31.In tls.h
31.Ft int 32.Ft int
32.Fo tls_connect 33.Fo tls_connect
diff --git a/src/lib/libtls/man/tls_init.3 b/src/lib/libtls/man/tls_init.3
index 557998107c..69879c04c7 100644
--- a/src/lib/libtls/man/tls_init.3
+++ b/src/lib/libtls/man/tls_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_init.3,v 1.13 2018/07/09 19:47:20 tb Exp $ 1.\" $OpenBSD: tls_init.3,v 1.14 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2016 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2016 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: July 9 2018 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_INIT 3 20.Dt TLS_INIT 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -26,6 +26,7 @@
26.Nm tls_config_error 26.Nm tls_config_error
27.Nd initialize TLS client and server API 27.Nd initialize TLS client and server API
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libtls libssl libcrypto
29.In tls.h 30.In tls.h
30.Ft int 31.Ft int
31.Fn tls_init void 32.Fn tls_init void
diff --git a/src/lib/libtls/man/tls_load_file.3 b/src/lib/libtls/man/tls_load_file.3
index cf33b575ef..33f486d530 100644
--- a/src/lib/libtls/man/tls_load_file.3
+++ b/src/lib/libtls/man/tls_load_file.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_load_file.3,v 1.14 2022/01/01 02:18:28 jsg Exp $ 1.\" $OpenBSD: tls_load_file.3,v 1.15 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> 4.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -17,7 +17,7 @@
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\" 19.\"
20.Dd $Mdocdate: January 1 2022 $ 20.Dd $Mdocdate: July 7 2025 $
21.Dt TLS_LOAD_FILE 3 21.Dt TLS_LOAD_FILE 3
22.Os 22.Os
23.Sh NAME 23.Sh NAME
@@ -49,6 +49,7 @@
49.Nm tls_default_ca_cert_file 49.Nm tls_default_ca_cert_file
50.Nd TLS certificate and key configuration 50.Nd TLS certificate and key configuration
51.Sh SYNOPSIS 51.Sh SYNOPSIS
52.Lb libtls libssl libcrypto
52.In tls.h 53.In tls.h
53.Ft uint8_t * 54.Ft uint8_t *
54.Fo tls_load_file 55.Fo tls_load_file
diff --git a/src/lib/libtls/man/tls_ocsp_process_response.3 b/src/lib/libtls/man/tls_ocsp_process_response.3
index 6e3aa4aecc..e7b57a6827 100644
--- a/src/lib/libtls/man/tls_ocsp_process_response.3
+++ b/src/lib/libtls/man/tls_ocsp_process_response.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_ocsp_process_response.3,v 1.6 2018/07/24 02:01:34 tb Exp $ 1.\" $OpenBSD: tls_ocsp_process_response.3,v 1.7 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org> 3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 24 2018 $ 17.Dd $Mdocdate: July 7 2025 $
18.Dt TLS_OCSP_PROCESS_RESPONSE 3 18.Dt TLS_OCSP_PROCESS_RESPONSE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -29,6 +29,7 @@
29.Nm tls_peer_ocsp_next_update 29.Nm tls_peer_ocsp_next_update
30.Nd inspect an OCSP response 30.Nd inspect an OCSP response
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libtls libssl libcrypto
32.In tls.h 33.In tls.h
33.Ft int 34.Ft int
34.Fo tls_ocsp_process_response 35.Fo tls_ocsp_process_response
diff --git a/src/lib/libtls/man/tls_read.3 b/src/lib/libtls/man/tls_read.3
index f9d949eef5..f72e63cf63 100644
--- a/src/lib/libtls/man/tls_read.3
+++ b/src/lib/libtls/man/tls_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_read.3,v 1.8 2023/09/18 17:25:15 schwarze Exp $ 1.\" $OpenBSD: tls_read.3,v 1.9 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014, 2015 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014, 2015 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Doug Hogan <doug@openbsd.org> 4.\" Copyright (c) 2015 Doug Hogan <doug@openbsd.org>
@@ -18,7 +18,7 @@
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\" 20.\"
21.Dd $Mdocdate: September 18 2023 $ 21.Dd $Mdocdate: July 7 2025 $
22.Dt TLS_READ 3 22.Dt TLS_READ 3
23.Os 23.Os
24.Sh NAME 24.Sh NAME
@@ -29,6 +29,7 @@
29.Nm tls_close 29.Nm tls_close
30.Nd use a TLS connection 30.Nd use a TLS connection
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libtls libssl libcrypto
32.In tls.h 33.In tls.h
33.Ft ssize_t 34.Ft ssize_t
34.Fo tls_read 35.Fo tls_read
diff --git a/src/lib/libtls/shlib_version b/src/lib/libtls/shlib_version
index 3040494c17..ed8f7473b5 100644
--- a/src/lib/libtls/shlib_version
+++ b/src/lib/libtls/shlib_version
@@ -1,2 +1,2 @@
1major=32 1major=33
2minor=1 2minor=0
diff --git a/src/lib/libtls/tls_server.c b/src/lib/libtls/tls_server.c
index a94b4221ed..42a697327a 100644
--- a/src/lib/libtls/tls_server.c
+++ b/src/lib/libtls/tls_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_server.c,v 1.51 2024/03/26 08:54:48 joshua Exp $ */ 1/* $OpenBSD: tls_server.c,v 1.52 2025/06/04 10:25:30 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -75,7 +75,7 @@ tls_server_alpn_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen,
75 OPENSSL_NPN_NEGOTIATED) 75 OPENSSL_NPN_NEGOTIATED)
76 return (SSL_TLSEXT_ERR_OK); 76 return (SSL_TLSEXT_ERR_OK);
77 77
78 return (SSL_TLSEXT_ERR_NOACK); 78 return (SSL_TLSEXT_ERR_ALERT_FATAL);
79} 79}
80 80
81static int 81static int
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile
index 81d8779db0..7a8db225ef 100644
--- a/src/regress/lib/libc/Makefile
+++ b/src/regress/lib/libc/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.60 2025/04/14 17:33:48 tb Exp $ 1# $OpenBSD: Makefile,v 1.62 2025/08/04 06:10:40 tb Exp $
2 2
3SUBDIR+= _setjmp 3SUBDIR+= _setjmp
4SUBDIR+= alloca arc4random-fork atexit 4SUBDIR+= alloca arc4random-fork atexit
@@ -11,7 +11,7 @@ SUBDIR+= ffs fmemopen fnmatch fpclassify fread
11SUBDIR+= gcvt getaddrinfo getcap getopt getopt_long glob 11SUBDIR+= gcvt getaddrinfo getcap getopt getopt_long glob
12SUBDIR+= hash 12SUBDIR+= hash
13SUBDIR+= hsearch 13SUBDIR+= hsearch
14SUBDIR+= ieeefp ifnameindex 14SUBDIR+= ieeefp ifnameindex illumos
15SUBDIR+= ldexp locale longjmp 15SUBDIR+= ldexp locale longjmp
16SUBDIR+= malloc mkstemp modf 16SUBDIR+= malloc mkstemp modf
17SUBDIR+= netdb 17SUBDIR+= netdb
@@ -19,9 +19,9 @@ SUBDIR+= open_memstream orientation
19SUBDIR+= popen printf 19SUBDIR+= popen printf
20SUBDIR+= qsort 20SUBDIR+= qsort
21SUBDIR+= regex 21SUBDIR+= regex
22SUBDIR+= setjmp setjmp-signal sigsetjmp sigthr sleep sprintf stdio_threading 22SUBDIR+= setjmp setjmp-signal sigsetjmp sigthr sleep sprintf stdio
23SUBDIR+= stpncpy strchr strerror strlcat strlcpy strnlen strtod strtol strtonum 23SUBDIR+= stdio_threading stpncpy strchr strerror strlcat strlcpy strnlen
24SUBDIR+= sys 24SUBDIR+= strtod strtol strtonum sys
25SUBDIR+= telldir time timingsafe 25SUBDIR+= telldir time timingsafe
26SUBDIR+= uuid 26SUBDIR+= uuid
27SUBDIR+= vis 27SUBDIR+= vis
diff --git a/src/regress/lib/libc/explicit_bzero/explicit_bzero.c b/src/regress/lib/libc/explicit_bzero/explicit_bzero.c
index 496bafb208..30c86290e8 100644
--- a/src/regress/lib/libc/explicit_bzero/explicit_bzero.c
+++ b/src/regress/lib/libc/explicit_bzero/explicit_bzero.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: explicit_bzero.c,v 1.9 2022/02/10 08:39:32 tb Exp $ */ 1/* $OpenBSD: explicit_bzero.c,v 1.10 2025/05/31 15:31:40 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Google Inc. 3 * Copyright (c) 2014 Google Inc.
4 * 4 *
@@ -28,9 +28,11 @@
28 28
29#if defined(__has_feature) 29#if defined(__has_feature)
30#if __has_feature(address_sanitizer) 30#if __has_feature(address_sanitizer)
31#ifndef __SANITIZE_ADDRESS__
31#define __SANITIZE_ADDRESS__ 32#define __SANITIZE_ADDRESS__
32#endif 33#endif
33#endif 34#endif
35#endif
34#ifdef __SANITIZE_ADDRESS__ 36#ifdef __SANITIZE_ADDRESS__
35#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) 37#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
36#else 38#else
diff --git a/src/regress/lib/libc/hash/hash_test.c b/src/regress/lib/libc/hash/hash_test.c
index f9dc641186..c04a0458fe 100644
--- a/src/regress/lib/libc/hash/hash_test.c
+++ b/src/regress/lib/libc/hash/hash_test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hash_test.c,v 1.2 2025/04/14 18:33:56 tb Exp $ */ 1/* $OpenBSD: hash_test.c,v 1.3 2025/08/02 06:05:13 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
@@ -757,7 +757,7 @@ struct hash_ctx {
757 void *ctx; 757 void *ctx;
758 void (*init)(void *); 758 void (*init)(void *);
759 void (*update)(void *, const uint8_t *, size_t); 759 void (*update)(void *, const uint8_t *, size_t);
760 void (*final)(void *, void *final); 760 void (*final)(void *, void *);
761}; 761};
762 762
763static const struct hash_tests { 763static const struct hash_tests {
@@ -814,7 +814,7 @@ hash_test_case(struct hash_ctx *ctx, const struct hash_test_case *tc,
814 size_t in_len = tc->in != NULL ? strlen(tc->in) : 0; 814 size_t in_len = tc->in != NULL ? strlen(tc->in) : 0;
815 815
816 ctx->init(ctx->ctx); 816 ctx->init(ctx->ctx);
817 ctx->update(ctx->ctx, (uint8_t *)tc->in, in_len); 817 ctx->update(ctx->ctx, (const uint8_t *)tc->in, in_len);
818 ctx->final(ctx->digest, ctx->ctx); 818 ctx->final(ctx->digest, ctx->ctx);
819 819
820 if (memcmp(tc->out, ctx->digest, ctx->digest_len) != 0) { 820 if (memcmp(tc->out, ctx->digest, ctx->digest_len) != 0) {
diff --git a/src/regress/lib/libc/illumos/Makefile b/src/regress/lib/libc/illumos/Makefile
new file mode 100644
index 0000000000..cf2d22eb44
--- /dev/null
+++ b/src/regress/lib/libc/illumos/Makefile
@@ -0,0 +1,7 @@
1# $OpenBSD: Makefile,v 1.1.1.1 2025/08/02 06:16:34 tb Exp $
2
3SUBDIR += oclo
4
5install:
6
7.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/illumos/Makefile.inc b/src/regress/lib/libc/illumos/Makefile.inc
new file mode 100644
index 0000000000..4296b6e690
--- /dev/null
+++ b/src/regress/lib/libc/illumos/Makefile.inc
@@ -0,0 +1,9 @@
1# $OpenBSD: Makefile.inc,v 1.1.1.1 2025/08/02 06:16:34 tb Exp $
2
3ILLUMOS_OS_TESTDIR = /usr/local/share/illumos-os-tests
4
5.if !exists(${ILLUMOS_OS_TESTDIR})
6regress:
7 @echo package illumos-os-tests is required for this regress
8 @echo SKIPPED
9.endif
diff --git a/src/regress/lib/libc/illumos/oclo/Makefile b/src/regress/lib/libc/illumos/oclo/Makefile
new file mode 100644
index 0000000000..284e49dc73
--- /dev/null
+++ b/src/regress/lib/libc/illumos/oclo/Makefile
@@ -0,0 +1,18 @@
1# $OpenBSD: Makefile,v 1.2 2025/08/09 18:17:42 anton Exp $
2
3.if exists(/usr/local/share/illumos-os-tests)
4
5PROGS = oclo
6PROGS += oclo_errors
7PROGS += ocloexec_verify
8
9LDADD_ocloexec_verify = -lkvm
10
11WARNINGS = yes
12
13regress: ${PROGS}
14
15.PATH: /usr/local/share/illumos-os-tests/tests/oclo
16.endif
17
18.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c b/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c
index 486c247f0d..57d799f49d 100644
--- a/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c
+++ b/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc_errs.c,v 1.5 2024/04/14 17:47:41 otto Exp $ */ 1/* $OpenBSD: malloc_errs.c,v 1.6 2025/05/24 06:40:29 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2023 Otto Moerbeek <otto@drijf.net>
4 * 4 *
@@ -286,11 +286,10 @@ int main(int argc, char *argv[])
286 int i, status; 286 int i, status;
287 pid_t pid; 287 pid_t pid;
288 char num[10]; 288 char num[10];
289 char options[10]; 289 char options[40];
290 extern char* malloc_options; 290 char const *env[2];
291 291
292 if (argc == 3) { 292 if (argc == 2) {
293 malloc_options = argv[2];
294 /* prevent coredumps */ 293 /* prevent coredumps */
295 setrlimit(RLIMIT_CORE, &lim); 294 setrlimit(RLIMIT_CORE, &lim);
296 i = atoi(argv[1]); 295 i = atoi(argv[1]);
@@ -303,9 +302,11 @@ int main(int argc, char *argv[])
303 pid = fork(); 302 pid = fork();
304 switch (pid) { 303 switch (pid) {
305 case 0: 304 case 0:
306 snprintf(options, sizeof(options), "us%s", tests[i].flags); 305 snprintf(options, sizeof(options), "MALLOC_OPTIONS=us%s", tests[i].flags);
307 snprintf(num, sizeof(num), "%d", i); 306 snprintf(num, sizeof(num), "%d", i);
308 execl(argv[0], argv[0], num, options, NULL); 307 env[0] = options;
308 env[1] = NULL;
309 execle(argv[0], argv[0], num, NULL, env);
309 err(1, "exec"); 310 err(1, "exec");
310 break; 311 break;
311 case -1: 312 case -1:
diff --git a/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c b/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c
index 799d2b9117..7e53c32dbc 100644
--- a/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c
+++ b/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc_ulimit1.c,v 1.5 2019/06/12 11:31:36 bluhm Exp $ */ 1/* $OpenBSD: malloc_ulimit1.c,v 1.6 2025/05/24 06:47:27 otto Exp $ */
2 2
3/* Public Domain, 2006, Otto Moerbeek <otto@drijf.net> */ 3/* Public Domain, 2006, Otto Moerbeek <otto@drijf.net> */
4 4
@@ -23,7 +23,7 @@
23#define FACTOR 1024 23#define FACTOR 1024
24 24
25/* This test takes forever with junking turned on. */ 25/* This test takes forever with junking turned on. */
26char *malloc_options = "jj"; 26const char * const malloc_options = "jj";
27 27
28int 28int
29main() 29main()
diff --git a/src/regress/lib/libc/stdio/Makefile b/src/regress/lib/libc/stdio/Makefile
new file mode 100644
index 0000000000..f1e980f688
--- /dev/null
+++ b/src/regress/lib/libc/stdio/Makefile
@@ -0,0 +1,29 @@
1# $OpenBSD: Makefile,v 1.4 2025/06/03 14:35:27 yasuoka Exp $
2
3PROGS= test_fflush
4CLEANFILES= test_fflush.tmp
5
6PROGS+= test_ungetwc
7CLEANFILES+= test_ungetwc.tmp
8
9PROGS+= test___freading
10CLEANFILES+= test___freading.tmp
11
12PROGS+= test___fwriting
13CLEANFILES+= test___fwriting.tmp
14
15PROGS+= test___fpending
16CLEANFILES+= test___fpending.tmp
17
18PROGS+= test___freadahead
19CLEANFILES+= test___freadahead.tmp
20
21PROGS+= test___freadptr
22CLEANFILES+= test___freadptr.tmp
23
24PROGS+= test___fseterr
25CLEANFILES+= test___fseterr.tmp
26
27WARNINGS= yes
28
29.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/stdio/test___fpending.c b/src/regress/lib/libc/stdio/test___fpending.c
new file mode 100644
index 0000000000..96ace2e481
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test___fpending.c
@@ -0,0 +1,58 @@
1/* $OpenBSD: test___fpending.c,v 1.1 2025/05/25 00:20:54 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <assert.h>
20#include <stdio.h>
21#include <stdio_ext.h>
22#include <stdlib.h>
23
24/* we use assert() */
25#undef NDEBUG
26
27#define TMPFILENAME "test___fpending.tmp"
28
29void test___fpending0(void);
30
31void
32test___fpending0(void)
33{
34 FILE *fp;
35 int r;
36 size_t s;
37
38 fp = fopen(TMPFILENAME, "w");
39 assert(fp != NULL);
40 r = fputs("Hello world", fp);
41 assert(r >= 0);
42 s = __fpending(fp);
43 assert(s > 0); /* assume buffered */
44 r = fflush(fp);
45 assert(r == 0);
46 s = __fpending(fp);
47 assert(s == 0); /* buffer must be 0 */
48 r = fclose(fp);
49 assert(r == 0);
50}
51
52int
53main(int argc, char *argv[])
54{
55 test___fpending0();
56
57 exit(0);
58}
diff --git a/src/regress/lib/libc/stdio/test___freadahead.c b/src/regress/lib/libc/stdio/test___freadahead.c
new file mode 100644
index 0000000000..66d5e3492a
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test___freadahead.c
@@ -0,0 +1,71 @@
1/* $OpenBSD: test___freadahead.c,v 1.2 2025/06/03 14:35:27 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <assert.h>
20#include <errno.h>
21#include <stdio.h>
22#include <stdio_ext.h>
23#include <stdlib.h>
24
25/* we use assert() */
26#undef NDEBUG
27
28#define TMPFILENAME "test___freadahead.tmp"
29
30void test___freadahead0(void);
31
32void
33test___freadahead0(void)
34{
35 FILE *fp;
36 int r;
37 size_t s;
38
39 fp = fopen(TMPFILENAME, "w");
40 assert(fp != NULL);
41 r = fputs("Hello world", fp);
42 assert(r >= 0);
43 r = fclose(fp);
44
45 fp = fopen(TMPFILENAME, "r");
46 s = __freadahead(fp);
47 assert(s == 0);
48 assert(fgetc(fp) == 'H');
49 s = __freadahead(fp);
50 assert(s == 10);
51 r = fflush(fp);
52#if 0
53 /* fflush() to reading file is not supported (yet) */
54 assert(errno == EBADF);
55#else
56 assert(r == 0);
57 s = __freadahead(fp);
58 assert(s == 0);
59#endif
60
61 r = fclose(fp);
62 assert(r == 0);
63}
64
65int
66main(int argc, char *argv[])
67{
68 test___freadahead0();
69
70 exit(0);
71}
diff --git a/src/regress/lib/libc/stdio/test___freading.c b/src/regress/lib/libc/stdio/test___freading.c
new file mode 100644
index 0000000000..f74eb78d35
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test___freading.c
@@ -0,0 +1,125 @@
1/* $OpenBSD: test___freading.c,v 1.2 2025/06/12 07:39:26 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <assert.h>
20#include <stdio.h>
21#include <stdio_ext.h>
22#include <stdlib.h>
23#include <string.h>
24#include <unistd.h>
25
26/* we use assert() */
27#undef NDEBUG
28
29#define TMPFILENAME "test___freading.tmp"
30
31void setup(void);
32
33void test___freading0(void);
34void test___freading1(void);
35void test___freading2(void);
36
37void
38setup(void)
39{
40 FILE *fp;
41
42 /* common setup */
43 unlink(TMPFILENAME);
44 fp = fopen(TMPFILENAME, "w+");
45 assert(fp != NULL);
46 fputs("Hello world\n", fp);
47 fclose(fp);
48}
49
50void
51test___freading0(void)
52{
53 FILE *fp;
54 int r;
55 char buf[80];
56
57 fp = popen("echo Hello world", "r");
58 assert(fp != NULL);
59 assert(__freading(fp) != 0);
60 assert(fgets(buf, sizeof(buf), fp) != NULL);
61 assert(strcmp(buf, "Hello world\n") == 0);
62 r = pclose(fp);
63 assert(r == 0);
64}
65
66void
67test___freading1(void)
68{
69 FILE *fp;
70 int r;
71
72 /* when the last operaiton is read, __freading() returns true */
73 fp = fopen(TMPFILENAME, "w+");
74 assert(fp != NULL);
75 assert(__freading(fp) == 0);
76 r = fputs("Hello world\n", fp);
77 assert(r >= 0);
78 assert(__freading(fp) == 0);
79 rewind(fp);
80 assert(fgetc(fp) == 'H');
81 assert(__freading(fp) != 0);
82 /* write */
83 fseek(fp, 0, SEEK_END);
84 r = fputs("\n", fp);
85 assert(__freading(fp) == 0);
86 /* ungetc */
87 rewind(fp);
88 assert(ungetc('X', fp) != 0);
89 assert(__freading(fp) != 0); /* reading */
90
91 r = fclose(fp);
92 assert(r == 0);
93}
94
95void
96test___freading2(void)
97{
98 int r;
99 FILE *fp;
100
101 /*
102 * until v1.10 of fpurge.c mistakenly enables the writing buffer
103 * without _SRD flag set.
104 */
105 fp = fopen(TMPFILENAME, "r+");
106 assert(fp != NULL);
107 assert(fgetc(fp) == 'H');
108 fpurge(fp);
109 fseek(fp, 0, SEEK_CUR);
110 assert(fputc('X', fp) == 'X');
111 assert(__freading(fp) == 0);
112
113 r = fclose(fp);
114 assert(r == 0);
115}
116
117int
118main(int argc, char *argv[])
119{
120 test___freading0();
121 test___freading1();
122 test___freading2();
123
124 exit(0);
125}
diff --git a/src/regress/lib/libc/stdio/test___freadptr.c b/src/regress/lib/libc/stdio/test___freadptr.c
new file mode 100644
index 0000000000..cce362f2ae
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test___freadptr.c
@@ -0,0 +1,78 @@
1/* $OpenBSD: test___freadptr.c,v 1.1 2025/05/25 00:20:54 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <sys/types.h>
20#include <assert.h>
21#include <stdio.h>
22#include <stdio_ext.h>
23#include <stdlib.h>
24#include <string.h>
25
26/* we use assert() */
27#undef NDEBUG
28
29#define TMPFILENAME "test___freadptr.tmp"
30
31void test___freadptr0(void);
32
33/* test __freadptr() and __freadptrinc() */
34void
35test___freadptr0(void)
36{
37 FILE *fp;
38 int r;
39 ssize_t s;
40 const char *p;
41
42 fp = fopen(TMPFILENAME, "w");
43 assert(fp != NULL);
44 r = fputs("Hello world", fp);
45 assert(r >= 0);
46 r = fclose(fp);
47
48 fp = fopen(TMPFILENAME, "r");
49 assert(fgetc(fp) == 'H');
50 p = __freadptr(fp, &s);
51 assert(p != NULL);
52 assert(s > 4); /* this test assume this (not by the spec) */
53 assert(*p == 'e');
54 assert(strncmp(p, "ello world", s) == 0);
55
56 __freadptrinc(fp, 4);
57 assert(fgetc(fp) == ' ');
58
59 ungetc('A', fp);
60 ungetc('A', fp);
61 ungetc('A', fp);
62 p = __freadptr(fp, &s);
63 assert(s > 0);
64 assert(*p == 'A');
65 /* ptr will contains only the pushback buffer */
66 assert(strncmp(p, "AAAworld", s) == 0);
67
68 r = fclose(fp);
69 assert(r == 0);
70}
71
72int
73main(int argc, char *argv[])
74{
75 test___freadptr0();
76
77 exit(0);
78}
diff --git a/src/regress/lib/libc/stdio/test___fseterr.c b/src/regress/lib/libc/stdio/test___fseterr.c
new file mode 100644
index 0000000000..70fb491c6c
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test___fseterr.c
@@ -0,0 +1,60 @@
1/* $OpenBSD: test___fseterr.c,v 1.1 2025/05/25 00:20:54 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <assert.h>
20#include <stdio.h>
21#include <stdio_ext.h>
22#include <stdlib.h>
23
24/* we use assert() */
25#undef NDEBUG
26
27#define TMPFILENAME "test___fseterr.tmp"
28
29void test___fseterr0(void);
30
31void
32test___fseterr0(void)
33{
34 FILE *fp;
35 int r;
36
37 fp = fopen(TMPFILENAME, "w+");
38 assert(fp != NULL);
39
40 assert(!ferror(fp));
41
42 r = fprintf(fp, "hello world\n");
43 assert(r > 0);
44
45 __fseterr(fp);
46 assert(ferror(fp));
47
48 r = fprintf(fp, "hello world\n");
49 assert(r == -1);
50
51 fclose(fp);
52}
53
54int
55main(int argc, char *argv[])
56{
57 test___fseterr0();
58
59 exit(0);
60}
diff --git a/src/regress/lib/libc/stdio/test___fwriting.c b/src/regress/lib/libc/stdio/test___fwriting.c
new file mode 100644
index 0000000000..eb4671d3cf
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test___fwriting.c
@@ -0,0 +1,83 @@
1/* $OpenBSD: test___fwriting.c,v 1.1 2025/05/25 00:20:54 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <assert.h>
20#include <stdio.h>
21#include <stdio_ext.h>
22#include <stdlib.h>
23
24/* we use assert() */
25#undef NDEBUG
26
27#define TMPFILENAME "test___fwriting.tmp"
28
29void test___fwriting0(void);
30void test___fwriting1(void);
31
32void
33test___fwriting0(void)
34{
35 FILE *fp;
36 int r;
37
38 fp = fopen(TMPFILENAME, "w"); /* write only */
39 assert(fp != NULL);
40 assert(__fwriting(fp) != 0); /* writing is true immediately */
41 r = fputs("Hello world\n", fp);
42 assert(r >= 0);
43 r = fclose(fp);
44 assert(r == 0);
45
46 fp = fopen(TMPFILENAME, "a"); /* append only */
47 assert(fp != NULL);
48 assert(__fwriting(fp) != 0); /* writing immediately */
49 r = fclose(fp);
50 assert(r == 0);
51}
52
53void
54test___fwriting1(void)
55{
56 FILE *fp;
57 int r;
58
59 fp = fopen(TMPFILENAME, "w+"); /* read / write */
60 assert(fp != NULL);
61 r = fputs("Hello world\n", fp);
62 assert(r >= 0);
63 assert(__fwriting(fp) != 0);
64 rewind(fp);
65 assert(fgetc(fp) == 'H'); /* read */
66 assert(__fwriting(fp) == 0); /* writing becomes false */
67 fputc('e', fp);
68 assert(__fwriting(fp) != 0); /* writing becomes true */
69 ungetc('e', fp);
70 assert(__fwriting(fp) == 0); /* ungetc -> writing becomes false */
71
72 r = fclose(fp);
73 assert(r == 0);
74}
75
76int
77main(int argc, char *argv[])
78{
79 test___fwriting0();
80 test___fwriting1();
81
82 exit(0);
83}
diff --git a/src/regress/lib/libc/stdio/test_fflush.c b/src/regress/lib/libc/stdio/test_fflush.c
new file mode 100644
index 0000000000..a0586b7d14
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test_fflush.c
@@ -0,0 +1,345 @@
1/* $OpenBSD: test_fflush.c,v 1.3 2025/06/08 08:53:53 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <assert.h>
20#include <locale.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <unistd.h>
25#include <wchar.h>
26
27/* we use assert() */
28#undef NDEBUG
29
30#define TMPFILENAME "test_fflush.tmp"
31
32void setup(void);
33
34void test_fflush_read0(void);
35void test_fflush_read1(void);
36void test_fflush_read2(void);
37void test_fflush_read3(void);
38void test_fflush_read4(void);
39void setupw(void);
40void test_fflush_read5(void);
41void test_fflush_read6(void);
42
43void
44setup(void)
45{
46 FILE *fp;
47
48 /* common setup */
49 unlink(TMPFILENAME);
50 fp = fopen(TMPFILENAME, "w+");
51 assert(fp != NULL);
52 fputs("Hello world\n", fp);
53 fclose(fp);
54}
55
56/* fflush work with reading file and seekable */
57void
58test_fflush_read0(void)
59{
60 int r;
61 char buf[80];
62 FILE *fp;
63
64 setup();
65
66 /* In POSIX 2008, fflush() must work with the file object for reading */
67 fp = fopen(TMPFILENAME, "r");
68 assert(fp != NULL);
69 assert(fgetc(fp) == 'H');
70 r = fflush(fp);
71 assert(r == 0);
72
73 /* the position is moved to 1 */
74 assert(ftell(fp) == 1);
75
76 /* can read rest of that */
77 fgets(buf, sizeof(buf), fp);
78 assert(strcmp(buf, "ello world\n") == 0);
79 r = fclose(fp);
80 assert(r == 0);
81}
82
83/* fflush work with reading file and seekable + unget */
84void
85test_fflush_read1(void)
86{
87 int r;
88 char buf[80];
89 FILE *fp;
90
91 setup();
92
93 fp = fopen(TMPFILENAME, "r");
94 assert(fp != NULL);
95 assert(fgetc(fp) == 'H');
96 assert(fgetc(fp) == 'e');
97 assert(fgetc(fp) == 'l');
98 assert(fgetc(fp) == 'l');
99 assert(fgetc(fp) == 'o');
100
101 /* push the 'AAAA' back */
102 ungetc('A', fp);
103 ungetc('A', fp);
104 ungetc('A', fp);
105 ungetc('A', fp);
106
107 /* can read rest of that */
108 fgets(buf, sizeof(buf), fp);
109 assert(strcmp(buf, "AAAA world\n") == 0);
110 r = fclose(fp);
111 assert(r == 0);
112
113 /* do the same thing + fflush */
114
115 fp = fopen(TMPFILENAME, "r");
116 assert(fp != NULL);
117 assert(fgetc(fp) == 'H');
118 assert(fgetc(fp) == 'e');
119 assert(fgetc(fp) == 'l');
120 assert(fgetc(fp) == 'l');
121 assert(fgetc(fp) == 'o');
122
123 /* push 'AAAA' back */
124 ungetc('A', fp);
125 ungetc('A', fp);
126 ungetc('A', fp);
127 ungetc('A', fp);
128
129 /* then fflush */
130 r = fflush(fp);
131 assert(r == 0);
132
133 /* fllush() clears the all pushed back chars */
134
135 /* can read rest of that */
136 fgets(buf, sizeof(buf), fp);
137 assert(strcmp(buf, " world\n") == 0);
138 r = fclose(fp);
139 assert(r == 0);
140}
141
142/* fflush() to reading and non-seekable stream */
143void
144test_fflush_read2(void)
145{
146 int r;
147 FILE *fp;
148 char buf[80];
149
150 /* In POSIX-2008, fflush() must work with the file object for reading */
151 fp = popen("echo Hello world", "r");
152 assert(fp != NULL);
153 assert(fgetc(fp) == 'H');
154 r = fflush(fp);
155 assert(r == 0);
156
157 /*
158 * FILE object for read and NOT seekable. In that case, fflush does
159 * nothing, but must keep the buffer.
160 */
161
162 /* can read rest of that */
163 fgets(buf, sizeof(buf), fp);
164 assert(strcmp(buf, "ello world\n") == 0);
165 r = pclose(fp);
166 assert(r == 0);
167}
168
169/* fflush() to the file which doesn't have any buffer */
170void
171test_fflush_read3(void)
172{
173 int r;
174 FILE *fp;
175
176 setup();
177
178 /* In POSIX-2008, fflush() must work with the file object for reading */
179 fp = fopen(TMPFILENAME, "r");
180 assert(fp != NULL);
181 r = fflush(fp);
182 assert(r == 0);
183 r = fclose(fp);
184 assert(r == 0);
185}
186
187/* freopen() should call fflush() internal */
188void
189test_fflush_read4(void)
190{
191 int r;
192 FILE *fp;
193 off_t pos;
194 char buf[80];
195
196 setup();
197
198 /* In POSIX-2008, fflush() must work with the file object for reading */
199 fp = fopen(TMPFILENAME, "r");
200 assert(fp != NULL);
201
202 assert(fgetc(fp) == 'H'); /* read 1 */
203
204 pos = lseek(fileno(fp), 0, SEEK_CUR);
205 assert(pos >= 1);
206 assert(pos > 1); /* this test assume the buffer is used */
207
208 /* freopen() should call fflush() internal */
209 fp = freopen(TMPFILENAME, "r", fp);
210 assert(fp != NULL);
211
212 /* can read rest of that on fp */
213 fgets(buf, sizeof(buf), fp);
214 assert(strcmp(buf, "Hello world\n") == 0);
215
216 r = fclose(fp);
217 assert(r == 0);
218}
219
220void
221setupw(void)
222{
223 FILE *fp;
224
225 /* common setup */
226 unlink(TMPFILENAME);
227 fp = fopen(TMPFILENAME, "w+");
228 assert(fp != NULL);
229 /* Konnitiwa Sekai(in Kanji) */
230 fputws(L"\u3053\u3093\u306b\u3061\u308f \u4e16\u754c\n", fp);
231 fclose(fp);
232}
233
234/* fflush work with reading file and seekable + ungetwc */
235void
236test_fflush_read5(void)
237{
238 int r;
239 wchar_t buf[80];
240 FILE *fp;
241
242 setupw();
243
244 fp = fopen(TMPFILENAME, "r");
245
246 assert(fp != NULL);
247 assert(fgetwc(fp) == L'\u3053'); /* Ko */
248 assert(fgetwc(fp) == L'\u3093'); /* N */
249 assert(fgetwc(fp) == L'\u306b'); /* Ni */
250 assert(fgetwc(fp) == L'\u3061'); /* Ti */
251 assert(fgetwc(fp) == L'\u308f'); /* Wa */
252
253 /* push 263A(smile) back */
254 assert(ungetwc(L'\u263a', fp));
255
256 /* we support 1 push back wchar_t */
257 assert(fgetwc(fp) == L'\u263a');
258
259 /* can read reset of that */
260 fgetws(buf, sizeof(buf), fp);
261 assert(wcscmp(buf, L" \u4e16\u754c\n") == 0);
262
263 r = fclose(fp);
264 assert(r == 0);
265
266 /* do the same thing + fflush */
267 fp = fopen(TMPFILENAME, "r");
268
269 assert(fp != NULL);
270 assert(fgetwc(fp) == L'\u3053'); /* Ko */
271 assert(fgetwc(fp) == L'\u3093'); /* N */
272 assert(fgetwc(fp) == L'\u306b'); /* Ni */
273 assert(fgetwc(fp) == L'\u3061'); /* Ti */
274 assert(fgetwc(fp) == L'\u308f'); /* Wa */
275
276 /* push 263A(smile) back */
277 assert(ungetwc(L'\u263a', fp));
278
279 /* we support 1 push back wchar_t */
280 assert(fgetwc(fp) == L'\u263a');
281
282 /* then fflush */
283 r = fflush(fp);
284 assert(r == 0);
285
286 /* fllush() clears the all pushed back chars */
287
288 /* can read rest of that */
289 fgetws(buf, sizeof(buf), fp);
290 assert(wcscmp(buf, L" \u4e16\u754c\n") == 0);
291 r = fclose(fp);
292 assert(r == 0);
293}
294
295void
296test_fflush_read6(void)
297{
298 int r, c;
299 FILE *fp;
300
301 setup();
302 fp = fopen(TMPFILENAME, "r");
303 assert(fp != NULL);
304
305 /*
306 * https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html
307 * .. any characters pushed back onto the stream by ungetc() or ungetwc()
308 * that have not subsequently been read from the stream shall be discarded
309 * (without further changing the file offset).
310 */
311
312 assert(fgetc(fp) == 'H');
313 c = getc(fp);
314 ungetc(c, fp); /* push back the character has been read */
315 r = fflush(fp);
316 assert(r == 0);
317 assert(getc(fp) == c);
318
319 fseek(fp, 0, SEEK_SET);
320 assert(fgetc(fp) == 'H');
321 c = getc(fp);
322 ungetc('X', fp); /* push back the character has not been read */
323 r = fflush(fp);
324 assert(r == 0);
325 assert(getc(fp) == 'l');
326
327 r = fclose(fp);
328 assert(r == 0);
329}
330
331int
332main(int argc, char *argv[])
333{
334 setlocale(LC_ALL, "C.UTF-8");
335
336 test_fflush_read0();
337 test_fflush_read1();
338 test_fflush_read2();
339 test_fflush_read3();
340 test_fflush_read4();
341 test_fflush_read5();
342 test_fflush_read6();
343
344 exit(0);
345}
diff --git a/src/regress/lib/libc/stdio/test_ungetwc.c b/src/regress/lib/libc/stdio/test_ungetwc.c
new file mode 100644
index 0000000000..bb4e853020
--- /dev/null
+++ b/src/regress/lib/libc/stdio/test_ungetwc.c
@@ -0,0 +1,90 @@
1/* $OpenBSD: test_ungetwc.c,v 1.1 2025/05/25 05:32:45 yasuoka Exp $ */
2
3/*
4 * Copyright (c) 2025 YASUOKA Masahiko <yasuoka@yasuoka.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <assert.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <unistd.h>
24#include <locale.h>
25#include <wchar.h>
26
27/* we use assert() */
28#undef NDEBUG
29
30#define TMPFILENAME "test_ungetwc.tmp"
31
32void setupw(void);
33void test_fflush_ungetwc0(void);
34
35void
36setupw(void)
37{
38 FILE *fp;
39
40 /* common setup */
41 unlink(TMPFILENAME);
42 fp = fopen(TMPFILENAME, "w+");
43 assert(fp != NULL);
44 /* Konnitiwa Sekai(in Kanji) */
45 fputws(L"\u3053\u3093\u306b\u3061\u308f \u4e16\u754c\n", fp);
46 fclose(fp);
47}
48
49/* fflush work with reading file and seekable + ungetwc */
50void
51test_fflush_ungetwc0(void)
52{
53 int r;
54 wchar_t buf[80];
55 FILE *fp;
56
57 setupw();
58
59 fp = fopen(TMPFILENAME, "r");
60
61 assert(fp != NULL);
62 assert(fgetwc(fp) == L'\u3053'); /* Ko */
63 assert(fgetwc(fp) == L'\u3093'); /* N */
64 assert(fgetwc(fp) == L'\u306b'); /* Ni */
65 assert(fgetwc(fp) == L'\u3061'); /* Ti */
66 assert(fgetwc(fp) == L'\u308f'); /* Wa */
67
68 /* push 263A(smile) back */
69 assert(ungetwc(L'\u263a', fp));
70
71 /* we support 1 push back wchar_t */
72 assert(fgetwc(fp) == L'\u263a');
73
74 /* can read reset of that */
75 fgetws(buf, sizeof(buf), fp);
76 assert(wcscmp(buf, L" \u4e16\u754c\n") == 0);
77
78 r = fclose(fp);
79 assert(r == 0);
80}
81
82int
83main(int argc, char *argv[])
84{
85 setlocale(LC_ALL, "C.UTF-8");
86
87 test_fflush_ungetwc0();
88
89 exit(0);
90}
diff --git a/src/regress/lib/libc/time/time_conversion/timetest.c b/src/regress/lib/libc/time/time_conversion/timetest.c
index 0706704ee1..1405f1c6a5 100644
--- a/src/regress/lib/libc/time/time_conversion/timetest.c
+++ b/src/regress/lib/libc/time/time_conversion/timetest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: timetest.c,v 1.4 2023/04/13 11:32:06 mbuhl Exp $ */ 1/* $OpenBSD: timetest.c,v 1.5 2025/08/17 08:43:03 phessler Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2022 Bob Beck <beck@openbsd.org>
@@ -79,12 +79,12 @@ struct timetest timetests[] = {
79 .tm_yday=171, 79 .tm_yday=171,
80 .tm_isdst=0, 80 .tm_isdst=0,
81 .tm_gmtoff=0, 81 .tm_gmtoff=0,
82 .tm_zone="GMT" 82 .tm_zone="UTC"
83 }, 83 },
84 }, 84 },
85 { 85 {
86 .descr="moon", 86 .descr="moon",
87 .timezone="right/UTC", 87 .timezone="right/GMT",
88 .time=-16751025, 88 .time=-16751025,
89 .local_tm= { 89 .local_tm= {
90 .tm_year=69, 90 .tm_year=69,
@@ -97,7 +97,7 @@ struct timetest timetests[] = {
97 .tm_yday=171, 97 .tm_yday=171,
98 .tm_isdst=0, 98 .tm_isdst=0,
99 .tm_gmtoff=0, 99 .tm_gmtoff=0,
100 .tm_zone="UTC" 100 .tm_zone="GMT"
101 }, 101 },
102 .gmt_tm= { 102 .gmt_tm= {
103 .tm_year=69, 103 .tm_year=69,
@@ -110,7 +110,7 @@ struct timetest timetests[] = {
110 .tm_yday=171, 110 .tm_yday=171,
111 .tm_isdst=0, 111 .tm_isdst=0,
112 .tm_gmtoff=0, 112 .tm_gmtoff=0,
113 .tm_zone="GMT" 113 .tm_zone="UTC"
114 }, 114 },
115 }, 115 },
116 { 116 {
@@ -141,7 +141,7 @@ struct timetest timetests[] = {
141 .tm_yday=171, 141 .tm_yday=171,
142 .tm_isdst=0, 142 .tm_isdst=0,
143 .tm_gmtoff=0, 143 .tm_gmtoff=0,
144 .tm_zone="GMT" 144 .tm_zone="UTC"
145 }, 145 },
146 }, 146 },
147 { 147 {
@@ -172,12 +172,12 @@ struct timetest timetests[] = {
172 .tm_yday=0, 172 .tm_yday=0,
173 .tm_isdst=0, 173 .tm_isdst=0,
174 .tm_gmtoff=0, 174 .tm_gmtoff=0,
175 .tm_zone="GMT" 175 .tm_zone="UTC"
176 }, 176 },
177 }, 177 },
178 { 178 {
179 .descr="epoch", 179 .descr="epoch",
180 .timezone="right/UTC", 180 .timezone="right/GMT",
181 .time=0, 181 .time=0,
182 .local_tm= { 182 .local_tm= {
183 .tm_year=70, 183 .tm_year=70,
@@ -190,7 +190,7 @@ struct timetest timetests[] = {
190 .tm_yday=0, 190 .tm_yday=0,
191 .tm_isdst=0, 191 .tm_isdst=0,
192 .tm_gmtoff=0, 192 .tm_gmtoff=0,
193 .tm_zone="UTC" 193 .tm_zone="GMT"
194 }, 194 },
195 .gmt_tm= { 195 .gmt_tm= {
196 .tm_year=70, 196 .tm_year=70,
@@ -203,7 +203,7 @@ struct timetest timetests[] = {
203 .tm_yday=0, 203 .tm_yday=0,
204 .tm_isdst=0, 204 .tm_isdst=0,
205 .tm_gmtoff=0, 205 .tm_gmtoff=0,
206 .tm_zone="GMT" 206 .tm_zone="UTC"
207 }, 207 },
208 }, 208 },
209 { 209 {
@@ -234,7 +234,7 @@ struct timetest timetests[] = {
234 .tm_yday=0, 234 .tm_yday=0,
235 .tm_isdst=0, 235 .tm_isdst=0,
236 .tm_gmtoff=0, 236 .tm_gmtoff=0,
237 .tm_zone="GMT" 237 .tm_zone="UTC"
238 }, 238 },
239 }, 239 },
240 { 240 {
@@ -265,12 +265,12 @@ struct timetest timetests[] = {
265 .tm_yday=364, 265 .tm_yday=364,
266 .tm_isdst=0, 266 .tm_isdst=0,
267 .tm_gmtoff=0, 267 .tm_gmtoff=0,
268 .tm_zone="GMT" 268 .tm_zone="UTC"
269 }, 269 },
270 }, 270 },
271 { 271 {
272 .descr="epoch - 1", 272 .descr="epoch - 1",
273 .timezone="right/UTC", 273 .timezone="right/GMT",
274 .time=-1, 274 .time=-1,
275 .local_tm= { 275 .local_tm= {
276 .tm_year=69, 276 .tm_year=69,
@@ -283,7 +283,7 @@ struct timetest timetests[] = {
283 .tm_yday=364, 283 .tm_yday=364,
284 .tm_isdst=0, 284 .tm_isdst=0,
285 .tm_gmtoff=0, 285 .tm_gmtoff=0,
286 .tm_zone="UTC" 286 .tm_zone="GMT"
287 }, 287 },
288 .gmt_tm= { 288 .gmt_tm= {
289 .tm_year=69, 289 .tm_year=69,
@@ -296,7 +296,7 @@ struct timetest timetests[] = {
296 .tm_yday=364, 296 .tm_yday=364,
297 .tm_isdst=0, 297 .tm_isdst=0,
298 .tm_gmtoff=0, 298 .tm_gmtoff=0,
299 .tm_zone="GMT" 299 .tm_zone="UTC"
300 }, 300 },
301 }, 301 },
302 { 302 {
@@ -327,7 +327,7 @@ struct timetest timetests[] = {
327 .tm_yday=364, 327 .tm_yday=364,
328 .tm_isdst=0, 328 .tm_isdst=0,
329 .tm_gmtoff=0, 329 .tm_gmtoff=0,
330 .tm_zone="GMT" 330 .tm_zone="UTC"
331 }, 331 },
332 }, 332 },
333 { 333 {
@@ -358,12 +358,12 @@ struct timetest timetests[] = {
358 .tm_yday=346, 358 .tm_yday=346,
359 .tm_isdst=0, 359 .tm_isdst=0,
360 .tm_gmtoff=0, 360 .tm_gmtoff=0,
361 .tm_zone="GMT" 361 .tm_zone="UTC"
362 }, 362 },
363 }, 363 },
364 { 364 {
365 .descr="legacy min", 365 .descr="legacy min",
366 .timezone="right/UTC", 366 .timezone="right/GMT",
367 .time=-2147483648, 367 .time=-2147483648,
368 .local_tm= { 368 .local_tm= {
369 .tm_year=1, 369 .tm_year=1,
@@ -376,7 +376,7 @@ struct timetest timetests[] = {
376 .tm_yday=346, 376 .tm_yday=346,
377 .tm_isdst=0, 377 .tm_isdst=0,
378 .tm_gmtoff=0, 378 .tm_gmtoff=0,
379 .tm_zone="UTC" 379 .tm_zone="GMT"
380 }, 380 },
381 .gmt_tm= { 381 .gmt_tm= {
382 .tm_year=1, 382 .tm_year=1,
@@ -389,7 +389,7 @@ struct timetest timetests[] = {
389 .tm_yday=346, 389 .tm_yday=346,
390 .tm_isdst=0, 390 .tm_isdst=0,
391 .tm_gmtoff=0, 391 .tm_gmtoff=0,
392 .tm_zone="GMT" 392 .tm_zone="UTC"
393 }, 393 },
394 }, 394 },
395 { 395 {
@@ -420,12 +420,12 @@ struct timetest timetests[] = {
420 .tm_yday=346, 420 .tm_yday=346,
421 .tm_isdst=0, 421 .tm_isdst=0,
422 .tm_gmtoff=0, 422 .tm_gmtoff=0,
423 .tm_zone="GMT" 423 .tm_zone="UTC"
424 }, 424 },
425 }, 425 },
426 { 426 {
427 .descr="legacy min - 1", 427 .descr="legacy min - 1",
428 .timezone="right/UTC", 428 .timezone="right/GMT",
429 .time=-2147483649, 429 .time=-2147483649,
430 .local_tm= { 430 .local_tm= {
431 .tm_year=1, 431 .tm_year=1,
@@ -438,7 +438,7 @@ struct timetest timetests[] = {
438 .tm_yday=346, 438 .tm_yday=346,
439 .tm_isdst=0, 439 .tm_isdst=0,
440 .tm_gmtoff=0, 440 .tm_gmtoff=0,
441 .tm_zone="UTC" 441 .tm_zone="GMT"
442 }, 442 },
443 .gmt_tm= { 443 .gmt_tm= {
444 .tm_year=1, 444 .tm_year=1,
@@ -451,7 +451,7 @@ struct timetest timetests[] = {
451 .tm_yday=346, 451 .tm_yday=346,
452 .tm_isdst=0, 452 .tm_isdst=0,
453 .tm_gmtoff=0, 453 .tm_gmtoff=0,
454 .tm_zone="GMT" 454 .tm_zone="UTC"
455 }, 455 },
456 }, 456 },
457 { 457 {
@@ -482,12 +482,12 @@ struct timetest timetests[] = {
482 .tm_yday=18, 482 .tm_yday=18,
483 .tm_isdst=0, 483 .tm_isdst=0,
484 .tm_gmtoff=0, 484 .tm_gmtoff=0,
485 .tm_zone="GMT" 485 .tm_zone="UTC"
486 }, 486 },
487 }, 487 },
488 { 488 {
489 .descr="legacy max", 489 .descr="legacy max",
490 .timezone="right/UTC", 490 .timezone="right/GMT",
491 .time=2147483647, 491 .time=2147483647,
492 .local_tm= { 492 .local_tm= {
493 .tm_year=138, 493 .tm_year=138,
@@ -500,7 +500,7 @@ struct timetest timetests[] = {
500 .tm_yday=18, 500 .tm_yday=18,
501 .tm_isdst=0, 501 .tm_isdst=0,
502 .tm_gmtoff=0, 502 .tm_gmtoff=0,
503 .tm_zone="UTC" 503 .tm_zone="GMT"
504 }, 504 },
505 .gmt_tm= { 505 .gmt_tm= {
506 .tm_year=138, 506 .tm_year=138,
@@ -513,7 +513,7 @@ struct timetest timetests[] = {
513 .tm_yday=18, 513 .tm_yday=18,
514 .tm_isdst=0, 514 .tm_isdst=0,
515 .tm_gmtoff=0, 515 .tm_gmtoff=0,
516 .tm_zone="GMT" 516 .tm_zone="UTC"
517 }, 517 },
518 }, 518 },
519 { 519 {
@@ -544,12 +544,12 @@ struct timetest timetests[] = {
544 .tm_yday=18, 544 .tm_yday=18,
545 .tm_isdst=0, 545 .tm_isdst=0,
546 .tm_gmtoff=0, 546 .tm_gmtoff=0,
547 .tm_zone="GMT" 547 .tm_zone="UTC"
548 }, 548 },
549 }, 549 },
550 { 550 {
551 .descr="legacy max + 1", 551 .descr="legacy max + 1",
552 .timezone="right/UTC", 552 .timezone="right/GMT",
553 .time=2147483648, 553 .time=2147483648,
554 .local_tm= { 554 .local_tm= {
555 .tm_year=138, 555 .tm_year=138,
@@ -562,7 +562,7 @@ struct timetest timetests[] = {
562 .tm_yday=18, 562 .tm_yday=18,
563 .tm_isdst=0, 563 .tm_isdst=0,
564 .tm_gmtoff=0, 564 .tm_gmtoff=0,
565 .tm_zone="UTC" 565 .tm_zone="GMT"
566 }, 566 },
567 .gmt_tm= { 567 .gmt_tm= {
568 .tm_year=138, 568 .tm_year=138,
@@ -575,7 +575,7 @@ struct timetest timetests[] = {
575 .tm_yday=18, 575 .tm_yday=18,
576 .tm_isdst=0, 576 .tm_isdst=0,
577 .tm_gmtoff=0, 577 .tm_gmtoff=0,
578 .tm_zone="GMT" 578 .tm_zone="UTC"
579 }, 579 },
580 }, 580 },
581 { 581 {
@@ -611,7 +611,7 @@ struct timetest timetests[] = {
611 }, 611 },
612 { 612 {
613 .descr="min", 613 .descr="min",
614 .timezone="right/UTC", 614 .timezone="right/GMT",
615 .time=INT64_MIN, 615 .time=INT64_MIN,
616 .local_tm= { 616 .local_tm= {
617 .tm_year=0, 617 .tm_year=0,
@@ -704,7 +704,7 @@ struct timetest timetests[] = {
704 }, 704 },
705 { 705 {
706 .descr="max", 706 .descr="max",
707 .timezone="right/UTC", 707 .timezone="right/GMT",
708 .time=9223372036854775807, 708 .time=9223372036854775807,
709 .local_tm= { 709 .local_tm= {
710 .tm_year=0, 710 .tm_year=0,
@@ -792,7 +792,7 @@ struct timetest timetests[] = {
792 .tm_yday=30, 792 .tm_yday=30,
793 .tm_isdst=0, 793 .tm_isdst=0,
794 .tm_gmtoff=0, 794 .tm_gmtoff=0,
795 .tm_zone="GMT" 795 .tm_zone="UTC"
796 }, 796 },
797 }, 797 },
798 { 798 {
@@ -823,12 +823,12 @@ struct timetest timetests[] = {
823 .tm_yday=30, 823 .tm_yday=30,
824 .tm_isdst=0, 824 .tm_isdst=0,
825 .tm_gmtoff=0, 825 .tm_gmtoff=0,
826 .tm_zone="GMT" 826 .tm_zone="UTC"
827 }, 827 },
828 }, 828 },
829 { 829 {
830 .descr="maxint struct tm", 830 .descr="maxint struct tm",
831 .timezone="right/UTC", 831 .timezone="right/GMT",
832 .time=67767976204675199, 832 .time=67767976204675199,
833 .local_tm= { 833 .local_tm= {
834 .tm_year=2147481747, 834 .tm_year=2147481747,
@@ -841,7 +841,7 @@ struct timetest timetests[] = {
841 .tm_yday=30, 841 .tm_yday=30,
842 .tm_isdst=0, 842 .tm_isdst=0,
843 .tm_gmtoff=0, 843 .tm_gmtoff=0,
844 .tm_zone="UTC" 844 .tm_zone="GMT"
845 }, 845 },
846 .gmt_tm= { 846 .gmt_tm= {
847 .tm_year=2147481747, 847 .tm_year=2147481747,
@@ -854,12 +854,12 @@ struct timetest timetests[] = {
854 .tm_yday=30, 854 .tm_yday=30,
855 .tm_isdst=0, 855 .tm_isdst=0,
856 .tm_gmtoff=0, 856 .tm_gmtoff=0,
857 .tm_zone="GMT" 857 .tm_zone="UTC"
858 }, 858 },
859 }, 859 },
860 { 860 {
861 .descr="minint struct tm", 861 .descr="minint struct tm",
862 .timezone="right/UTC", 862 .timezone="right/GMT",
863 .time=-67768038398073601, 863 .time=-67768038398073601,
864 .local_tm= { 864 .local_tm= {
865 .tm_year=-2147483578, 865 .tm_year=-2147483578,
@@ -872,7 +872,7 @@ struct timetest timetests[] = {
872 .tm_yday=30, 872 .tm_yday=30,
873 .tm_isdst=0, 873 .tm_isdst=0,
874 .tm_gmtoff=0, 874 .tm_gmtoff=0,
875 .tm_zone="UTC" 875 .tm_zone="GMT"
876 }, 876 },
877 .gmt_tm= { 877 .gmt_tm= {
878 .tm_year=-2147483578, 878 .tm_year=-2147483578,
@@ -885,7 +885,7 @@ struct timetest timetests[] = {
885 .tm_yday=30, 885 .tm_yday=30,
886 .tm_isdst=0, 886 .tm_isdst=0,
887 .tm_gmtoff=0, 887 .tm_gmtoff=0,
888 .tm_zone="GMT" 888 .tm_zone="UTC"
889 }, 889 },
890 }, 890 },
891 { 891 {
@@ -916,12 +916,12 @@ struct timetest timetests[] = {
916 .tm_yday=0, 916 .tm_yday=0,
917 .tm_isdst=0, 917 .tm_isdst=0,
918 .tm_gmtoff=0, 918 .tm_gmtoff=0,
919 .tm_zone="GMT" 919 .tm_zone="UTC"
920 }, 920 },
921 }, 921 },
922 { 922 {
923 .descr="0000", 923 .descr="0000",
924 .timezone="right/UTC", 924 .timezone="right/GMT",
925 .time=-62167219200, 925 .time=-62167219200,
926 .local_tm= { 926 .local_tm= {
927 .tm_year=-1900, 927 .tm_year=-1900,
@@ -934,7 +934,7 @@ struct timetest timetests[] = {
934 .tm_yday=0, 934 .tm_yday=0,
935 .tm_isdst=0, 935 .tm_isdst=0,
936 .tm_gmtoff=0, 936 .tm_gmtoff=0,
937 .tm_zone="UTC" 937 .tm_zone="GMT"
938 }, 938 },
939 .gmt_tm= { 939 .gmt_tm= {
940 .tm_year=-1900, 940 .tm_year=-1900,
@@ -947,7 +947,7 @@ struct timetest timetests[] = {
947 .tm_yday=0, 947 .tm_yday=0,
948 .tm_isdst=0, 948 .tm_isdst=0,
949 .tm_gmtoff=0, 949 .tm_gmtoff=0,
950 .tm_zone="GMT" 950 .tm_zone="UTC"
951 }, 951 },
952 }, 952 },
953 { 953 {
@@ -978,7 +978,7 @@ struct timetest timetests[] = {
978 .tm_yday=0, 978 .tm_yday=0,
979 .tm_isdst=0, 979 .tm_isdst=0,
980 .tm_gmtoff=0, 980 .tm_gmtoff=0,
981 .tm_zone="GMT" 981 .tm_zone="UTC"
982 }, 982 },
983 }, 983 },
984 { 984 {
@@ -1009,12 +1009,12 @@ struct timetest timetests[] = {
1009 .tm_yday=364, 1009 .tm_yday=364,
1010 .tm_isdst=0, 1010 .tm_isdst=0,
1011 .tm_gmtoff=0, 1011 .tm_gmtoff=0,
1012 .tm_zone="GMT" 1012 .tm_zone="UTC"
1013 }, 1013 },
1014 }, 1014 },
1015 { 1015 {
1016 .descr="9999", 1016 .descr="9999",
1017 .timezone="right/UTC", 1017 .timezone="right/GMT",
1018 .time=253402300799, 1018 .time=253402300799,
1019 .local_tm= { 1019 .local_tm= {
1020 .tm_year=8099, 1020 .tm_year=8099,
@@ -1027,7 +1027,7 @@ struct timetest timetests[] = {
1027 .tm_yday=364, 1027 .tm_yday=364,
1028 .tm_isdst=0, 1028 .tm_isdst=0,
1029 .tm_gmtoff=0, 1029 .tm_gmtoff=0,
1030 .tm_zone="UTC" 1030 .tm_zone="GMT"
1031 }, 1031 },
1032 .gmt_tm= { 1032 .gmt_tm= {
1033 .tm_year=8099, 1033 .tm_year=8099,
@@ -1040,7 +1040,7 @@ struct timetest timetests[] = {
1040 .tm_yday=364, 1040 .tm_yday=364,
1041 .tm_isdst=0, 1041 .tm_isdst=0,
1042 .tm_gmtoff=0, 1042 .tm_gmtoff=0,
1043 .tm_zone="GMT" 1043 .tm_zone="UTC"
1044 }, 1044 },
1045 }, 1045 },
1046 { 1046 {
@@ -1071,7 +1071,7 @@ struct timetest timetests[] = {
1071 .tm_yday=364, 1071 .tm_yday=364,
1072 .tm_isdst=0, 1072 .tm_isdst=0,
1073 .tm_gmtoff=0, 1073 .tm_gmtoff=0,
1074 .tm_zone="GMT" 1074 .tm_zone="UTC"
1075 }, 1075 },
1076 }, 1076 },
1077 { 1077 {
@@ -1102,7 +1102,7 @@ struct timetest timetests[] = {
1102 .tm_yday=0, 1102 .tm_yday=0,
1103 .tm_isdst=0, 1103 .tm_isdst=0,
1104 .tm_gmtoff=0, 1104 .tm_gmtoff=0,
1105 .tm_zone="GMT" 1105 .tm_zone="UTC"
1106 }, 1106 },
1107 }, 1107 },
1108 { 1108 {
@@ -1133,7 +1133,7 @@ struct timetest timetests[] = {
1133 .tm_yday=0, 1133 .tm_yday=0,
1134 .tm_isdst=0, 1134 .tm_isdst=0,
1135 .tm_gmtoff=0, 1135 .tm_gmtoff=0,
1136 .tm_zone="GMT" 1136 .tm_zone="UTC"
1137 }, 1137 },
1138 }, 1138 },
1139 { 1139 {
@@ -1164,12 +1164,12 @@ struct timetest timetests[] = {
1164 .tm_yday=0, 1164 .tm_yday=0,
1165 .tm_isdst=0, 1165 .tm_isdst=0,
1166 .tm_gmtoff=0, 1166 .tm_gmtoff=0,
1167 .tm_zone="GMT" 1167 .tm_zone="UTC"
1168 }, 1168 },
1169 }, 1169 },
1170 { 1170 {
1171 .descr="leap second - 1", 1171 .descr="leap second - 1",
1172 .timezone="right/UTC", 1172 .timezone="right/GMT",
1173 .time=1483228825, 1173 .time=1483228825,
1174 .local_tm= { 1174 .local_tm= {
1175 .tm_year=116, 1175 .tm_year=116,
@@ -1182,7 +1182,7 @@ struct timetest timetests[] = {
1182 .tm_yday=365, 1182 .tm_yday=365,
1183 .tm_isdst=0, 1183 .tm_isdst=0,
1184 .tm_gmtoff=0, 1184 .tm_gmtoff=0,
1185 .tm_zone="UTC" 1185 .tm_zone="GMT"
1186 }, 1186 },
1187 .gmt_tm= { 1187 .gmt_tm= {
1188 .tm_year=117, 1188 .tm_year=117,
@@ -1195,12 +1195,12 @@ struct timetest timetests[] = {
1195 .tm_yday=0, 1195 .tm_yday=0,
1196 .tm_isdst=0, 1196 .tm_isdst=0,
1197 .tm_gmtoff=0, 1197 .tm_gmtoff=0,
1198 .tm_zone="GMT" 1198 .tm_zone="UTC"
1199 }, 1199 },
1200 }, 1200 },
1201 { 1201 {
1202 .descr="leap second", 1202 .descr="leap second",
1203 .timezone="right/UTC", 1203 .timezone="right/GMT",
1204 .time=1483228826, 1204 .time=1483228826,
1205 .local_tm= { 1205 .local_tm= {
1206 .tm_year=116, 1206 .tm_year=116,
@@ -1213,7 +1213,7 @@ struct timetest timetests[] = {
1213 .tm_yday=365, 1213 .tm_yday=365,
1214 .tm_isdst=0, 1214 .tm_isdst=0,
1215 .tm_gmtoff=0, 1215 .tm_gmtoff=0,
1216 .tm_zone="UTC" 1216 .tm_zone="GMT"
1217 }, 1217 },
1218 .gmt_tm= { 1218 .gmt_tm= {
1219 .tm_year=117, 1219 .tm_year=117,
@@ -1226,12 +1226,12 @@ struct timetest timetests[] = {
1226 .tm_yday=0, 1226 .tm_yday=0,
1227 .tm_isdst=0, 1227 .tm_isdst=0,
1228 .tm_gmtoff=0, 1228 .tm_gmtoff=0,
1229 .tm_zone="GMT" 1229 .tm_zone="UTC"
1230 }, 1230 },
1231 }, 1231 },
1232 { 1232 {
1233 .descr="leap second + 1", 1233 .descr="leap second + 1",
1234 .timezone="right/UTC", 1234 .timezone="right/GMT",
1235 .time=1483228827, 1235 .time=1483228827,
1236 .local_tm= { 1236 .local_tm= {
1237 .tm_year=117, 1237 .tm_year=117,
@@ -1244,7 +1244,7 @@ struct timetest timetests[] = {
1244 .tm_yday=0, 1244 .tm_yday=0,
1245 .tm_isdst=0, 1245 .tm_isdst=0,
1246 .tm_gmtoff=0, 1246 .tm_gmtoff=0,
1247 .tm_zone="UTC" 1247 .tm_zone="GMT"
1248 }, 1248 },
1249 .gmt_tm= { 1249 .gmt_tm= {
1250 .tm_year=117, 1250 .tm_year=117,
@@ -1257,7 +1257,7 @@ struct timetest timetests[] = {
1257 .tm_yday=0, 1257 .tm_yday=0,
1258 .tm_isdst=0, 1258 .tm_isdst=0,
1259 .tm_gmtoff=0, 1259 .tm_gmtoff=0,
1260 .tm_zone="GMT" 1260 .tm_zone="UTC"
1261 }, 1261 },
1262 }, 1262 },
1263 { 1263 {
@@ -1288,7 +1288,7 @@ struct timetest timetests[] = {
1288 .tm_yday=0, 1288 .tm_yday=0,
1289 .tm_isdst=0, 1289 .tm_isdst=0,
1290 .tm_gmtoff=0, 1290 .tm_gmtoff=0,
1291 .tm_zone="GMT" 1291 .tm_zone="UTC"
1292 }, 1292 },
1293 }, 1293 },
1294 { 1294 {
@@ -1319,7 +1319,7 @@ struct timetest timetests[] = {
1319 .tm_yday=0, 1319 .tm_yday=0,
1320 .tm_isdst=0, 1320 .tm_isdst=0,
1321 .tm_gmtoff=0, 1321 .tm_gmtoff=0,
1322 .tm_zone="GMT" 1322 .tm_zone="UTC"
1323 }, 1323 },
1324 }, 1324 },
1325 { 1325 {
@@ -1350,7 +1350,7 @@ struct timetest timetests[] = {
1350 .tm_yday=0, 1350 .tm_yday=0,
1351 .tm_isdst=0, 1351 .tm_isdst=0,
1352 .tm_gmtoff=0, 1352 .tm_gmtoff=0,
1353 .tm_zone="GMT" 1353 .tm_zone="UTC"
1354 }, 1354 },
1355 }, 1355 },
1356 { 1356 {
@@ -1381,7 +1381,7 @@ struct timetest timetests[] = {
1381 .tm_yday=72, 1381 .tm_yday=72,
1382 .tm_isdst=0, 1382 .tm_isdst=0,
1383 .tm_gmtoff=0, 1383 .tm_gmtoff=0,
1384 .tm_zone="GMT" 1384 .tm_zone="UTC"
1385 }, 1385 },
1386 }, 1386 },
1387 { 1387 {
@@ -1412,7 +1412,7 @@ struct timetest timetests[] = {
1412 .tm_yday=72, 1412 .tm_yday=72,
1413 .tm_isdst=0, 1413 .tm_isdst=0,
1414 .tm_gmtoff=0, 1414 .tm_gmtoff=0,
1415 .tm_zone="GMT" 1415 .tm_zone="UTC"
1416 }, 1416 },
1417 }, 1417 },
1418 { 1418 {
@@ -1443,7 +1443,7 @@ struct timetest timetests[] = {
1443 .tm_yday=72, 1443 .tm_yday=72,
1444 .tm_isdst=0, 1444 .tm_isdst=0,
1445 .tm_gmtoff=0, 1445 .tm_gmtoff=0,
1446 .tm_zone="GMT" 1446 .tm_zone="UTC"
1447 }, 1447 },
1448 }, 1448 },
1449 { 1449 {
@@ -1474,7 +1474,7 @@ struct timetest timetests[] = {
1474 .tm_yday=72, 1474 .tm_yday=72,
1475 .tm_isdst=0, 1475 .tm_isdst=0,
1476 .tm_gmtoff=0, 1476 .tm_gmtoff=0,
1477 .tm_zone="GMT" 1477 .tm_zone="UTC"
1478 }, 1478 },
1479 }, 1479 },
1480 { 1480 {
@@ -1505,7 +1505,7 @@ struct timetest timetests[] = {
1505 .tm_yday=72, 1505 .tm_yday=72,
1506 .tm_isdst=0, 1506 .tm_isdst=0,
1507 .tm_gmtoff=0, 1507 .tm_gmtoff=0,
1508 .tm_zone="GMT" 1508 .tm_zone="UTC"
1509 }, 1509 },
1510 }, 1510 },
1511 { 1511 {
@@ -1536,7 +1536,7 @@ struct timetest timetests[] = {
1536 .tm_yday=72, 1536 .tm_yday=72,
1537 .tm_isdst=0, 1537 .tm_isdst=0,
1538 .tm_gmtoff=0, 1538 .tm_gmtoff=0,
1539 .tm_zone="GMT" 1539 .tm_zone="UTC"
1540 }, 1540 },
1541 }, 1541 },
1542 { 1542 {
@@ -1567,7 +1567,7 @@ struct timetest timetests[] = {
1567 .tm_yday=310, 1567 .tm_yday=310,
1568 .tm_isdst=0, 1568 .tm_isdst=0,
1569 .tm_gmtoff=0, 1569 .tm_gmtoff=0,
1570 .tm_zone="GMT" 1570 .tm_zone="UTC"
1571 }, 1571 },
1572 }, 1572 },
1573 { 1573 {
@@ -1598,7 +1598,7 @@ struct timetest timetests[] = {
1598 .tm_yday=310, 1598 .tm_yday=310,
1599 .tm_isdst=0, 1599 .tm_isdst=0,
1600 .tm_gmtoff=0, 1600 .tm_gmtoff=0,
1601 .tm_zone="GMT" 1601 .tm_zone="UTC"
1602 }, 1602 },
1603 }, 1603 },
1604 { 1604 {
@@ -1629,7 +1629,7 @@ struct timetest timetests[] = {
1629 .tm_yday=310, 1629 .tm_yday=310,
1630 .tm_isdst=0, 1630 .tm_isdst=0,
1631 .tm_gmtoff=0, 1631 .tm_gmtoff=0,
1632 .tm_zone="GMT" 1632 .tm_zone="UTC"
1633 }, 1633 },
1634 }, 1634 },
1635 { 1635 {
@@ -1660,7 +1660,7 @@ struct timetest timetests[] = {
1660 .tm_yday=310, 1660 .tm_yday=310,
1661 .tm_isdst=0, 1661 .tm_isdst=0,
1662 .tm_gmtoff=0, 1662 .tm_gmtoff=0,
1663 .tm_zone="GMT" 1663 .tm_zone="UTC"
1664 }, 1664 },
1665 }, 1665 },
1666 { 1666 {
@@ -1691,7 +1691,7 @@ struct timetest timetests[] = {
1691 .tm_yday=310, 1691 .tm_yday=310,
1692 .tm_isdst=0, 1692 .tm_isdst=0,
1693 .tm_gmtoff=0, 1693 .tm_gmtoff=0,
1694 .tm_zone="GMT" 1694 .tm_zone="UTC"
1695 }, 1695 },
1696 }, 1696 },
1697 { 1697 {
@@ -1722,7 +1722,7 @@ struct timetest timetests[] = {
1722 .tm_yday=310, 1722 .tm_yday=310,
1723 .tm_isdst=0, 1723 .tm_isdst=0,
1724 .tm_gmtoff=0, 1724 .tm_gmtoff=0,
1725 .tm_zone="GMT" 1725 .tm_zone="UTC"
1726 }, 1726 },
1727 }, 1727 },
1728 { 1728 {
diff --git a/src/regress/lib/libcrypto/aes/aes_test.c b/src/regress/lib/libcrypto/aes/aes_test.c
index 37bee05ca7..8d5947a031 100644
--- a/src/regress/lib/libcrypto/aes/aes_test.c
+++ b/src/regress/lib/libcrypto/aes/aes_test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: aes_test.c,v 1.3 2023/09/28 08:21:43 tb Exp $ */ 1/* $OpenBSD: aes_test.c,v 1.5 2025/07/05 14:32:47 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Joshua Sing <joshua@hypera.dev> 3 * Copyright (c) 2022 Joshua Sing <joshua@hypera.dev>
4 * 4 *
@@ -524,6 +524,161 @@ static const struct aes_test aes_tests[] = {
524 }, 524 },
525 .out_len = 64, 525 .out_len = 64,
526 }, 526 },
527
528 /* XTS128 - Test vectors from NIST SP 800-38A */
529 {
530 /* XTSGenAES128 1 */
531 .mode = NID_aes_128_xts,
532 .key = {
533 0xa1, 0xb9, 0x0c, 0xba, 0x3f, 0x06, 0xac, 0x35,
534 0x3b, 0x2c, 0x34, 0x38, 0x76, 0x08, 0x17, 0x62,
535 0x09, 0x09, 0x23, 0x02, 0x6e, 0x91, 0x77, 0x18,
536 0x15, 0xf2, 0x9d, 0xab, 0x01, 0x93, 0x2f, 0x2f,
537 },
538 .iv = {
539 0x4f, 0xae, 0xf7, 0x11, 0x7c, 0xda, 0x59, 0xc6,
540 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5,
541 },
542 .iv_len = 16,
543 .in = {
544 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d,
545 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c,
546 },
547 .in_len = 16,
548 .out = {
549 0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a,
550 0x82, 0x50, 0x81, 0xd5, 0xbe, 0x47, 0x1c, 0x63,
551 },
552 .out_len = 16,
553 },
554 {
555 /* XTSGenAES128 385 */
556 .mode = NID_aes_128_xts,
557 .key = {
558 0xb8, 0xdb, 0x0b, 0x9e, 0x63, 0xf5, 0xf0, 0xe6,
559 0x60, 0x97, 0x98, 0xa6, 0xcb, 0x42, 0xbb, 0x5b,
560 0x5d, 0x71, 0x39, 0xbb, 0x95, 0x57, 0x99, 0xf5,
561 0x2a, 0x7c, 0x58, 0x1f, 0x84, 0x63, 0x31, 0x76,
562 },
563 .iv = {
564 0x8d, 0x46, 0xf9, 0x67, 0x01, 0x16, 0x7a, 0x1d,
565 0x77, 0xcd, 0x1e, 0x44, 0xda, 0x92, 0xf3, 0xa8,
566 },
567 .iv_len = 16,
568 .in = {
569 0xb4, 0x64, 0x4d, 0xc1, 0xb3, 0x8d, 0xd5, 0x98,
570 0xca, 0x84, 0x0a, 0x82, 0xd4, 0xd9, 0xc0, 0x65,
571 0x67, 0x23, 0xb1, 0x58, 0x01, 0xaa, 0x18, 0xe6,
572 0x6e,
573 },
574 .in_len = 25,
575 .out = {
576 0x09, 0x28, 0x8c, 0xf5, 0x1f, 0x1e, 0xb4, 0xad,
577 0xb8, 0x54, 0x23, 0xd0, 0xe0, 0xd6, 0xe9, 0x58,
578 0x18, 0x87, 0x06, 0xaf, 0x26, 0x0e, 0x24, 0x67,
579 0x4e,
580 },
581 .out_len = 25,
582 },
583 {
584 /* XTSGenAES128 404 */
585 .mode = NID_aes_128_xts,
586 .key = {
587 0xbe, 0x5c, 0xf1, 0xf9, 0x9d, 0x51, 0x59, 0xf2,
588 0x11, 0xdb, 0xc4, 0xc1, 0x47, 0xf7, 0x9c, 0x55,
589 0x6b, 0x2d, 0xa5, 0xc6, 0x91, 0xde, 0xed, 0x74,
590 0x0d, 0x01, 0x57, 0xea, 0xb8, 0xc9, 0xc8, 0x9a,
591 },
592 .iv = {
593 0x89, 0x24, 0x86, 0x24, 0xb6, 0x96, 0xcf, 0x9c,
594 0xb1, 0xb5, 0x77, 0x9c, 0xdc, 0xbc, 0xfe, 0x1c,
595 },
596 .iv_len = 16,
597 .in = {
598 0x3b, 0x80, 0xf8, 0x22, 0xc4, 0xee, 0xe1, 0x31,
599 0x3f, 0x79, 0xca, 0x3d, 0xb1, 0x34, 0xd9, 0xca,
600 0x8b, 0x09, 0xa3, 0x53, 0x4d, 0x4e, 0x18, 0xe6,
601 0x43, 0x9e, 0x1c, 0xdb, 0x86, 0x18, 0x2a, 0x4f,
602 },
603 .in_len = 32,
604 .out = {
605 0x4b, 0x6a, 0xf4, 0x3a, 0x88, 0xb6, 0x33, 0xeb,
606 0xd1, 0xe1, 0x27, 0xc1, 0xec, 0x90, 0xcc, 0x47,
607 0xa2, 0xf1, 0x6e, 0x3b, 0xc7, 0x9f, 0x88, 0x45,
608 0xe3, 0xbd, 0x00, 0x25, 0xda, 0x87, 0x26, 0x45,
609 },
610 .out_len = 32,
611 },
612 {
613 /* XTSGenAES256 1 */
614 .mode = NID_aes_256_xts,
615 .key = {
616 0x1e, 0xa6, 0x61, 0xc5, 0x8d, 0x94, 0x3a, 0x0e,
617 0x48, 0x01, 0xe4, 0x2f, 0x4b, 0x09, 0x47, 0x14,
618 0x9e, 0x7f, 0x9f, 0x8e, 0x3e, 0x68, 0xd0, 0xc7,
619 0x50, 0x52, 0x10, 0xbd, 0x31, 0x1a, 0x0e, 0x7c,
620 0xd6, 0xe1, 0x3f, 0xfd, 0xf2, 0x41, 0x8d, 0x8d,
621 0x19, 0x11, 0xc0, 0x04, 0xcd, 0xa5, 0x8d, 0xa3,
622 0xd6, 0x19, 0xb7, 0xe2, 0xb9, 0x14, 0x1e, 0x58,
623 0x31, 0x8e, 0xea, 0x39, 0x2c, 0xf4, 0x1b, 0x08,
624 },
625 .iv = {
626 0xad, 0xf8, 0xd9, 0x26, 0x27, 0x46, 0x4a, 0xd2,
627 0xf0, 0x42, 0x8e, 0x84, 0xa9, 0xf8, 0x75, 0x64,
628 },
629 .iv_len = 16,
630 .in = {
631 0x2e, 0xed, 0xea, 0x52, 0xcd, 0x82, 0x15, 0xe1,
632 0xac, 0xc6, 0x47, 0xe8, 0x10, 0xbb, 0xc3, 0x64,
633 0x2e, 0x87, 0x28, 0x7f, 0x8d, 0x2e, 0x57, 0xe3,
634 0x6c, 0x0a, 0x24, 0xfb, 0xc1, 0x2a, 0x20, 0x2e,
635 },
636 .in_len = 32,
637 .out = {
638 0xcb, 0xaa, 0xd0, 0xe2, 0xf6, 0xce, 0xa3, 0xf5,
639 0x0b, 0x37, 0xf9, 0x34, 0xd4, 0x6a, 0x9b, 0x13,
640 0x0b, 0x9d, 0x54, 0xf0, 0x7e, 0x34, 0xf3, 0x6a,
641 0xf7, 0x93, 0xe8, 0x6f, 0x73, 0xc6, 0xd7, 0xdb,
642 },
643 .out_len = 32,
644 },
645 {
646 /* XTSGenAES256 172 */
647 .mode = NID_aes_256_xts,
648 .key= {
649 0x5c, 0x7f, 0x7a, 0x36, 0x08, 0x01, 0x78, 0x43,
650 0x00, 0x83, 0xff, 0x54, 0x92, 0xef, 0x77, 0x26,
651 0x0f, 0x68, 0x0a, 0x15, 0xa7, 0x66, 0x24, 0xb8,
652 0x9e, 0x85, 0x4c, 0x94, 0xf0, 0x48, 0x8a, 0x9e,
653 0x7d, 0xaa, 0x4f, 0x33, 0x01, 0x1f, 0x91, 0xdf,
654 0x5e, 0x33, 0x80, 0x53, 0xf4, 0x6c, 0xee, 0x65,
655 0x0f, 0xb0, 0xee, 0x69, 0xf8, 0xc2, 0x15, 0x75,
656 0x5a, 0x4a, 0x63, 0xcd, 0x42, 0x28, 0xc2, 0x19,
657 },
658 .iv = {
659 0xa4, 0x01, 0xd7, 0x3c, 0x88, 0x75, 0xe7, 0x59,
660 0xaa, 0x3e, 0xef, 0x53, 0xe0, 0xfb, 0x62, 0x63,
661 },
662 .iv_len = 16,
663 .in = {
664 0xb1, 0xe6, 0x29, 0xa6, 0x2a, 0x03, 0xca, 0x96,
665 0x9b, 0x16, 0x91, 0x52, 0x02, 0xbc, 0xaa, 0x09,
666 0xe7, 0x8a, 0xe1, 0x85, 0x1b, 0xc8, 0x85, 0x81,
667 0x16, 0x49, 0x68, 0xa5, 0x65, 0x6c, 0x82, 0xc0,
668 0xe5, 0xc4, 0x03, 0xba, 0x54, 0xb9, 0xb5, 0xed,
669 0x9b, 0xab, 0xe8, 0xb0, 0x75, 0x1d, 0x1b, 0x34,
670 },
671 .in_len = 48,
672 .out = {
673 0xf5, 0xbc, 0xa6, 0x0f, 0xb9, 0x35, 0x2b, 0x1d,
674 0xe0, 0x4d, 0x71, 0x29, 0x40, 0x56, 0x26, 0xb3,
675 0xa4, 0x74, 0xa2, 0x64, 0xfb, 0xac, 0x2d, 0x6b,
676 0xe1, 0x19, 0xe1, 0xd5, 0x7a, 0xa9, 0x98, 0xd0,
677 0xe0, 0xe4, 0xd9, 0xf9, 0xc9, 0x76, 0x21, 0x0d,
678 0x93, 0xc4, 0x65, 0xa3, 0xe3, 0x60, 0xcd, 0x92,
679 },
680 .out_len = 48,
681 },
527}; 682};
528 683
529#define N_AES_TESTS (sizeof(aes_tests) / sizeof(aes_tests[0])) 684#define N_AES_TESTS (sizeof(aes_tests) / sizeof(aes_tests[0]))
@@ -542,7 +697,10 @@ aes_ecb_test(size_t test_number, const char *label, int key_bits,
542 697
543 /* Encryption */ 698 /* Encryption */
544 memset(out, 0, sizeof(out)); 699 memset(out, 0, sizeof(out));
545 AES_set_encrypt_key(at->key, key_bits, &key); 700 if (AES_set_encrypt_key(at->key, key_bits, &key) != 0) {
701 fprintf(stderr, "FAIL (%s:%zu): AES_set_encrypt_key failed\n", label, test_number);
702 return 0;
703 }
546 AES_ecb_encrypt(at->in, out, &key, 1); 704 AES_ecb_encrypt(at->in, out, &key, 1);
547 705
548 if (memcmp(at->out, out, at->out_len) != 0) { 706 if (memcmp(at->out, out, at->out_len) != 0) {
@@ -553,7 +711,10 @@ aes_ecb_test(size_t test_number, const char *label, int key_bits,
553 711
554 /* Decryption */ 712 /* Decryption */
555 memset(out, 0, sizeof(out)); 713 memset(out, 0, sizeof(out));
556 AES_set_decrypt_key(at->key, key_bits, &key); 714 if (AES_set_decrypt_key(at->key, key_bits, &key) != 0) {
715 fprintf(stderr, "FAIL (%s:%zu): AES_set_decrypt_key failed\n", label, test_number);
716 return 0;
717 }
557 AES_ecb_encrypt(at->out, out, &key, 0); 718 AES_ecb_encrypt(at->out, out, &key, 0);
558 719
559 if (memcmp(at->in, out, at->in_len) != 0) { 720 if (memcmp(at->in, out, at->in_len) != 0) {
@@ -582,7 +743,10 @@ aes_cbc_test(size_t test_number, const char *label, int key_bits,
582 /* Encryption */ 743 /* Encryption */
583 memset(out, 0, sizeof(out)); 744 memset(out, 0, sizeof(out));
584 memcpy(iv, at->iv, at->iv_len); 745 memcpy(iv, at->iv, at->iv_len);
585 AES_set_encrypt_key(at->key, key_bits, &key); 746 if (AES_set_encrypt_key(at->key, key_bits, &key) != 0) {
747 fprintf(stderr, "FAIL (%s:%zu): AES_set_encrypt_key failed\n", label, test_number);
748 return 0;
749 }
586 AES_cbc_encrypt(at->in, out, at->in_len, &key, iv, 1); 750 AES_cbc_encrypt(at->in, out, at->in_len, &key, iv, 1);
587 751
588 if (memcmp(at->out, out, at->out_len) != 0) { 752 if (memcmp(at->out, out, at->out_len) != 0) {
@@ -594,7 +758,10 @@ aes_cbc_test(size_t test_number, const char *label, int key_bits,
594 /* Decryption */ 758 /* Decryption */
595 memset(out, 0, sizeof(out)); 759 memset(out, 0, sizeof(out));
596 memcpy(iv, at->iv, at->iv_len); 760 memcpy(iv, at->iv, at->iv_len);
597 AES_set_decrypt_key(at->key, key_bits, &key); 761 if (AES_set_decrypt_key(at->key, key_bits, &key) != 0) {
762 fprintf(stderr, "FAIL (%s:%zu): AES_set_decrypt_key failed\n", label, test_number);
763 return 0;
764 }
598 AES_cbc_encrypt(at->out, out, at->out_len, &key, iv, 0); 765 AES_cbc_encrypt(at->out, out, at->out_len, &key, iv, 0);
599 766
600 if (memcmp(at->in, out, at->in_len) != 0) { 767 if (memcmp(at->in, out, at->in_len) != 0) {
@@ -607,6 +774,96 @@ aes_cbc_test(size_t test_number, const char *label, int key_bits,
607} 774}
608 775
609static int 776static int
777aes_cfb128_test(size_t test_number, const char *label, int key_bits,
778 const struct aes_test *at)
779{
780 AES_KEY key;
781 uint8_t out[64];
782 uint8_t iv[16];
783 int num = 0;
784
785 /* CFB mode has no padding */
786
787 /* Encryption */
788 memset(out, 0, sizeof(out));
789 memcpy(iv, at->iv, at->iv_len);
790 if (AES_set_encrypt_key(at->key, key_bits, &key) != 0) {
791 fprintf(stderr, "FAIL (%s:%zu): AES_set_encrypt_key failed\n", label, test_number);
792 return 0;
793 }
794 AES_cfb128_encrypt(at->in, out, at->in_len, &key, iv, &num, AES_ENCRYPT);
795
796 if (memcmp(at->out, out, at->out_len) != 0) {
797 fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n",
798 label, test_number);
799 return 0;
800 }
801
802 /* Decryption */
803 memset(out, 0, sizeof(out));
804 memcpy(iv, at->iv, at->iv_len);
805 num = 0;
806 if (AES_set_encrypt_key(at->key, key_bits, &key) != 0) {
807 fprintf(stderr, "FAIL (%s:%zu): AES_set_encrypt_key failed\n", label, test_number);
808 return 0;
809 }
810 AES_cfb128_encrypt(at->out, out, at->out_len, &key, iv, &num, AES_DECRYPT);
811
812 if (memcmp(at->in, out, at->in_len) != 0) {
813 fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n",
814 label, test_number);
815 return 0;
816 }
817
818 return 1;
819}
820
821static int
822aes_ofb128_test(size_t test_number, const char *label, int key_bits,
823 const struct aes_test *at)
824{
825 AES_KEY key;
826 uint8_t out[64];
827 uint8_t iv[16];
828 int num = 0;
829
830 /* OFB mode has no padding */
831
832 /* Encryption */
833 memset(out, 0, sizeof(out));
834 memcpy(iv, at->iv, at->iv_len);
835 if (AES_set_encrypt_key(at->key, key_bits, &key) != 0) {
836 fprintf(stderr, "FAIL (%s:%zu): AES_set_encrypt_key failed\n", label, test_number);
837 return 0;
838 }
839 AES_ofb128_encrypt(at->in, out, at->in_len, &key, iv, &num);
840
841 if (memcmp(at->out, out, at->out_len) != 0) {
842 fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n",
843 label, test_number);
844 return 0;
845 }
846
847 /* Decryption */
848 memset(out, 0, sizeof(out));
849 memcpy(iv, at->iv, at->iv_len);
850 num = 0;
851 if (AES_set_encrypt_key(at->key, key_bits, &key) != 0) {
852 fprintf(stderr, "FAIL (%s:%zu): AES_set_encrypt_key failed\n", label, test_number);
853 return 0;
854 }
855 AES_ofb128_encrypt(at->out, out, at->out_len, &key, iv, &num);
856
857 if (memcmp(at->in, out, at->in_len) != 0) {
858 fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n",
859 label, test_number);
860 return 0;
861 }
862
863 return 1;
864}
865
866static int
610aes_evp_test(size_t test_number, const struct aes_test *at, const char *label, 867aes_evp_test(size_t test_number, const struct aes_test *at, const char *label,
611 int key_bits, const EVP_CIPHER *cipher) 868 int key_bits, const EVP_CIPHER *cipher)
612{ 869{
@@ -649,6 +906,10 @@ aes_evp_test(size_t test_number, const struct aes_test *at, const char *label,
649 if (in_len > at->in_len - i) 906 if (in_len > at->in_len - i)
650 in_len = at->in_len - i; 907 in_len = at->in_len - i;
651 908
909 /* XTS needs to be single shot. */
910 if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_XTS_MODE)
911 in_len = at->in_len;
912
652 if (!EVP_EncryptUpdate(ctx, out + total_len, &out_len, 913 if (!EVP_EncryptUpdate(ctx, out + total_len, &out_len,
653 at->in + i, in_len)) { 914 at->in + i, in_len)) {
654 fprintf(stderr, 915 fprintf(stderr,
@@ -715,6 +976,10 @@ aes_evp_test(size_t test_number, const struct aes_test *at, const char *label,
715 if (in_len > at->out_len - i) 976 if (in_len > at->out_len - i)
716 in_len = at->out_len - i; 977 in_len = at->out_len - i;
717 978
979 /* XTS needs to be single shot. */
980 if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_XTS_MODE)
981 in_len = at->in_len;
982
718 if (!EVP_DecryptUpdate(ctx, out + total_len, &out_len, 983 if (!EVP_DecryptUpdate(ctx, out + total_len, &out_len,
719 at->out + i, in_len)) { 984 at->out + i, in_len)) {
720 fprintf(stderr, 985 fprintf(stderr,
@@ -881,6 +1146,16 @@ aes_cipher_from_nid(int nid, const char **out_label,
881 *out_cipher = EVP_aes_256_ccm(); 1146 *out_cipher = EVP_aes_256_ccm();
882 break; 1147 break;
883 1148
1149 /* XTS */
1150 case NID_aes_128_xts:
1151 *out_label = SN_aes_128_xts;
1152 *out_cipher = EVP_aes_128_xts();
1153 break;
1154 case NID_aes_256_xts:
1155 *out_label = SN_aes_256_xts;
1156 *out_cipher = EVP_aes_256_xts();
1157 break;
1158
884 /* Unknown */ 1159 /* Unknown */
885 default: 1160 default:
886 return 0; 1161 return 0;
@@ -902,8 +1177,10 @@ aes_test(void)
902 for (i = 0; i < N_AES_TESTS; i++) { 1177 for (i = 0; i < N_AES_TESTS; i++) {
903 at = &aes_tests[i]; 1178 at = &aes_tests[i];
904 key_bits = aes_key_bits_from_nid(at->mode); 1179 key_bits = aes_key_bits_from_nid(at->mode);
905 if (!aes_cipher_from_nid(at->mode, &label, &cipher)) 1180 if (!aes_cipher_from_nid(at->mode, &label, &cipher)) {
1181 fprintf(stderr, "unknown cipher\n");
906 goto failed; 1182 goto failed;
1183 }
907 1184
908 switch (at->mode) { 1185 switch (at->mode) {
909 /* ECB */ 1186 /* ECB */
@@ -926,14 +1203,16 @@ aes_test(void)
926 case NID_aes_128_cfb128: 1203 case NID_aes_128_cfb128:
927 case NID_aes_192_cfb128: 1204 case NID_aes_192_cfb128:
928 case NID_aes_256_cfb128: 1205 case NID_aes_256_cfb128:
929 /* XXX - CFB128 non-EVP tests */ 1206 if (!aes_cfb128_test(i, label, key_bits, at))
1207 goto failed;
930 break; 1208 break;
931 1209
932 /* OFB128 */ 1210 /* OFB128 */
933 case NID_aes_128_ofb128: 1211 case NID_aes_128_ofb128:
934 case NID_aes_192_ofb128: 1212 case NID_aes_192_ofb128:
935 case NID_aes_256_ofb128: 1213 case NID_aes_256_ofb128:
936 /* XXX - OFB128 non-EVP tests */ 1214 if (!aes_ofb128_test(i, label, key_bits, at))
1215 goto failed;
937 break; 1216 break;
938 1217
939 /* GCM */ 1218 /* GCM */
@@ -947,7 +1226,13 @@ aes_test(void)
947 case NID_aes_128_ccm: 1226 case NID_aes_128_ccm:
948 case NID_aes_192_ccm: 1227 case NID_aes_192_ccm:
949 case NID_aes_256_ccm: 1228 case NID_aes_256_ccm:
950 /* XXX - CCM non-EVP tests */ 1229 /* CCM is EVP-only */
1230 break;
1231
1232 /* XTS */
1233 case NID_aes_128_xts:
1234 case NID_aes_256_xts:
1235 /* XTS is EVP-only */
951 break; 1236 break;
952 1237
953 /* Unknown */ 1238 /* Unknown */
diff --git a/src/regress/lib/libcrypto/asn1/asn1time.c b/src/regress/lib/libcrypto/asn1/asn1time.c
index 7223ad9c9b..e0e5139808 100644
--- a/src/regress/lib/libcrypto/asn1/asn1time.c
+++ b/src/regress/lib/libcrypto/asn1/asn1time.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1time.c,v 1.30 2024/07/21 13:25:11 tb Exp $ */ 1/* $OpenBSD: asn1time.c,v 1.31 2025/05/22 04:54:14 joshua Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2024 Google Inc. 4 * Copyright (c) 2024 Google Inc.
@@ -33,6 +33,7 @@ struct asn1_time_test {
33 const char *data; 33 const char *data;
34 const unsigned char der[32]; 34 const unsigned char der[32];
35 time_t time; 35 time_t time;
36 int generalized_time;
36}; 37};
37 38
38static const struct asn1_time_test asn1_invtime_tests[] = { 39static const struct asn1_time_test asn1_invtime_tests[] = {
@@ -73,20 +74,19 @@ static const struct asn1_time_test asn1_invtime_tests[] = {
73 { 74 {
74 .str = "aaaaaaaaaaaaaaZ", 75 .str = "aaaaaaaaaaaaaaZ",
75 }, 76 },
76 /* utc time with omitted seconds, should fail */
77 { 77 {
78 /* UTC time with omitted seconds, should fail */
78 .str = "1609082343Z", 79 .str = "1609082343Z",
79 }, 80 },
80};
81
82static const struct asn1_time_test asn1_invgentime_tests[] = {
83 /* Generalized time with omitted seconds, should fail */
84 { 81 {
82 /* Generalized time with omitted seconds, should fail */
85 .str = "201612081934Z", 83 .str = "201612081934Z",
84 .generalized_time = 1,
86 }, 85 },
87 /* Valid UTC time, should fail as a generalized time */
88 { 86 {
87 /* Valid UTC time, should fail as a generalized time */
89 .str = "160908234300Z", 88 .str = "160908234300Z",
89 .generalized_time = 1,
90 }, 90 },
91}; 91};
92 92
@@ -235,7 +235,7 @@ asn1_compare_str(int test_no, const struct asn1_string_st *asn1str,
235} 235}
236 236
237static int 237static int
238asn1_invtime_test(int test_no, const struct asn1_time_test *att, int gen) 238asn1_invtime_test(int test_no, const struct asn1_time_test *att)
239{ 239{
240 ASN1_GENERALIZEDTIME *gt = NULL; 240 ASN1_GENERALIZEDTIME *gt = NULL;
241 ASN1_UTCTIME *ut = NULL; 241 ASN1_UTCTIME *ut = NULL;
@@ -255,7 +255,7 @@ asn1_invtime_test(int test_no, const struct asn1_time_test *att, int gen)
255 goto done; 255 goto done;
256 } 256 }
257 257
258 if (gen) { 258 if (att->generalized_time) {
259 failure = 0; 259 failure = 0;
260 goto done; 260 goto done;
261 } 261 }
@@ -842,13 +842,7 @@ main(int argc, char **argv)
842 fprintf(stderr, "Invalid time tests...\n"); 842 fprintf(stderr, "Invalid time tests...\n");
843 for (i = 0; i < N_INVTIME_TESTS; i++) { 843 for (i = 0; i < N_INVTIME_TESTS; i++) {
844 att = &asn1_invtime_tests[i]; 844 att = &asn1_invtime_tests[i];
845 failed |= asn1_invtime_test(i, att, 0); 845 failed |= asn1_invtime_test(i, att);
846 }
847
848 fprintf(stderr, "Invalid generalized time tests...\n");
849 for (i = 0; i < N_INVGENTIME_TESTS; i++) {
850 att = &asn1_invgentime_tests[i];
851 failed |= asn1_invtime_test(i, att, 1);
852 } 846 }
853 847
854 fprintf(stderr, "GENERALIZEDTIME tests...\n"); 848 fprintf(stderr, "GENERALIZEDTIME tests...\n");
diff --git a/src/regress/lib/libcrypto/bio/bio_dump.c b/src/regress/lib/libcrypto/bio/bio_dump.c
index 22db80fa3d..fd2bb285fb 100644
--- a/src/regress/lib/libcrypto/bio/bio_dump.c
+++ b/src/regress/lib/libcrypto/bio/bio_dump.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_dump.c,v 1.4 2024/02/09 12:48:32 tb Exp $ */ 1/* $OpenBSD: bio_dump.c,v 1.5 2025/05/18 06:41:51 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -809,7 +809,7 @@ bio_dump_test(const struct bio_dump_testcase *tc)
809 tc->indent, ret, got_len, strlen(tc->output)); 809 tc->indent, ret, got_len, strlen(tc->output));
810 goto err; 810 goto err;
811 } 811 }
812 if (strncmp(tc->output, got, got_len) != 0) { 812 if (got_len > 0 && strncmp(tc->output, got, got_len) != 0) {
813 fprintf(stderr, "%d: mismatch\n", tc->indent); 813 fprintf(stderr, "%d: mismatch\n", tc->indent);
814 goto err; 814 goto err;
815 } 815 }
diff --git a/src/regress/lib/libcrypto/bn/bn_mul_div.c b/src/regress/lib/libcrypto/bn/bn_mul_div.c
index 625d5e318e..dbad01004e 100644
--- a/src/regress/lib/libcrypto/bn/bn_mul_div.c
+++ b/src/regress/lib/libcrypto/bn/bn_mul_div.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mul_div.c,v 1.7 2023/06/21 07:18:10 jsing Exp $ */ 1/* $OpenBSD: bn_mul_div.c,v 1.8 2025/08/12 10:29:35 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -233,6 +233,13 @@ struct benchmark benchmarks[] = {
233 .b_bits = 256, 233 .b_bits = 256,
234 }, 234 },
235 { 235 {
236 .desc = "BN_mul (384 bit x 384 bit)",
237 .setup = benchmark_bn_mul_setup,
238 .run_once = benchmark_bn_mul_run_once,
239 .a_bits = 384,
240 .b_bits = 384,
241 },
242 {
236 .desc = "BN_mul (512 bit x 512 bit)", 243 .desc = "BN_mul (512 bit x 512 bit)",
237 .setup = benchmark_bn_mul_setup, 244 .setup = benchmark_bn_mul_setup,
238 .run_once = benchmark_bn_mul_run_once, 245 .run_once = benchmark_bn_mul_run_once,
@@ -294,6 +301,12 @@ struct benchmark benchmarks[] = {
294 .a_bits = 256, 301 .a_bits = 256,
295 }, 302 },
296 { 303 {
304 .desc = "BN_sqr (384 bit)",
305 .setup = benchmark_bn_sqr_setup,
306 .run_once = benchmark_bn_sqr_run_once,
307 .a_bits = 384,
308 },
309 {
297 .desc = "BN_sqr (512 bit)", 310 .desc = "BN_sqr (512 bit)",
298 .setup = benchmark_bn_sqr_setup, 311 .setup = benchmark_bn_sqr_setup,
299 .run_once = benchmark_bn_sqr_run_once, 312 .run_once = benchmark_bn_sqr_run_once,
diff --git a/src/regress/lib/libcrypto/c2sp/Makefile b/src/regress/lib/libcrypto/c2sp/Makefile
index d16d06975b..73ee0b8c22 100644
--- a/src/regress/lib/libcrypto/c2sp/Makefile
+++ b/src/regress/lib/libcrypto/c2sp/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.5 2025/04/27 08:51:24 tb Exp $ 1# $OpenBSD: Makefile,v 1.7 2025/07/23 07:35:21 tb Exp $
2 2
3C2SP_TESTVECTORS = /usr/local/share/c2sp-testvectors/ 3C2SP_TESTVECTORS = /usr/local/share/c2sp-testvectors/
4 4
@@ -13,12 +13,12 @@ PROGS += cctv
13SRCS_cctv = 13SRCS_cctv =
14 14
15cctv: cctv.go 15cctv: cctv.go
16 go build -o $@ ${.CURDIR}/cctv.go 16 env GOCACHE=${.OBJDIR}/go-build go build -o $@ ${.CURDIR}/cctv.go
17 17
18OSSL_LIB = /usr/local/lib/eopenssl 18OSSL_LIB = /usr/local/lib/eopenssl
19OSSL_INC = /usr/local/include/eopenssl 19OSSL_INC = /usr/local/include/eopenssl
20 20
21. for V in 33 34 35 21. for V in 35
22. if exists(/usr/local/bin/eopenssl$V) 22. if exists(/usr/local/bin/eopenssl$V)
23PROGS += cctv-openssl$V 23PROGS += cctv-openssl$V
24SRCS_cctv-openssl$V = 24SRCS_cctv-openssl$V =
@@ -29,10 +29,17 @@ CGO_LDFLAGS_$V += -L${OSSL_LIB}$V
29 29
30cctv-openssl$V: cctv.go 30cctv-openssl$V: cctv.go
31 env CGO_CFLAGS="${CGO_CFLAGS_$V}" CGO_LDFLAGS="${CGO_LDFLAGS_$V}" \ 31 env CGO_CFLAGS="${CGO_CFLAGS_$V}" CGO_LDFLAGS="${CGO_LDFLAGS_$V}" \
32 GOCACHE=${.OBJDIR}/go-build \
32 go build -o $@ ${.CURDIR}/cctv.go 33 go build -o $@ ${.CURDIR}/cctv.go
33. endif 34. endif
34. endfor 35. endfor
35 36
37REGRESS_CLEANUP = clean-go-cache
38
39clean-go-cache:
40 env GOCACHE=${.OBJDIR}/go-build go clean -cache
41 rm -rf ${.OBJDIR}/go-build
42
36.endif 43.endif
37 44
38.include <bsd.regress.mk> 45.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/certs/Makefile b/src/regress/lib/libcrypto/certs/Makefile
index 621c60907f..f7ba9fcad8 100644
--- a/src/regress/lib/libcrypto/certs/Makefile
+++ b/src/regress/lib/libcrypto/certs/Makefile
@@ -1,21 +1,24 @@
1# $OpenBSD: Makefile,v 1.1 2020/07/14 18:27:28 jsing Exp $ 1# $OpenBSD: Makefile,v 1.2 2025/07/09 05:04:35 tb Exp $
2 2
3.if ! (make(clean) || make(cleandir) || make(obj)) 3.if !exists(/usr/local/bin/go)
4GO_VERSION != sh -c "(go version) 2>/dev/null || true"
5.endif
6
7.if empty(GO_VERSION)
8regress: 4regress:
9 @echo package go is required for this regress 5 @echo package go is required for this regress
10 @echo SKIPPED 6 @echo SKIPPED
11.endif 7.else
12 8
13REGRESS_TARGETS=regress-go-verify 9REGRESS_TARGETS=regress-go-verify
10REGRESS_CLEANUP=clean-go-cache
14 11
15certs: 12certs:
16 cd ${.CURDIR} && sh ./make-certs.sh 13 cd ${.CURDIR} && sh ./make-certs.sh
17 14
18regress-go-verify: 15regress-go-verify:
19 cd ${.CURDIR} && go test -test.v . 16 cd ${.CURDIR} && env GOCACHE=${.OBJDIR}/go-build go test -test.v .
17
18clean-go-cache:
19 env GOCACHE=${.OBJDIR}/go-build go clean -cache
20 rm -rf ${.OBJDIR}/go-build
21
22.endif
20 23
21.include <bsd.regress.mk> 24.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/ec/Makefile b/src/regress/lib/libcrypto/ec/Makefile
index b21eacb4bc..1d976c77d0 100644
--- a/src/regress/lib/libcrypto/ec/Makefile
+++ b/src/regress/lib/libcrypto/ec/Makefile
@@ -1,12 +1,13 @@
1# $OpenBSD: Makefile,v 1.11 2025/03/08 20:09:35 tb Exp $ 1# $OpenBSD: Makefile,v 1.13 2025/08/03 08:29:39 jsing Exp $
2 2
3.ifdef EOPENSSL33 3.ifdef EOPENSSL35
4LDADD += -Wl,-rpath,/usr/local/lib/eopenssl33 -L/usr/local/lib/eopenssl33 4LDADD += -Wl,-rpath,/usr/local/lib/eopenssl35 -L/usr/local/lib/eopenssl35
5CFLAGS += -I/usr/local/include/eopenssl33/ 5CFLAGS += -I/usr/local/include/eopenssl35/
6CFLAGS += -DOPENSSL_SUPPRESS_DEPRECATED 6CFLAGS += -DOPENSSL_SUPPRESS_DEPRECATED
7.endif 7.endif
8 8
9PROGS += ectest 9PROGS += ectest
10PROGS += ec_arithmetic
10PROGS += ec_asn1_test 11PROGS += ec_asn1_test
11PROGS += ec_point_conversion 12PROGS += ec_point_conversion
12 13
diff --git a/src/regress/lib/libcrypto/ec/ec_arithmetic.c b/src/regress/lib/libcrypto/ec/ec_arithmetic.c
new file mode 100644
index 0000000000..c6f7cd4f8c
--- /dev/null
+++ b/src/regress/lib/libcrypto/ec/ec_arithmetic.c
@@ -0,0 +1,210 @@
1/* $OpenBSD: ec_arithmetic.c,v 1.1 2025/08/03 08:29:39 jsing Exp $ */
2/*
3 * Copyright (c) 2022,2025 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <sys/time.h>
19
20#include <err.h>
21#include <signal.h>
22#include <stdio.h>
23#include <string.h>
24#include <time.h>
25#include <unistd.h>
26
27#include <openssl/bn.h>
28#include <openssl/ec.h>
29#include <openssl/objects.h>
30
31static void
32benchmark_ec_point_add(const EC_GROUP *group, EC_POINT *result,
33 const BIGNUM *scalar, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
34{
35 if (!EC_POINT_add(group, result, a, b, ctx))
36 errx(1, "EC_POINT_add");
37}
38
39static void
40benchmark_ec_point_dbl(const EC_GROUP *group, EC_POINT *result,
41 const BIGNUM *scalar, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
42{
43 if (!EC_POINT_dbl(group, result, a, ctx))
44 errx(1, "EC_POINT_dbl");
45}
46
47static void
48benchmark_ec_point_mul_generator(const EC_GROUP *group, EC_POINT *result,
49 const BIGNUM *scalar, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
50{
51 if (!EC_POINT_mul(group, result, scalar, NULL, NULL, ctx))
52 errx(1, "EC_POINT_mul");
53}
54
55struct benchmark {
56 int curve;
57 const char *desc;
58 void (*func)(const EC_GROUP *, EC_POINT *, const BIGNUM *,
59 const EC_POINT *, const EC_POINT *, BN_CTX *);
60};
61
62static const struct benchmark benchmarks[] = {
63 {
64 .curve = NID_X9_62_prime256v1,
65 .desc = "EC_POINT_add() p256",
66 .func = benchmark_ec_point_add,
67 },
68 {
69 .curve = NID_secp384r1,
70 .desc = "EC_POINT_add() p384",
71 .func = benchmark_ec_point_add,
72 },
73 {
74 .curve = NID_secp521r1,
75 .desc = "EC_POINT_add() p521",
76 .func = benchmark_ec_point_add,
77 },
78 {
79 .curve = NID_X9_62_prime256v1,
80 .desc = "EC_POINT_dbl() p256",
81 .func = benchmark_ec_point_dbl,
82 },
83 {
84 .curve = NID_secp384r1,
85 .desc = "EC_POINT_dbl() p384",
86 .func = benchmark_ec_point_dbl,
87 },
88 {
89 .curve = NID_secp521r1,
90 .desc = "EC_POINT_dbl() p521",
91 .func = benchmark_ec_point_dbl,
92 },
93 {
94 .curve = NID_X9_62_prime256v1,
95 .desc = "EC_POINT_mul() generator p256",
96 .func = benchmark_ec_point_mul_generator,
97 },
98 {
99 .curve = NID_secp384r1,
100 .desc = "EC_POINT_mul() generator p384",
101 .func = benchmark_ec_point_mul_generator,
102 },
103 {
104 .curve = NID_secp521r1,
105 .desc = "EC_POINT_mul() generator p521",
106 .func = benchmark_ec_point_mul_generator,
107 },
108};
109
110#define N_BENCHMARKS (sizeof(benchmarks) / sizeof(benchmarks[0]))
111
112static volatile sig_atomic_t benchmark_stop;
113
114static void
115benchmark_sig_alarm(int sig)
116{
117 benchmark_stop = 1;
118}
119
120static void
121benchmark_run(const struct benchmark *bm, int seconds)
122{
123 struct timespec start, end, duration;
124 EC_GROUP *group = NULL;
125 EC_POINT *a = NULL, *b = NULL, *result = NULL;
126 BIGNUM *order = NULL, *scalar = NULL;
127 BN_CTX *ctx = NULL;
128 int i;
129
130 signal(SIGALRM, benchmark_sig_alarm);
131
132 if ((ctx = BN_CTX_new()) == NULL)
133 errx(1, "BN_CTX_new");
134
135 if ((group = EC_GROUP_new_by_curve_name(bm->curve)) == NULL)
136 errx(1, "EC_GROUP_new_by_curve_name");
137 if ((order = BN_new()) == NULL)
138 errx(1, "BN_new");
139 if (!EC_GROUP_get_order(group, order, ctx))
140 errx(1, "EC_GROUP_get_order");
141
142 if ((scalar = BN_new()) == NULL)
143 errx(1, "BN_new");
144 if (!BN_rand_range(scalar, order))
145 errx(1, "BN_rand_range");
146 if (!BN_set_bit(scalar, EC_GROUP_order_bits(group) - 1))
147 errx(1, "BN_set_bit");
148
149 if ((result = EC_POINT_new(group)) == NULL)
150 errx(1, "EC_POINT_new");
151 if ((a = EC_POINT_new(group)) == NULL)
152 errx(1, "EC_POINT_new");
153 if ((b = EC_POINT_new(group)) == NULL)
154 errx(1, "EC_POINT_new");
155
156 if (!EC_POINT_mul(group, a, scalar, NULL, NULL, ctx))
157 errx(1, "EC_POINT_mul");
158 if (!EC_POINT_mul(group, b, scalar, NULL, NULL, ctx))
159 errx(1, "EC_POINT_mul");
160
161 benchmark_stop = 0;
162 i = 0;
163 alarm(seconds);
164
165 clock_gettime(CLOCK_MONOTONIC, &start);
166
167 fprintf(stderr, "Benchmarking %s for %ds: ", bm->desc, seconds);
168 while (!benchmark_stop) {
169 bm->func(group, result, scalar, a, b, ctx);
170 i++;
171 }
172 clock_gettime(CLOCK_MONOTONIC, &end);
173 timespecsub(&end, &start, &duration);
174 fprintf(stderr, "%d iterations in %f seconds\n", i,
175 duration.tv_sec + duration.tv_nsec / 1000000000.0);
176
177 EC_GROUP_free(group);
178 EC_POINT_free(result);
179 EC_POINT_free(a);
180 EC_POINT_free(b);
181 BN_free(order);
182 BN_free(scalar);
183 BN_CTX_free(ctx);
184}
185
186static void
187benchmark_ec_mul_single(void)
188{
189 const struct benchmark *bm;
190 size_t i;
191
192 for (i = 0; i < N_BENCHMARKS; i++) {
193 bm = &benchmarks[i];
194 benchmark_run(bm, 5);
195 }
196}
197
198int
199main(int argc, char **argv)
200{
201 int benchmark = 0, failed = 0;
202
203 if (argc == 2 && strcmp(argv[1], "--benchmark") == 0)
204 benchmark = 1;
205
206 if (benchmark && !failed)
207 benchmark_ec_mul_single();
208
209 return failed;
210}
diff --git a/src/regress/lib/libcrypto/ec/ec_asn1_test.c b/src/regress/lib/libcrypto/ec/ec_asn1_test.c
index 03358e69ca..50e6304baf 100644
--- a/src/regress/lib/libcrypto/ec/ec_asn1_test.c
+++ b/src/regress/lib/libcrypto/ec/ec_asn1_test.c
@@ -1,7 +1,7 @@
1/* $OpenBSD: ec_asn1_test.c,v 1.32 2025/03/08 20:09:35 tb Exp $ */ 1/* $OpenBSD: ec_asn1_test.c,v 1.36 2025/07/23 07:42:33 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2024, 2025 Theo Buehler <tb@openbsd.org>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -17,12 +17,17 @@
17 */ 17 */
18 18
19#include <err.h> 19#include <err.h>
20#include <stdio.h>
21#include <stdint.h>
22#include <stdlib.h>
20#include <string.h> 23#include <string.h>
21 24
22#include <openssl/bio.h> 25#include <openssl/bio.h>
26#include <openssl/bn.h>
23#include <openssl/ec.h> 27#include <openssl/ec.h>
24#include <openssl/err.h> 28#include <openssl/err.h>
25#include <openssl/objects.h> 29#include <openssl/objects.h>
30#include <openssl/sha.h>
26 31
27#include "ec_local.h" 32#include "ec_local.h"
28 33
@@ -1281,126 +1286,6 @@ static const struct ec_private_key {
1281 }, 1286 },
1282 }, 1287 },
1283 { 1288 {
1284 .name = "prime239v1",
1285 .der_len = 115,
1286 .der = {
1287 0x30, 0x71, 0x02, 0x01, 0x01, 0x04, 0x1e, 0x6e,
1288 0x26, 0x5e, 0xde, 0x5b, 0x67, 0xd6, 0x38, 0x52,
1289 0xe7, 0x1e, 0x8d, 0x44, 0xb1, 0xfb, 0xf8, 0xaf,
1290 0xf9, 0x94, 0x2c, 0xe2, 0x0d, 0xa8, 0x5f, 0x03,
1291 0x67, 0x53, 0x7b, 0x8b, 0x2e, 0xa0, 0x0a, 0x06,
1292 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01,
1293 0x04, 0xa1, 0x40, 0x03, 0x3e, 0x00, 0x04, 0x33,
1294 0xc6, 0xe5, 0x8a, 0xc1, 0x8b, 0x7c, 0x96, 0x19,
1295 0xc9, 0xe1, 0x54, 0x7f, 0x81, 0x9e, 0x59, 0x62,
1296 0xec, 0xc0, 0x1e, 0xe5, 0x53, 0xd5, 0xae, 0x6b,
1297 0xd3, 0xe0, 0x09, 0x07, 0xc5, 0x27, 0x81, 0xa6,
1298 0x8d, 0x39, 0x8e, 0xfe, 0x01, 0xc2, 0x1d, 0xda,
1299 0xde, 0x7b, 0xdc, 0x76, 0x27, 0x17, 0xf9, 0x6f,
1300 0xe3, 0x04, 0xef, 0x5d, 0x65, 0x75, 0x98, 0x7f,
1301 0x2d, 0xd0, 0x68,
1302 },
1303 .hex = "0433C6E58AC18B7C"
1304 "9619C9E1547F819E"
1305 "5962ECC01EE553D5"
1306 "AE6BD3E00907C527"
1307 "81A68D398EFE01C2"
1308 "1DDADE7BDC762717"
1309 "F96FE304EF5D6575"
1310 "987F2DD068",
1311 .oct_len = 61,
1312 .oct = {
1313 0x04, 0x33, 0xc6, 0xe5, 0x8a, 0xc1, 0x8b, 0x7c,
1314 0x96, 0x19, 0xc9, 0xe1, 0x54, 0x7f, 0x81, 0x9e,
1315 0x59, 0x62, 0xec, 0xc0, 0x1e, 0xe5, 0x53, 0xd5,
1316 0xae, 0x6b, 0xd3, 0xe0, 0x09, 0x07, 0xc5, 0x27,
1317 0x81, 0xa6, 0x8d, 0x39, 0x8e, 0xfe, 0x01, 0xc2,
1318 0x1d, 0xda, 0xde, 0x7b, 0xdc, 0x76, 0x27, 0x17,
1319 0xf9, 0x6f, 0xe3, 0x04, 0xef, 0x5d, 0x65, 0x75,
1320 0x98, 0x7f, 0x2d, 0xd0, 0x68,
1321 },
1322 },
1323 {
1324 .name = "prime239v2",
1325 .der_len = 115,
1326 .der = {
1327 0x30, 0x71, 0x02, 0x01, 0x01, 0x04, 0x1e, 0x30,
1328 0x2f, 0x01, 0x10, 0xe9, 0x09, 0x15, 0xdd, 0xe3,
1329 0xdd, 0xae, 0xcb, 0x9d, 0x3a, 0x58, 0x92, 0x02,
1330 0x1e, 0x6e, 0x02, 0x57, 0xa8, 0x36, 0x0b, 0x20,
1331 0x0b, 0x7e, 0xf4, 0xad, 0x0b, 0xa0, 0x0a, 0x06,
1332 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01,
1333 0x05, 0xa1, 0x40, 0x03, 0x3e, 0x00, 0x04, 0x3c,
1334 0x10, 0x27, 0x7b, 0xac, 0xdf, 0x86, 0xc9, 0x4f,
1335 0xf8, 0x39, 0x87, 0x02, 0x39, 0xaf, 0x41, 0xbc,
1336 0x4b, 0x67, 0xd8, 0x5e, 0x04, 0x96, 0x84, 0xb5,
1337 0x60, 0x50, 0x48, 0x6a, 0x20, 0x1d, 0x2b, 0x7e,
1338 0x9f, 0xaf, 0xf8, 0x8e, 0x7e, 0xa4, 0xcd, 0x00,
1339 0xad, 0xb1, 0xad, 0x22, 0x69, 0x32, 0x10, 0x6c,
1340 0xe0, 0xcc, 0xdd, 0x45, 0xd8, 0xa6, 0x29, 0x2f,
1341 0xad, 0x6b, 0xf9,
1342 },
1343 .hex = "043C10277BACDF86"
1344 "C94FF839870239AF"
1345 "41BC4B67D85E0496"
1346 "84B56050486A201D"
1347 "2B7E9FAFF88E7EA4"
1348 "CD00ADB1AD226932"
1349 "106CE0CCDD45D8A6"
1350 "292FAD6BF9",
1351 .oct_len = 61,
1352 .oct = {
1353 0x04, 0x3c, 0x10, 0x27, 0x7b, 0xac, 0xdf, 0x86,
1354 0xc9, 0x4f, 0xf8, 0x39, 0x87, 0x02, 0x39, 0xaf,
1355 0x41, 0xbc, 0x4b, 0x67, 0xd8, 0x5e, 0x04, 0x96,
1356 0x84, 0xb5, 0x60, 0x50, 0x48, 0x6a, 0x20, 0x1d,
1357 0x2b, 0x7e, 0x9f, 0xaf, 0xf8, 0x8e, 0x7e, 0xa4,
1358 0xcd, 0x00, 0xad, 0xb1, 0xad, 0x22, 0x69, 0x32,
1359 0x10, 0x6c, 0xe0, 0xcc, 0xdd, 0x45, 0xd8, 0xa6,
1360 0x29, 0x2f, 0xad, 0x6b, 0xf9,
1361 },
1362 },
1363 {
1364 .name = "prime239v3",
1365 .der_len = 115,
1366 .der = {
1367 0x30, 0x71, 0x02, 0x01, 0x01, 0x04, 0x1e, 0x26,
1368 0x3f, 0x23, 0x4c, 0xe7, 0xbd, 0xa8, 0xe4, 0xfe,
1369 0x7c, 0xf6, 0x18, 0x6a, 0xb2, 0xa6, 0x39, 0x15,
1370 0x6d, 0x72, 0xe8, 0x9e, 0x3f, 0x0f, 0x10, 0x1e,
1371 0xe5, 0xdf, 0xac, 0xe8, 0x2f, 0xa0, 0x0a, 0x06,
1372 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01,
1373 0x06, 0xa1, 0x40, 0x03, 0x3e, 0x00, 0x04, 0x37,
1374 0xba, 0x07, 0x7f, 0xd9, 0x46, 0x5a, 0x33, 0x03,
1375 0x31, 0x77, 0x38, 0xef, 0xee, 0xcc, 0x3d, 0xe1,
1376 0xaa, 0x57, 0xe3, 0x8d, 0xb7, 0xcd, 0xe3, 0x01,
1377 0xf4, 0xd6, 0x75, 0x49, 0x72, 0x61, 0x4c, 0xbf,
1378 0xc0, 0x1f, 0x8b, 0x5f, 0x98, 0x9b, 0xa7, 0xe5,
1379 0x6a, 0xb7, 0xfe, 0x63, 0xdb, 0xb0, 0x40, 0xcb,
1380 0x26, 0x81, 0x2a, 0x91, 0x14, 0x0f, 0xc7, 0x31,
1381 0x13, 0x78, 0x16,
1382 },
1383 .hex = "0437BA077FD9465A"
1384 "3303317738EFEECC"
1385 "3DE1AA57E38DB7CD"
1386 "E301F4D675497261"
1387 "4CBFC01F8B5F989B"
1388 "A7E56AB7FE63DBB0"
1389 "40CB26812A91140F"
1390 "C731137816",
1391 .oct_len = 61,
1392 .oct = {
1393 0x04, 0x37, 0xba, 0x07, 0x7f, 0xd9, 0x46, 0x5a,
1394 0x33, 0x03, 0x31, 0x77, 0x38, 0xef, 0xee, 0xcc,
1395 0x3d, 0xe1, 0xaa, 0x57, 0xe3, 0x8d, 0xb7, 0xcd,
1396 0xe3, 0x01, 0xf4, 0xd6, 0x75, 0x49, 0x72, 0x61,
1397 0x4c, 0xbf, 0xc0, 0x1f, 0x8b, 0x5f, 0x98, 0x9b,
1398 0xa7, 0xe5, 0x6a, 0xb7, 0xfe, 0x63, 0xdb, 0xb0,
1399 0x40, 0xcb, 0x26, 0x81, 0x2a, 0x91, 0x14, 0x0f,
1400 0xc7, 0x31, 0x13, 0x78, 0x16,
1401 },
1402 },
1403 {
1404 .name = "prime256v1", 1289 .name = "prime256v1",
1405 .der_len = 121, 1290 .der_len = 121,
1406 .der = { 1291 .der = {
@@ -2468,6 +2353,197 @@ ec_group_check_private_keys(void)
2468 return failed; 2353 return failed;
2469} 2354}
2470 2355
2356static void
2357ec_group_sha1_bignum(BIGNUM *out, const BIGNUM *in)
2358{
2359 char md[SHA_DIGEST_LENGTH];
2360 unsigned char *bin;
2361 size_t bin_len;
2362
2363 if (BN_num_bytes(in) <= 0)
2364 errx(1, "%s: invalid bignum", __func__);
2365
2366 bin_len = BN_num_bytes(in);
2367 if ((bin = calloc(1, bin_len)) == NULL)
2368 err(1, "calloc");
2369 if (BN_bn2bin(in, bin) <= 0)
2370 errx(1, "BN_bn2bin");
2371
2372 SHA1(bin, bin_len, md);
2373 free(bin);
2374
2375 if (BN_bin2bn(md, sizeof(md), out) == NULL)
2376 errx(1, "BN_bin2bn");
2377}
2378
2379static int
2380ec_group_check_seed(const EC_builtin_curve *curve, BN_CTX *ctx)
2381{
2382 EC_GROUP *group = NULL;
2383 BIGNUM *p, *a, *b, *pow2, *r, *seed_bn, *w;
2384 const unsigned char *seed;
2385 size_t seed_len;
2386 int i, g, h, s, t;
2387 int failed = 1;
2388
2389 if ((group = EC_GROUP_new_by_curve_name(curve->nid)) == NULL)
2390 errx(1, "EC_GROUP_new_by_curve_name");
2391
2392 BN_CTX_start(ctx);
2393
2394 if ((p = BN_CTX_get(ctx)) == NULL)
2395 errx(1, "p = BN_CTX_get()");
2396 if ((a = BN_CTX_get(ctx)) == NULL)
2397 errx(1, "a = BN_CTX_get()");
2398 if ((b = BN_CTX_get(ctx)) == NULL)
2399 errx(1, "b = BN_CTX_get()");
2400 if ((r = BN_CTX_get(ctx)) == NULL)
2401 errx(1, "r = BN_CTX_get()");
2402 if ((pow2 = BN_CTX_get(ctx)) == NULL)
2403 errx(1, "pow2 = BN_CTX_get()");
2404 if ((seed_bn = BN_CTX_get(ctx)) == NULL)
2405 errx(1, "seed_bn = BN_CTX_get()");
2406 if ((w = BN_CTX_get(ctx)) == NULL)
2407 errx(1, "w = BN_CTX_get()");
2408
2409 /*
2410 * If the curve has a seed, verify that its parameters a and b have
2411 * been selected using that seed, loosely following X9.62, F.3.4.b.
2412 * Otherwise there's nothing to do.
2413 */
2414 if ((seed = EC_GROUP_get0_seed(group)) == NULL)
2415 goto done;
2416 seed_len = EC_GROUP_get_seed_len(group);
2417
2418 /*
2419 * This isn't a requirement but happens to be the case for NIST
2420 * curves - the only built-in curves that have a seed.
2421 */
2422 if (seed_len != SHA_DIGEST_LENGTH) {
2423 fprintf(stderr, "%s FAIL: unexpected seed length. "
2424 "want %d, got %zu\n", __func__, SHA_DIGEST_LENGTH, seed_len);
2425 goto err;
2426 }
2427
2428 /* Seed length in bits, per F.3.3.b. */
2429 g = 8 * seed_len;
2430
2431 /*
2432 * Prepare to build the verifiably random element r of GFp by
2433 * concatenating the SHA-1 of modifications of the seed as a number.
2434 */
2435 if (BN_bin2bn(seed, seed_len, seed_bn) == NULL)
2436 errx(1, "BN_bin2bn");
2437
2438 if (!EC_GROUP_get_curve(group, p, a, b, ctx))
2439 errx(1, "EC_GROUP_get_curve");
2440
2441 t = BN_num_bits(p); /* bit length needed. */
2442 s = (t - 1) / 160; /* number of SHA-1 fitting in bit length. */
2443 h = t - 160 * s; /* remaining number of bits in r. */
2444
2445 /*
2446 * Steps 1 - 3: compute hash of the seed and take h - 1 rightmost bits.
2447 */
2448
2449 ec_group_sha1_bignum(r, seed_bn);
2450 BN_zero(pow2);
2451 if (!BN_set_bit(pow2, h - 1))
2452 errx(1, "BN_set_bit");
2453 if (!BN_mod(r, r, pow2, ctx))
2454 errx(1, "BN_nnmod");
2455
2456 /*
2457 * Steps 4 - 6: for i from 1 to s do Wi = SHA-1(SEED + i mod 2^g),
2458 * With W0 = r as already computed, let r = W0 || W1 || ... || Ws.
2459 */
2460
2461 BN_zero(pow2);
2462 if (!BN_set_bit(pow2, g))
2463 errx(1, "BN_set_bit");
2464
2465 for (i = 0; i < s; i++) {
2466 /*
2467 * This is a bit silly since the seed isn't going to have all
2468 * its bits set, so BN_add_word(seed_bn, 1) would do, but for
2469 * the sake of correctness...
2470 */
2471 if (!BN_mod_add(seed_bn, seed_bn, BN_value_one(), pow2, ctx))
2472 errx(1, "BN_mod_add");
2473
2474 ec_group_sha1_bignum(w, seed_bn);
2475
2476 if (!BN_lshift(r, r, 8 * SHA_DIGEST_LENGTH))
2477 errx(1, "BN_lshift");
2478 if (!BN_add(r, r, w))
2479 errx(1, "BN_add");
2480 }
2481
2482 /*
2483 * Step 7: check that r * b^2 == a^3 (mod p)
2484 */
2485
2486 /* Compute r = r * b^2 (mod p). */
2487 if (!BN_mod_sqr(b, b, p, ctx))
2488 errx(1, "BN_mod_sqr");
2489 if (!BN_mod_mul(r, r, b, p, ctx))
2490 errx(1, "BN_mod_mul");
2491
2492 /* Compute a = a^3 (mod p). */
2493 if (!BN_mod_sqr(b, a, p, ctx))
2494 errx(1, "BN_mod_sqr");
2495 if (!BN_mod_mul(a, a, b, p, ctx))
2496 errx(1, "BN_mod_mul");
2497
2498 /*
2499 * XXX - this assumes that a, b, p >= 0, so the results are in [0, p).
2500 * This is currently enforced in the EC code.
2501 */
2502 if (BN_cmp(r, a) != 0) {
2503 fprintf(stderr, "FAIL: %s verification failed for %s\nr * b^2:\t",
2504 __func__, curve->comment);
2505 BN_print_fp(stderr, r);
2506 fprintf(stderr, "\na^3:\t\t");
2507 BN_print_fp(stderr, a);
2508 fprintf(stderr, "\n");
2509 goto err;
2510 }
2511
2512 done:
2513 failed = 0;
2514
2515 err:
2516 BN_CTX_end(ctx);
2517 EC_GROUP_free(group);
2518
2519 return failed;
2520}
2521
2522static int
2523ec_group_check_seeds(void)
2524{
2525 BN_CTX *ctx = NULL;
2526 EC_builtin_curve *all_curves = NULL;
2527 size_t curve_id, ncurves;
2528 int failed = 0;
2529
2530 if ((ctx = BN_CTX_new()) == NULL)
2531 errx(1, "BN_CTX_new");
2532
2533 ncurves = EC_get_builtin_curves(NULL, 0);
2534 if ((all_curves = calloc(ncurves, sizeof(*all_curves))) == NULL)
2535 err(1, "calloc builtin curves");
2536 EC_get_builtin_curves(all_curves, ncurves);
2537
2538 for (curve_id = 0; curve_id < ncurves; curve_id++)
2539 failed |= ec_group_check_seed(&all_curves[curve_id], ctx);
2540
2541 free(all_curves);
2542 BN_CTX_free(ctx);
2543
2544 return failed;
2545}
2546
2471int 2547int
2472main(int argc, char **argv) 2548main(int argc, char **argv)
2473{ 2549{
@@ -2479,6 +2555,7 @@ main(int argc, char **argv)
2479 failed |= ec_group_roundtrip_builtin_curves(); 2555 failed |= ec_group_roundtrip_builtin_curves();
2480 failed |= ec_group_non_builtin_curves(); 2556 failed |= ec_group_non_builtin_curves();
2481 failed |= ec_group_check_private_keys(); 2557 failed |= ec_group_check_private_keys();
2558 failed |= ec_group_check_seeds();
2482 2559
2483 return failed; 2560 return failed;
2484} 2561}
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c
index fc44f9c886..3e81954174 100644
--- a/src/regress/lib/libcrypto/ec/ectest.c
+++ b/src/regress/lib/libcrypto/ec/ectest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ectest.c,v 1.35 2025/01/24 11:49:13 tb Exp $ */ 1/* $OpenBSD: ectest.c,v 1.36 2025/07/23 07:40:07 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -71,14 +71,11 @@
71 71
72#include <stdio.h> 72#include <stdio.h>
73#include <stdlib.h> 73#include <stdlib.h>
74#include <string.h>
75#include <time.h>
76 74
75#include <openssl/bn.h>
76#include <openssl/crypto.h>
77#include <openssl/ec.h> 77#include <openssl/ec.h>
78#include <openssl/err.h> 78#include <openssl/err.h>
79#include <openssl/obj_mac.h>
80#include <openssl/objects.h>
81#include <openssl/bn.h>
82#include <openssl/opensslconf.h> 79#include <openssl/opensslconf.h>
83 80
84#define ABORT do { \ 81#define ABORT do { \
diff --git a/src/regress/lib/libcrypto/evp/evp_pkey_cleanup.c b/src/regress/lib/libcrypto/evp/evp_pkey_cleanup.c
index d4825f68e8..1d2fa60be7 100644
--- a/src/regress/lib/libcrypto/evp/evp_pkey_cleanup.c
+++ b/src/regress/lib/libcrypto/evp/evp_pkey_cleanup.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_pkey_cleanup.c,v 1.5 2024/02/29 20:02:00 tb Exp $ */ 1/* $OpenBSD: evp_pkey_cleanup.c,v 1.6 2025/05/21 03:53:20 kenjiro Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
@@ -38,6 +38,8 @@ int pkey_ids[] = {
38 EVP_PKEY_RSA, 38 EVP_PKEY_RSA,
39 EVP_PKEY_RSA_PSS, 39 EVP_PKEY_RSA_PSS,
40 EVP_PKEY_X25519, 40 EVP_PKEY_X25519,
41 EVP_PKEY_HKDF,
42 EVP_PKEY_TLS1_PRF,
41}; 43};
42 44
43static const size_t N_PKEY_IDS = sizeof(pkey_ids) / sizeof(pkey_ids[0]); 45static const size_t N_PKEY_IDS = sizeof(pkey_ids) / sizeof(pkey_ids[0]);
diff --git a/src/regress/lib/libcrypto/evp/evp_test.c b/src/regress/lib/libcrypto/evp/evp_test.c
index a699832c45..0bd8b4d092 100644
--- a/src/regress/lib/libcrypto/evp/evp_test.c
+++ b/src/regress/lib/libcrypto/evp/evp_test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_test.c,v 1.20 2024/07/09 17:24:12 tb Exp $ */ 1/* $OpenBSD: evp_test.c,v 1.21 2025/05/22 00:13:47 kenjiro Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2022 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017, 2022 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2023, 2024 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2023, 2024 Theo Buehler <tb@openbsd.org>
@@ -802,6 +802,85 @@ kdf_compare_bytes(const char *label, const unsigned char *d1, int len1,
802} 802}
803 803
804static int 804static int
805evp_kdf_hkdf_basic(void)
806{
807 EVP_PKEY_CTX *pctx;
808 unsigned char out[42];
809 size_t outlen = sizeof(out);
810 int failed = 1;
811
812 /* Test vector from RFC 5869, Appendix A.1. */
813 const unsigned char ikm[] = {
814 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
815 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
816 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
817 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
818 0x0b, 0x0b,
819 };
820 const unsigned char salt[] = {
821 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
822 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
823 0x0c,
824 };
825 const unsigned char info[] = {
826 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
827 0xf6, 0xf7, 0xf8, 0xf9,
828 };
829 const unsigned char expected[42] = {
830 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a,
831 0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a,
832 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c,
833 0x5d, 0xb0, 0x2d, 0x56, 0xec, 0xc4, 0xc5, 0xbf,
834 0x34, 0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18,
835 0x58, 0x65,
836 };
837
838 if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)) == NULL) {
839 fprintf(stderr, "FAIL: EVP_PKEY_CTX_new_id\n");
840 goto err;
841 }
842
843 if (EVP_PKEY_derive_init(pctx) <= 0) {
844 fprintf(stderr, "FAIL: EVP_PKEY_derive_init\n");
845 goto err;
846 }
847
848 if (EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256()) <= 0) {
849 fprintf(stderr, "FAIL: EVP_PKEY_CTX_set_hkdf_md\n");
850 goto err;
851 }
852
853 if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, sizeof(salt)) <= 0) {
854 fprintf(stderr, "FAIL: EVP_PKEY_CTX_set1_hkdf_salt\n");
855 goto err;
856 }
857
858 if (EVP_PKEY_CTX_set1_hkdf_key(pctx, ikm, sizeof(ikm)) <= 0) {
859 fprintf(stderr, "FAIL: EVP_PKEY_CTX_set1_hkdf_key\n");
860 goto err;
861 }
862
863 if (EVP_PKEY_CTX_add1_hkdf_info(pctx, info, sizeof(info)) <= 0) {
864 fprintf(stderr, "FAIL: EVP_PKEY_CTX_add1_hkdf_info\n");
865 goto err;
866 }
867
868 if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) {
869 fprintf(stderr, "FAIL: EVP_PKEY_derive\n");
870 goto err;
871 }
872
873 if (!kdf_compare_bytes("HKDF test", out, outlen, expected, sizeof(expected)))
874 goto err;
875
876 failed = 0;
877
878 err:
879 EVP_PKEY_CTX_free(pctx);
880 return failed;
881}
882
883static int
805evp_kdf_tls1_prf_basic(void) 884evp_kdf_tls1_prf_basic(void)
806{ 885{
807 EVP_PKEY_CTX *pctx; 886 EVP_PKEY_CTX *pctx;
@@ -1038,6 +1117,7 @@ main(int argc, char **argv)
1038 failed |= obj_name_do_all_test(); 1117 failed |= obj_name_do_all_test();
1039 failed |= evp_get_cipherbyname_test(); 1118 failed |= evp_get_cipherbyname_test();
1040 failed |= evp_get_digestbyname_test(); 1119 failed |= evp_get_digestbyname_test();
1120 failed |= evp_kdf_hkdf_basic();
1041 failed |= evp_kdf_tls1_prf_basic(); 1121 failed |= evp_kdf_tls1_prf_basic();
1042 failed |= evp_kdf_tls1_prf(); 1122 failed |= evp_kdf_tls1_prf();
1043 1123
diff --git a/src/regress/lib/libcrypto/gcm128/gcm128test.c b/src/regress/lib/libcrypto/gcm128/gcm128test.c
index def7653c7b..78631979fe 100644
--- a/src/regress/lib/libcrypto/gcm128/gcm128test.c
+++ b/src/regress/lib/libcrypto/gcm128/gcm128test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gcm128test.c,v 1.7 2022/09/05 21:06:31 tb Exp $ */ 1/* $OpenBSD: gcm128test.c,v 1.8 2025/05/16 14:03:49 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -57,11 +57,6 @@
57#include <openssl/aes.h> 57#include <openssl/aes.h>
58#include <openssl/modes.h> 58#include <openssl/modes.h>
59 59
60/* XXX - something like this should be in the public headers. */
61struct gcm128_context {
62 uint64_t opaque[64];
63};
64
65struct gcm128_test { 60struct gcm128_test {
66 const uint8_t K[128]; 61 const uint8_t K[128];
67 size_t K_len; 62 size_t K_len;
@@ -856,7 +851,7 @@ struct gcm128_test gcm128_tests[] = {
856static int 851static int
857do_gcm128_test(int test_no, struct gcm128_test *tv) 852do_gcm128_test(int test_no, struct gcm128_test *tv)
858{ 853{
859 GCM128_CONTEXT ctx; 854 GCM128_CONTEXT *ctx;
860 AES_KEY key; 855 AES_KEY key;
861 uint8_t *out = NULL; 856 uint8_t *out = NULL;
862 size_t out_len; 857 size_t out_len;
@@ -873,13 +868,16 @@ do_gcm128_test(int test_no, struct gcm128_test *tv)
873 868
874 if (out_len != 0) 869 if (out_len != 0)
875 memset(out, 0, out_len); 870 memset(out, 0, out_len);
876 CRYPTO_gcm128_init(&ctx, &key, (block128_f)AES_encrypt); 871
877 CRYPTO_gcm128_setiv(&ctx, tv->IV, tv->IV_len); 872 if ((ctx = CRYPTO_gcm128_new(&key, (block128_f)AES_encrypt)) == NULL)
873 err(1, "CRYPTO_gcm128_new");
874
875 CRYPTO_gcm128_setiv(ctx, tv->IV, tv->IV_len);
878 if (tv->A_len > 0) 876 if (tv->A_len > 0)
879 CRYPTO_gcm128_aad(&ctx, tv->A, tv->A_len); 877 CRYPTO_gcm128_aad(ctx, tv->A, tv->A_len);
880 if (tv->P_len > 0) 878 if (tv->P_len > 0)
881 CRYPTO_gcm128_encrypt(&ctx, tv->P, out, out_len); 879 CRYPTO_gcm128_encrypt(ctx, tv->P, out, out_len);
882 if (CRYPTO_gcm128_finish(&ctx, tv->T, 16)) { 880 if (CRYPTO_gcm128_finish(ctx, tv->T, 16)) {
883 fprintf(stderr, "TEST %d: CRYPTO_gcm128_finish failed\n", 881 fprintf(stderr, "TEST %d: CRYPTO_gcm128_finish failed\n",
884 test_no); 882 test_no);
885 goto fail; 883 goto fail;
@@ -891,12 +889,12 @@ do_gcm128_test(int test_no, struct gcm128_test *tv)
891 889
892 if (out_len != 0) 890 if (out_len != 0)
893 memset(out, 0, out_len); 891 memset(out, 0, out_len);
894 CRYPTO_gcm128_setiv(&ctx, tv->IV, tv->IV_len); 892 CRYPTO_gcm128_setiv(ctx, tv->IV, tv->IV_len);
895 if (tv->A_len > 0) 893 if (tv->A_len > 0)
896 CRYPTO_gcm128_aad(&ctx, tv->A, tv->A_len); 894 CRYPTO_gcm128_aad(ctx, tv->A, tv->A_len);
897 if (tv->C_len > 0) 895 if (tv->C_len > 0)
898 CRYPTO_gcm128_decrypt(&ctx, tv->C, out, out_len); 896 CRYPTO_gcm128_decrypt(ctx, tv->C, out, out_len);
899 if (CRYPTO_gcm128_finish(&ctx, tv->T, 16)) { 897 if (CRYPTO_gcm128_finish(ctx, tv->T, 16)) {
900 fprintf(stderr, "TEST %d: CRYPTO_gcm128_finish failed\n", 898 fprintf(stderr, "TEST %d: CRYPTO_gcm128_finish failed\n",
901 test_no); 899 test_no);
902 goto fail; 900 goto fail;
@@ -909,6 +907,8 @@ do_gcm128_test(int test_no, struct gcm128_test *tv)
909 ret = 0; 907 ret = 0;
910 908
911fail: 909fail:
910 CRYPTO_gcm128_release(ctx);
911
912 free(out); 912 free(out);
913 return (ret); 913 return (ret);
914} 914}
diff --git a/src/regress/lib/libcrypto/man/check_complete.pl b/src/regress/lib/libcrypto/man/check_complete.pl
index 5f2d12ec73..3cbf02f16a 100755
--- a/src/regress/lib/libcrypto/man/check_complete.pl
+++ b/src/regress/lib/libcrypto/man/check_complete.pl
@@ -1,6 +1,6 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2# 2#
3# Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3# Copyright (c) 2021,2022,2023,2024,2025 Ingo Schwarze <schwarze@openbsd.org>
4# 4#
5# Permission to use, copy, modify, and distribute this software for any 5# Permission to use, copy, modify, and distribute this software for any
6# purpose with or without fee is hereby granted, provided that the above 6# purpose with or without fee is hereby granted, provided that the above
@@ -30,6 +30,9 @@ my %internal = (
30 BN_MASK2 BN_MASK2h BN_MASK2h1 BN_MASK2l 30 BN_MASK2 BN_MASK2h BN_MASK2h1 BN_MASK2l
31 BN_TBIT BN_ULLONG 31 BN_TBIT BN_ULLONG
32 )], 32 )],
33 conf => [qw(
34 conf_st conf_method_st
35 )],
33 evp => [qw( 36 evp => [qw(
34 ASN1_PKEY_CTRL_CMS_ENVELOPE ASN1_PKEY_CTRL_CMS_RI_TYPE 37 ASN1_PKEY_CTRL_CMS_ENVELOPE ASN1_PKEY_CTRL_CMS_RI_TYPE
35 ASN1_PKEY_CTRL_CMS_SIGN 38 ASN1_PKEY_CTRL_CMS_SIGN
@@ -116,7 +119,7 @@ my %postponed = (
116 119
117my $MANW = 'man -M /usr/share/man -w'; 120my $MANW = 'man -M /usr/share/man -w';
118my $srcdir = '/usr/src/lib/libcrypto/man'; 121my $srcdir = '/usr/src/lib/libcrypto/man';
119my $hfile = '/usr/include/openssl'; 122my $hfile = '/usr/include';
120 123
121my $in_cplusplus = 0; 124my $in_cplusplus = 0;
122my $in_comment = 0; 125my $in_comment = 0;
@@ -133,6 +136,7 @@ if (defined $ARGV[0] && $ARGV[0] eq '-v') {
133 shift @ARGV; 136 shift @ARGV;
134} 137}
135$#ARGV == 0 or die "usage: $0 [-v] headername"; 138$#ARGV == 0 or die "usage: $0 [-v] headername";
139$hfile .= "/openssl" unless $ARGV[0] eq 'tls';
136$hfile .= "/$ARGV[0].h"; 140$hfile .= "/$ARGV[0].h";
137open my $in_fh, '<', $hfile or die "$hfile: $!"; 141open my $in_fh, '<', $hfile or die "$hfile: $!";
138 142
@@ -236,6 +240,7 @@ try_again:
236 # Uninteresting lines. 240 # Uninteresting lines.
237 241
238 if (/^\s*$/ || 242 if (/^\s*$/ ||
243 /^DECLARE_LHASH_OF\(\w+\);$/ ||
239 /^DECLARE_STACK_OF\(\w+\)$/ || 244 /^DECLARE_STACK_OF\(\w+\)$/ ||
240 /^DECLARE_PKCS12_STACK_OF\(\w+\)$/ || 245 /^DECLARE_PKCS12_STACK_OF\(\w+\)$/ ||
241 /^TYPEDEF_D2I2D_OF\(\w+\);$/ || 246 /^TYPEDEF_D2I2D_OF\(\w+\);$/ ||
@@ -288,7 +293,7 @@ try_again:
288 print "D- $line\n" if $verbose; 293 print "D- $line\n" if $verbose;
289 next; 294 next;
290 } 295 }
291 if ($id =~ /^(?:ASN1|BIO|BN|EVP|X509(?:V3)?)_[FR]_\w+$/) { 296 if ($id =~ /^(?:ASN1|BIO|BN|CONF|EVP|X509(?:V3)?)_[FR]_\w+$/) {
292 print "D- $line\n" if $verbose; 297 print "D- $line\n" if $verbose;
293 next; 298 next;
294 } 299 }
diff --git a/src/regress/lib/libcrypto/md/Makefile b/src/regress/lib/libcrypto/md/Makefile
index 94bec95e05..1df57283b2 100644
--- a/src/regress/lib/libcrypto/md/Makefile
+++ b/src/regress/lib/libcrypto/md/Makefile
@@ -1,9 +1,15 @@
1# $OpenBSD: Makefile,v 1.1.1.1 2022/09/02 13:34:48 tb Exp $ 1# $OpenBSD: Makefile,v 1.2 2025/05/22 03:24:47 joshua Exp $
2 2
3PROG= md_test 3PROG = md_test
4LDADD= -lcrypto 4LDADD = -lcrypto
5DPADD= ${LIBCRYPTO} 5DPADD = ${LIBCRYPTO}
6WARNINGS= Yes 6WARNINGS = Yes
7CFLAGS+= -DLIBRESSL_INTERNAL -Werror 7CFLAGS += -DLIBRESSL_INTERNAL -Werror
8CFLAGS += -I${.CURDIR}/../test
9SRCS += md_test.c
10SRCS += test.c
11SRCS += test_util.c
12
13.PATH: ${.CURDIR}/../test
8 14
9.include <bsd.regress.mk> 15.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/md/md_test.c b/src/regress/lib/libcrypto/md/md_test.c
index 590bb50ee3..752f2e4958 100644
--- a/src/regress/lib/libcrypto/md/md_test.c
+++ b/src/regress/lib/libcrypto/md/md_test.c
@@ -1,6 +1,6 @@
1/* $OpenBSD: md_test.c,v 1.3 2025/01/19 10:17:39 tb Exp $ */ 1/* $OpenBSD: md_test.c,v 1.4 2025/05/22 03:24:47 joshua Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Joshua Sing <joshua@hypera.dev> 3 * Copyright (c) 2022, 2025 Joshua Sing <joshua@joshuasing.dev>
4 * 4 *
5 * Permission to use, copy, modify, and distribute this software for any 5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above 6 * purpose with or without fee is hereby granted, provided that the above
@@ -22,6 +22,8 @@
22#include <stdint.h> 22#include <stdint.h>
23#include <string.h> 23#include <string.h>
24 24
25#include "test.h"
26
25struct md_test { 27struct md_test {
26 const int algorithm; 28 const int algorithm;
27 const uint8_t in[128]; 29 const uint8_t in[128];
@@ -30,7 +32,7 @@ struct md_test {
30}; 32};
31 33
32static const struct md_test md_tests[] = { 34static const struct md_test md_tests[] = {
33 /* MD4 (RFC 1320 test vectors) */ 35 /* MD4 (RFC 1320 test vectors) */
34 { 36 {
35 .algorithm = NID_md4, 37 .algorithm = NID_md4,
36 .in = "", 38 .in = "",
@@ -99,7 +101,7 @@ static const struct md_test md_tests[] = {
99 } 101 }
100 }, 102 },
101 103
102 /* MD5 (RFC 1321 test vectors) */ 104 /* MD5 (RFC 1321 test vectors) */
103 { 105 {
104 .algorithm = NID_md5, 106 .algorithm = NID_md5,
105 .in = "", 107 .in = "",
@@ -175,25 +177,21 @@ typedef unsigned char *(*md_hash_func)(const unsigned char *, size_t,
175 unsigned char *); 177 unsigned char *);
176 178
177static int 179static int
178md_hash_from_algorithm(int algorithm, const char **out_label, 180md_hash_from_algorithm(int algorithm, md_hash_func *out_func,
179 md_hash_func *out_func, const EVP_MD **out_md, size_t *out_len) 181 const EVP_MD **out_md, size_t *out_len)
180{ 182{
181 switch (algorithm) { 183 switch (algorithm) {
182 case NID_md4: 184 case NID_md4:
183 *out_label = SN_md4;
184 *out_func = MD4; 185 *out_func = MD4;
185 *out_md = EVP_md4(); 186 *out_md = EVP_md4();
186 *out_len = MD4_DIGEST_LENGTH; 187 *out_len = MD4_DIGEST_LENGTH;
187 break; 188 break;
188 case NID_md5: 189 case NID_md5:
189 *out_label = SN_md5;
190 *out_func = MD5; 190 *out_func = MD5;
191 *out_md = EVP_md5(); 191 *out_md = EVP_md5();
192 *out_len = MD5_DIGEST_LENGTH; 192 *out_len = MD5_DIGEST_LENGTH;
193 break; 193 break;
194 default: 194 default:
195 fprintf(stderr, "FAIL: unknown algorithm (%d)\n",
196 algorithm);
197 return 0; 195 return 0;
198 } 196 }
199 197
@@ -201,108 +199,100 @@ md_hash_from_algorithm(int algorithm, const char **out_label,
201} 199}
202 200
203static void 201static void
204hexdump(const unsigned char *buf, size_t len) 202test_md_tv(struct test *t, const void *arg)
205{
206 size_t i;
207
208 for (i = 1; i <= len; i++)
209 fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n");
210
211 fprintf(stderr, "\n");
212}
213
214static int
215md_test(void)
216{ 203{
217 unsigned char *(*md_func)(const unsigned char *, size_t, unsigned char *); 204 const struct md_test *st = arg;
218 const struct md_test *st; 205 md_hash_func md_func;
219 EVP_MD_CTX *hash = NULL;
220 const EVP_MD *md; 206 const EVP_MD *md;
207 EVP_MD_CTX *hash = NULL;
221 uint8_t out[EVP_MAX_MD_SIZE]; 208 uint8_t out[EVP_MAX_MD_SIZE];
222 size_t in_len, out_len; 209 size_t in_len, out_len;
223 size_t i;
224 const char *label;
225 int failed = 1;
226 210
227 if ((hash = EVP_MD_CTX_new()) == NULL) { 211 if (!md_hash_from_algorithm(st->algorithm, &md_func, &md, &out_len)) {
228 fprintf(stderr, "FAIL: EVP_MD_CTX_new() failed\n"); 212 test_errorf(t, "md_hash_from_algorithm: unknown algorithm: %d",
229 goto failed; 213 st->algorithm);
214 goto fail;
230 } 215 }
231 216
232 for (i = 0; i < N_MD_TESTS; i++) { 217 if ((hash = EVP_MD_CTX_new()) == NULL) {
233 st = &md_tests[i]; 218 test_errorf(t, "EVP_MD_CTX_new()");
234 if (!md_hash_from_algorithm(st->algorithm, &label, &md_func, 219 goto fail;
235 &md, &out_len)) 220 }
236 goto failed;
237
238 /* Digest */
239 memset(out, 0, sizeof(out));
240 md_func(st->in, st->in_len, out);
241 if (memcmp(st->out, out, out_len) != 0) {
242 fprintf(stderr, "FAIL (%s): mismatch\n", label);
243 goto failed;
244 }
245 221
246 /* EVP single-shot digest */ 222 /* Digest */
247 memset(out, 0, sizeof(out)); 223 memset(out, 0, sizeof(out));
248 if (!EVP_Digest(st->in, st->in_len, out, NULL, md, NULL)) { 224 md_func(st->in, st->in_len, out);
249 fprintf(stderr, "FAIL (%s): EVP_Digest failed\n", 225 if (memcmp(st->out, out, out_len) != 0) {
250 label); 226 test_errorf(t, "MD: digest output mismatch");
251 goto failed; 227 test_hexdiff(t, out, out_len, st->out);
252 } 228 }
253 229
254 if (memcmp(st->out, out, out_len) != 0) { 230 /* EVP single-shot digest */
255 fprintf(stderr, "FAIL (%s): EVP single-shot mismatch\n", 231 memset(out, 0, sizeof(out));
256 label); 232 if (!EVP_Digest(st->in, st->in_len, out, NULL, md, NULL)) {
257 goto failed; 233 test_errorf(t, "EVP_Digest()");
258 } 234 goto fail;
235 }
236 if (memcmp(st->out, out, out_len) != 0) {
237 test_errorf(t, "EVP_Digest: digest output mismatch");
238 test_hexdiff(t, out, out_len, st->out);
239 }
259 240
260 /* EVP digest */ 241 /* EVP digest */
261 memset(out, 0, sizeof(out)); 242 memset(out, 0, sizeof(out));
262 if (!EVP_DigestInit_ex(hash, md, NULL)) { 243 if (!EVP_DigestInit_ex(hash, md, NULL)) {
263 fprintf(stderr, "FAIL (%s): EVP_DigestInit_ex failed\n", 244 test_errorf(t, "EVP_DigestInit_ex()");
264 label); 245 goto fail;
265 goto failed; 246 }
266 }
267 247
268 in_len = st->in_len / 2; 248 in_len = st->in_len / 2;
269 if (!EVP_DigestUpdate(hash, st->in, in_len)) { 249 if (!EVP_DigestUpdate(hash, st->in, in_len)) {
270 fprintf(stderr, 250 test_errorf(t, "EVP_DigestUpdate: first half failed");
271 "FAIL (%s): EVP_DigestUpdate first half failed\n", 251 goto fail;
272 label); 252 }
273 goto failed;
274 }
275 253
276 if (!EVP_DigestUpdate(hash, st->in + in_len, 254 if (!EVP_DigestUpdate(hash, st->in + in_len,
277 st->in_len - in_len)) { 255 st->in_len - in_len)) {
278 fprintf(stderr, 256 test_errorf(t, "EVP_DigestUpdate: second half failed");
279 "FAIL (%s): EVP_DigestUpdate second half failed\n", 257 goto fail;
280 label); 258 }
281 goto failed;
282 }
283 259
284 if (!EVP_DigestFinal_ex(hash, out, NULL)) { 260 if (!EVP_DigestFinal_ex(hash, out, NULL)) {
285 fprintf(stderr, 261 test_errorf(t, "EVP_DigestFinal_ex()");
286 "FAIL (%s): EVP_DigestFinal_ex failed\n", 262 goto fail;
287 label); 263 }
288 goto failed;
289 }
290 264
291 if (memcmp(st->out, out, out_len) != 0) { 265 if (memcmp(st->out, out, out_len) != 0) {
292 fprintf(stderr, "FAIL (%s): EVP mismatch\n", label); 266 test_errorf(t, "EVP: digest output mismatch");
293 goto failed; 267 test_hexdiff(t, out, out_len, st->out);
294 }
295 } 268 }
296 269
297 failed = 0;
298 270
299 failed: 271 fail:
300 EVP_MD_CTX_free(hash); 272 EVP_MD_CTX_free(hash);
301 return failed;
302} 273}
303 274
304static int 275static void
305md5_large_test(void) 276test_md(struct test *t, const void *arg)
277{
278 const struct md_test *st;
279 size_t i;
280 char *name;
281
282 for (i = 0; i < N_MD_TESTS; i++) {
283 st = &md_tests[i];
284 if (asprintf(&name, "%s: '%s'", OBJ_nid2sn(st->algorithm), st->in) == -1) {
285 test_errorf(t, "create test name");
286 return;
287 }
288
289 test_run(t, name, test_md_tv, st);
290 free(name);
291 }
292}
293
294static void
295test_md5_large(struct test *t, const void *arg)
306{ 296{
307 MD5_CTX ctx; 297 MD5_CTX ctx;
308 uint8_t in[1024]; 298 uint8_t in[1024];
@@ -310,12 +300,10 @@ md5_large_test(void)
310 unsigned int out_len; 300 unsigned int out_len;
311 size_t in_len; 301 size_t in_len;
312 size_t i; 302 size_t i;
313 const char *label;
314 uint8_t want[] = { 303 uint8_t want[] = {
315 0xd8, 0xbc, 0xae, 0x13, 0xb5, 0x5a, 0xb0, 0xfc, 304 0xd8, 0xbc, 0xae, 0x13, 0xb5, 0x5a, 0xb0, 0xfc,
316 0x7f, 0x8a, 0xe1, 0x78, 0x27, 0x8d, 0x44, 0x1b, 305 0x7f, 0x8a, 0xe1, 0x78, 0x27, 0x8d, 0x44, 0x1b,
317 }; 306 };
318 int failed = 1;
319 307
320 memset(in, 'A', sizeof(in)); 308 memset(in, 'A', sizeof(in));
321 in_len = sizeof(in); 309 in_len = sizeof(in);
@@ -323,44 +311,34 @@ md5_large_test(void)
323 memset(out, 0, sizeof(out)); 311 memset(out, 0, sizeof(out));
324 out_len = 16; 312 out_len = 16;
325 313
326 label = "md5";
327
328 MD5_Init(&ctx); 314 MD5_Init(&ctx);
329 315
330 for (i = 0; i < (1<<29) + 1; i += in_len) { 316 for (i = 0; i < (1<<29) + 1; i += in_len) {
331 if (!MD5_Update(&ctx, in, in_len)) { 317 if (!MD5_Update(&ctx, in, in_len)) {
332 fprintf(stderr, "FAIL (%s): MD5_Update failed\n", label); 318 test_errorf(t, "MD5_Update()");
333 goto failed; 319 return;
334 } 320 }
335 } 321 }
336 if (!MD5_Final(out, &ctx)) { 322 if (!MD5_Final(out, &ctx)) {
337 fprintf(stderr, "FAIL (%s): MD5_Final failed\n", label); 323 test_errorf(t, "MD5_Final()");
338 goto failed; 324 return;
339 } 325 }
340 326
341 if (memcmp(out, want, out_len) != 0) { 327 if (memcmp(out, want, out_len) != 0) {
342 fprintf(stderr, "FAIL (%s): MD5 mismatch\n", label); 328 test_errorf(t, "MD5 digest output mismatch");
343 hexdump(out, out_len); 329 test_hexdump(t, out, out_len);
344 goto failed;
345 } 330 }
346 if (ctx.Nh != 0x1 || ctx.Nl != 0x2000) { 331 if (ctx.Nh != 0x1 || ctx.Nl != 0x2000)
347 fprintf(stderr, "FAIL (%s): MD5 incorrect bit length\n", label); 332 test_errorf(t, "MD5 incorrect bit length");
348 goto failed;
349 }
350
351 failed = 0;
352
353 failed:
354 return failed;
355} 333}
356 334
357int 335int
358main(int argc, char **argv) 336main(int argc, char **argv)
359{ 337{
360 int failed = 0; 338 struct test *t = test_init();
361 339
362 failed |= md_test(); 340 test_run(t, "md", test_md, NULL);
363 failed |= md5_large_test(); 341 test_run(t, "md5 large", test_md5_large, NULL);
364 342
365 return failed; 343 return test_result(t);
366} 344}
diff --git a/src/regress/lib/libcrypto/mlkem/Makefile b/src/regress/lib/libcrypto/mlkem/Makefile
index a08623c90a..3acaf78e63 100644
--- a/src/regress/lib/libcrypto/mlkem/Makefile
+++ b/src/regress/lib/libcrypto/mlkem/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.9 2024/12/29 20:14:15 tb Exp $ 1# $OpenBSD: Makefile,v 1.10 2025/08/15 14:46:37 tb Exp $
2 2
3REGRESS_SLOW_TARGETS += run-regress-mlkem_iteration_tests 3REGRESS_SLOW_TARGETS += run-regress-mlkem_iteration_tests
4 4
@@ -22,7 +22,7 @@ run-regress-mlkem_tests: mlkem_tests
22 ./mlkem_tests $f ${.CURDIR}/$f.txt 22 ./mlkem_tests $f ${.CURDIR}/$f.txt
23.endfor 23.endfor
24 24
25SRCS_mlkem_tests = mlkem_tests.c mlkem_tests_util.c parse_test_file.c 25SRCS_mlkem_tests = mlkem_tests.c parse_test_file.c
26SRCS_mlkem_iteration_tests = mlkem_iteration_tests.c mlkem_tests_util.c 26SRCS_mlkem_iteration_tests = mlkem_iteration_tests.c mlkem_tests_util.c
27SRCS_mlkem_unittest = mlkem_unittest.c mlkem_tests_util.c 27SRCS_mlkem_unittest = mlkem_unittest.c mlkem_tests_util.c
28 28
diff --git a/src/regress/lib/libcrypto/mlkem/mlkem_iteration_tests.c b/src/regress/lib/libcrypto/mlkem/mlkem_iteration_tests.c
index 5a61248090..053f8e1222 100644
--- a/src/regress/lib/libcrypto/mlkem/mlkem_iteration_tests.c
+++ b/src/regress/lib/libcrypto/mlkem/mlkem_iteration_tests.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mlkem_iteration_tests.c,v 1.2 2024/12/26 07:26:45 tb Exp $ */ 1/* $OpenBSD: mlkem_iteration_tests.c,v 1.8 2025/08/17 19:26:35 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Google Inc. 3 * Copyright (c) 2024 Google Inc.
4 * Copyright (c) 2024 Bob Beck <beck@obtuse.com> 4 * Copyright (c) 2024 Bob Beck <beck@obtuse.com>
@@ -22,7 +22,7 @@
22#include <stdio.h> 22#include <stdio.h>
23#include <stdlib.h> 23#include <stdlib.h>
24 24
25#include "mlkem.h" 25#include <openssl/mlkem.h>
26 26
27#include "mlkem_internal.h" 27#include "mlkem_internal.h"
28#include "mlkem_tests_util.h" 28#include "mlkem_tests_util.h"
@@ -63,46 +63,49 @@ const uint8_t kExpectedAdam1024[32] = {
63 0x04, 0xab, 0xdb, 0x94, 0x8b, 0x90, 0x8b, 0x75, 0xba, 0xd5 63 0x04, 0xab, 0xdb, 0x94, 0x8b, 0x90, 0x8b, 0x75, 0xba, 0xd5
64}; 64};
65 65
66struct iteration_ctx {
67 uint8_t *encoded_public_key;
68 size_t encoded_public_key_len;
69 uint8_t *ciphertext;
70 size_t ciphertext_len;
71 uint8_t *invalid_ciphertext;
72 size_t invalid_ciphertext_len;
73 void *priv;
74 void *pub;
75
76 mlkem_encode_private_key_fn encode_private_key;
77 mlkem_encap_external_entropy_fn encap_external_entropy;
78 mlkem_generate_key_external_entropy_fn generate_key_external_entropy;
79 mlkem_public_from_private_fn public_from_private;
80 mlkem_decap_fn decap;
81
82 const uint8_t *start;
83 size_t start_len;
84
85 const uint8_t *expected;
86 size_t expected_len;
87};
88
89static int 66static int
90MlkemIterativeTest(struct iteration_ctx *ctx) 67MlkemIterativeTest(int rank)
91{ 68{
92 uint8_t shared_secret[MLKEM_SHARED_SECRET_BYTES]; 69 const uint8_t *start, *expected;
70 size_t start_len;
93 uint8_t encap_entropy[MLKEM_ENCAP_ENTROPY]; 71 uint8_t encap_entropy[MLKEM_ENCAP_ENTROPY];
94 uint8_t seed[MLKEM_SEED_BYTES] = {0}; 72 uint8_t seed[MLKEM_SEED_LENGTH] = {0};
73 uint8_t *shared_secret = NULL;
95 sha3_ctx drng, results; 74 sha3_ctx drng, results;
96 uint8_t out[32]; 75 uint8_t out[32];
97 int i; 76 int i;
98 77
78 start = kExpectedSeedStart;
79 start_len = sizeof(kExpectedSeedStart);
80 switch(rank){
81 case RANK768:
82 expected = kExpectedAdam768;
83 break;
84 case RANK1024:
85 expected = kExpectedAdam1024;
86 break;
87 default:
88 errx(1, "invalid rank %d", rank);
89 }
90
99 shake128_init(&drng); 91 shake128_init(&drng);
100 shake128_init(&results); 92 shake128_init(&results);
101 93
102 shake_xof(&drng); 94 shake_xof(&drng);
103 for (i = 0; i < 10000; i++) { 95 for (i = 0; i < 10000; i++) {
104 uint8_t *encoded_private_key = NULL; 96 uint8_t *encoded_public_key = NULL, *ciphertext = NULL,
105 size_t encoded_private_key_len; 97 *encoded_private_key = NULL, *invalid_ciphertext = NULL;
98 size_t encoded_public_key_len, ciphertext_len,
99 encoded_private_key_len, invalid_ciphertext_len;
100 MLKEM_private_key *priv;
101 MLKEM_public_key *pub;
102 size_t s_len = 0;
103
104 /* allocate keys for this iteration */
105 if ((priv = MLKEM_private_key_new(rank)) == NULL)
106 errx(1, "malloc");
107 if ((pub = MLKEM_public_key_new(rank)) == NULL)
108 errx(1, "malloc");
106 109
107 /* 110 /*
108 * This should draw both d and z from DRNG concatenating in 111 * This should draw both d and z from DRNG concatenating in
@@ -110,118 +113,91 @@ MlkemIterativeTest(struct iteration_ctx *ctx)
110 */ 113 */
111 shake_out(&drng, seed, sizeof(seed)); 114 shake_out(&drng, seed, sizeof(seed));
112 if (i == 0) { 115 if (i == 0) {
113 if (compare_data(seed, ctx->start, ctx->start_len, 116 if (compare_data(seed, start, start_len,
114 "seed start") != 0) 117 "seed start") != 0)
115 errx(1, "compare_data"); 118 errx(1, "compare_data");
116 } 119 }
117 120
118 /* generate ek as encoded_public_key */ 121 /* generate ek as encoded_public_key */
119 ctx->generate_key_external_entropy(ctx->encoded_public_key, 122 if (!MLKEM_generate_key_external_entropy(priv,
120 ctx->priv, seed); 123 &encoded_public_key, &encoded_public_key_len,
121 ctx->public_from_private(ctx->pub, ctx->priv); 124 seed))
125 errx(1, "generate_key_external_entropy");
126
127 if (!MLKEM_public_from_private(priv, pub))
128 errx(1, "public_from_private");
122 129
123 /* hash in ek */ 130 /* hash in ek */
124 shake_update(&results, ctx->encoded_public_key, 131 shake_update(&results, encoded_public_key,
125 ctx->encoded_public_key_len); 132 encoded_public_key_len);
126 133
127 /* marshal priv to dk as encoded_private_key */ 134 /* marshal priv to dk as encoded_private_key */
128 if (!ctx->encode_private_key(ctx->priv, &encoded_private_key, 135 if (!MLKEM_marshal_private_key(priv, &encoded_private_key,
129 &encoded_private_key_len)) 136 &encoded_private_key_len))
130 errx(1, "encode private key"); 137 errx(1, "marshal private key");
131 138
132 /* hash in dk */ 139 /* hash in dk */
133 shake_update(&results, encoded_private_key, 140 shake_update(&results, encoded_private_key,
134 encoded_private_key_len); 141 encoded_private_key_len);
135 142
136 free(encoded_private_key); 143 freezero(encoded_private_key, encoded_private_key_len);
137 144
138 /* draw m as encap entropy from DRNG */ 145 /* draw m as encap entropy from DRNG */
139 shake_out(&drng, encap_entropy, sizeof(encap_entropy)); 146 shake_out(&drng, encap_entropy, sizeof(encap_entropy));
140 147
141 /* generate ct as ciphertext, k as shared_secret */ 148 /* generate ct as ciphertext, k as shared_secret */
142 ctx->encap_external_entropy(ctx->ciphertext, shared_secret, 149 if (!MLKEM_encap_external_entropy(pub, encap_entropy,
143 ctx->pub, encap_entropy); 150 &ciphertext, &ciphertext_len, &shared_secret, &s_len))
151 errx(1, "encap_external_entropy");
144 152
145 /* hash in ct */ 153 /* hash in ct */
146 shake_update(&results, ctx->ciphertext, ctx->ciphertext_len); 154 shake_update(&results, ciphertext, ciphertext_len);
147 /* hash in k */ 155 /* hash in k */
148 shake_update(&results, shared_secret, sizeof(shared_secret)); 156 shake_update(&results, shared_secret, s_len);
157
158 freezero(shared_secret, s_len);
159 shared_secret = NULL;
160
161 invalid_ciphertext_len = ciphertext_len;
162 if ((invalid_ciphertext = calloc(1, invalid_ciphertext_len))
163 == NULL)
164 errx(1, "malloc");
149 165
150 /* draw ct as invalid_ciphertxt from DRNG */ 166 /* draw ct as invalid_ciphertxt from DRNG */
151 shake_out(&drng, ctx->invalid_ciphertext, 167 shake_out(&drng, invalid_ciphertext, invalid_ciphertext_len);
152 ctx->invalid_ciphertext_len);
153 168
154 /* generate k as shared secret from invalid ciphertext */ 169 /* generate k as shared secret from invalid ciphertext */
155 if (!ctx->decap(shared_secret, ctx->invalid_ciphertext, 170 if (!MLKEM_decap(priv, invalid_ciphertext,
156 ctx->invalid_ciphertext_len, ctx->priv)) 171 invalid_ciphertext_len, &shared_secret, &s_len))
157 errx(1, "decap failed"); 172 errx(1, "decap failed, iteration %d", i);
158 173
159 /* hash in k */ 174 /* hash in k */
160 shake_update(&results, shared_secret, sizeof(shared_secret)); 175 shake_update(&results, shared_secret, s_len);
176
177 freezero(shared_secret, s_len);
178 shared_secret = NULL;
179 freezero(invalid_ciphertext, invalid_ciphertext_len);
180 invalid_ciphertext = NULL;
181
182 /* free keys and intermediate products for this iteration */
183 MLKEM_private_key_free(priv);
184 MLKEM_public_key_free(pub);
185 freezero(encoded_public_key, encoded_public_key_len);
186 freezero(ciphertext, ciphertext_len);
161 } 187 }
162 shake_xof(&results); 188 shake_xof(&results);
163 shake_out(&results, out, sizeof(out)); 189 shake_out(&results, out, sizeof(out));
164 190
165 return compare_data(ctx->expected, out, sizeof(out), "final result hash"); 191 return compare_data(expected, out, sizeof(out), "final result hash");
166} 192}
167 193
168int 194int
169main(void) 195main(void)
170{ 196{
171 uint8_t encoded_public_key768[MLKEM768_PUBLIC_KEY_BYTES];
172 uint8_t ciphertext768[MLKEM768_CIPHERTEXT_BYTES];
173 uint8_t invalid_ciphertext768[MLKEM768_CIPHERTEXT_BYTES];
174 struct MLKEM768_private_key priv768;
175 struct MLKEM768_public_key pub768;
176 struct iteration_ctx iteration768 = {
177 .encoded_public_key = encoded_public_key768,
178 .encoded_public_key_len = sizeof(encoded_public_key768),
179 .ciphertext = ciphertext768,
180 .ciphertext_len = sizeof(ciphertext768),
181 .invalid_ciphertext = invalid_ciphertext768,
182 .invalid_ciphertext_len = sizeof(invalid_ciphertext768),
183 .priv = &priv768,
184 .pub = &pub768,
185 .encap_external_entropy = mlkem768_encap_external_entropy,
186 .encode_private_key = mlkem768_encode_private_key,
187 .generate_key_external_entropy =
188 mlkem768_generate_key_external_entropy,
189 .public_from_private = mlkem768_public_from_private,
190 .decap = mlkem768_decap,
191 .start = kExpectedSeedStart,
192 .start_len = sizeof(kExpectedSeedStart),
193 .expected = kExpectedAdam768,
194 .expected_len = sizeof(kExpectedAdam768),
195 };
196 uint8_t encoded_public_key1024[MLKEM1024_PUBLIC_KEY_BYTES];
197 uint8_t ciphertext1024[MLKEM1024_CIPHERTEXT_BYTES];
198 uint8_t invalid_ciphertext1024[MLKEM1024_CIPHERTEXT_BYTES];
199 struct MLKEM1024_private_key priv1024;
200 struct MLKEM1024_public_key pub1024;
201 struct iteration_ctx iteration1024 = {
202 .encoded_public_key = encoded_public_key1024,
203 .encoded_public_key_len = sizeof(encoded_public_key1024),
204 .ciphertext = ciphertext1024,
205 .ciphertext_len = sizeof(ciphertext1024),
206 .invalid_ciphertext = invalid_ciphertext1024,
207 .invalid_ciphertext_len = sizeof(invalid_ciphertext1024),
208 .priv = &priv1024,
209 .pub = &pub1024,
210 .encap_external_entropy = mlkem1024_encap_external_entropy,
211 .encode_private_key = mlkem1024_encode_private_key,
212 .generate_key_external_entropy =
213 mlkem1024_generate_key_external_entropy,
214 .public_from_private = mlkem1024_public_from_private,
215 .decap = mlkem1024_decap,
216 .start = kExpectedSeedStart,
217 .start_len = sizeof(kExpectedSeedStart),
218 .expected = kExpectedAdam1024,
219 .expected_len = sizeof(kExpectedAdam1024),
220 };
221 int failed = 0; 197 int failed = 0;
222 198
223 failed |= MlkemIterativeTest(&iteration768); 199 failed |= MlkemIterativeTest(RANK768);
224 failed |= MlkemIterativeTest(&iteration1024); 200 failed |= MlkemIterativeTest(RANK1024);
225 201
226 return failed; 202 return failed;
227} 203}
diff --git a/src/regress/lib/libcrypto/mlkem/mlkem_tests.c b/src/regress/lib/libcrypto/mlkem/mlkem_tests.c
index 2801a58890..361467afd0 100644
--- a/src/regress/lib/libcrypto/mlkem/mlkem_tests.c
+++ b/src/regress/lib/libcrypto/mlkem/mlkem_tests.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mlkem_tests.c,v 1.2 2024/12/26 00:10:19 tb Exp $ */ 1/* $OpenBSD: mlkem_tests.c,v 1.10 2025/08/15 21:47:39 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Google Inc. 3 * Copyright (c) 2024 Google Inc.
4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
@@ -23,12 +23,11 @@
23#include <stdlib.h> 23#include <stdlib.h>
24#include <string.h> 24#include <string.h>
25 25
26#include "bytestring.h" 26#include <openssl/mlkem.h>
27#include "mlkem.h"
28 27
28#include "bytestring.h"
29#include "mlkem_internal.h" 29#include "mlkem_internal.h"
30 30
31#include "mlkem_tests_util.h"
32#include "parse_test_file.h" 31#include "parse_test_file.h"
33 32
34enum test_type { 33enum test_type {
@@ -39,11 +38,7 @@ enum test_type {
39struct decap_ctx { 38struct decap_ctx {
40 struct parse *parse_ctx; 39 struct parse *parse_ctx;
41 40
42 void *private_key; 41 int rank;
43 size_t private_key_len;
44
45 mlkem_parse_private_key_fn parse_private_key;
46 mlkem_decap_fn decap;
47}; 42};
48 43
49enum decap_states { 44enum decap_states {
@@ -102,8 +97,10 @@ static int
102MlkemDecapFileTest(struct decap_ctx *decap) 97MlkemDecapFileTest(struct decap_ctx *decap)
103{ 98{
104 struct parse *p = decap->parse_ctx; 99 struct parse *p = decap->parse_ctx;
105 uint8_t shared_secret_buf[MLKEM_SHARED_SECRET_BYTES]; 100 MLKEM_private_key *priv_key = NULL;
106 CBS ciphertext, shared_secret, private_key; 101 CBS ciphertext, shared_secret, private_key;
102 uint8_t *shared_secret_buf = NULL;
103 size_t shared_secret_buf_len = 0;
107 int should_fail; 104 int should_fail;
108 int failed = 1; 105 int failed = 1;
109 106
@@ -112,20 +109,31 @@ MlkemDecapFileTest(struct decap_ctx *decap)
112 parse_get_cbs(p, DECAP_PRIVATE_KEY, &private_key); 109 parse_get_cbs(p, DECAP_PRIVATE_KEY, &private_key);
113 parse_get_int(p, DECAP_RESULT, &should_fail); 110 parse_get_int(p, DECAP_RESULT, &should_fail);
114 111
115 if (!decap->parse_private_key(decap->private_key, &private_key)) { 112 if ((priv_key = MLKEM_private_key_new(decap->rank)) == NULL)
113 parse_errx(p, "MLKEM_private_key_new");
114
115 if (!MLKEM_parse_private_key(priv_key,
116 CBS_data(&private_key), CBS_len(&private_key))) {
116 if ((failed = !should_fail)) 117 if ((failed = !should_fail))
117 parse_info(p, "parse private key"); 118 parse_info(p, "parse private key");
118 goto err; 119 goto err;
119 } 120 }
120 if (!decap->decap(shared_secret_buf, 121 if (!MLKEM_decap(priv_key, CBS_data(&ciphertext), CBS_len(&ciphertext),
121 CBS_data(&ciphertext), CBS_len(&ciphertext), decap->private_key)) { 122 &shared_secret_buf, &shared_secret_buf_len)) {
122 if ((failed = !should_fail)) 123 if ((failed = !should_fail))
123 parse_info(p, "decap"); 124 parse_info(p, "decap");
124 goto err; 125 goto err;
125 } 126 }
126 127
128 if (shared_secret_buf_len != MLKEM_SHARED_SECRET_LENGTH) {
129 if ((failed = !should_fail))
130 parse_info(p, "shared secret length %zu != %d",
131 shared_secret_buf_len, MLKEM_SHARED_SECRET_LENGTH);
132 goto err;
133 }
134
127 failed = !parse_data_equal(p, "shared_secret", &shared_secret, 135 failed = !parse_data_equal(p, "shared_secret", &shared_secret,
128 shared_secret_buf, sizeof(shared_secret_buf)); 136 shared_secret_buf, shared_secret_buf_len);
129 137
130 if (should_fail != failed) { 138 if (should_fail != failed) {
131 parse_info(p, "FAIL: should_fail %d, failed %d", 139 parse_info(p, "FAIL: should_fail %d, failed %d",
@@ -134,6 +142,9 @@ MlkemDecapFileTest(struct decap_ctx *decap)
134 } 142 }
135 143
136 err: 144 err:
145 MLKEM_private_key_free(priv_key);
146 freezero(shared_secret_buf, shared_secret_buf_len);
147
137 return failed; 148 return failed;
138} 149}
139 150
@@ -192,35 +203,49 @@ static int
192MlkemNistDecapFileTest(struct decap_ctx *decap) 203MlkemNistDecapFileTest(struct decap_ctx *decap)
193{ 204{
194 struct parse *p = decap->parse_ctx; 205 struct parse *p = decap->parse_ctx;
195 uint8_t shared_secret[MLKEM_SHARED_SECRET_BYTES]; 206 MLKEM_private_key *priv_key = NULL;
196 CBS dk, c, k; 207 CBS dk, c, k;
208 uint8_t *shared_secret = NULL;
209 size_t shared_secret_len = 0;
197 int failed = 1; 210 int failed = 1;
198 211
199 parse_instruction_get_cbs(p, NIST_DECAP_DK, &dk); 212 parse_instruction_get_cbs(p, NIST_DECAP_DK, &dk);
200 parse_get_cbs(p, NIST_DECAP_C, &c); 213 parse_get_cbs(p, NIST_DECAP_C, &c);
201 parse_get_cbs(p, NIST_DECAP_K, &k); 214 parse_get_cbs(p, NIST_DECAP_K, &k);
202 215
216 if ((priv_key = MLKEM_private_key_new(decap->rank)) == NULL)
217 parse_errx(p, "MLKEM_private_key_new");
218
203 if (!parse_length_equal(p, "private key", 219 if (!parse_length_equal(p, "private key",
204 decap->private_key_len, CBS_len(&dk))) 220 MLKEM_private_key_encoded_length(priv_key), CBS_len(&dk)))
205 goto err; 221 goto err;
206 if (!parse_length_equal(p, "shared secret", 222 if (!parse_length_equal(p, "shared secret",
207 MLKEM_SHARED_SECRET_BYTES, CBS_len(&k))) 223 MLKEM_SHARED_SECRET_LENGTH, CBS_len(&k)))
208 goto err; 224 goto err;
209 225
210 if (!decap->parse_private_key(decap->private_key, &dk)) { 226 if (!MLKEM_parse_private_key(priv_key, CBS_data(&dk), CBS_len(&dk))) {
211 parse_info(p, "parse private key"); 227 parse_info(p, "parse private key");
212 goto err; 228 goto err;
213 } 229 }
214 if (!decap->decap(shared_secret, CBS_data(&c), CBS_len(&c), 230 if (!MLKEM_decap(priv_key, CBS_data(&c), CBS_len(&c),
215 decap->private_key)) { 231 &shared_secret, &shared_secret_len)) {
216 parse_info(p, "decap"); 232 parse_info(p, "decap");
217 goto err; 233 goto err;
218 } 234 }
219 235
236 if (shared_secret_len != MLKEM_SHARED_SECRET_LENGTH) {
237 parse_info(p, "shared secret length %zu != %d",
238 shared_secret_len, MLKEM_SHARED_SECRET_LENGTH);
239 goto err;
240 }
241
220 failed = !parse_data_equal(p, "shared secret", &k, 242 failed = !parse_data_equal(p, "shared secret", &k,
221 shared_secret, MLKEM_SHARED_SECRET_BYTES); 243 shared_secret, shared_secret_len);
222 244
223 err: 245 err:
246 MLKEM_private_key_free(priv_key);
247 freezero(shared_secret, shared_secret_len);
248
224 return failed; 249 return failed;
225} 250}
226 251
@@ -244,46 +269,24 @@ static const struct test_parse nist_decap_parse = {
244}; 269};
245 270
246static int 271static int
247mlkem_decap_tests(const char *fn, size_t size, enum test_type test_type) 272mlkem_decap_tests(const char *fn, int rank, enum test_type test_type)
248{ 273{
249 struct MLKEM768_private_key private_key768; 274 struct decap_ctx decap = {
250 struct decap_ctx decap768 = { 275 .rank = rank,
251 .private_key = &private_key768,
252 .private_key_len = MLKEM768_PRIVATE_KEY_BYTES,
253
254 .parse_private_key = mlkem768_parse_private_key,
255 .decap = mlkem768_decap,
256 }; 276 };
257 struct MLKEM1024_private_key private_key1024;
258 struct decap_ctx decap1024 = {
259 .private_key = &private_key1024,
260 .private_key_len = MLKEM1024_PRIVATE_KEY_BYTES,
261 277
262 .parse_private_key = mlkem1024_parse_private_key, 278 if (test_type == TEST_TYPE_NORMAL)
263 .decap = mlkem1024_decap, 279 return parse_test_file(fn, &decap_parse, &decap);
264 }; 280 if (test_type == TEST_TYPE_NIST)
265 281 return parse_test_file(fn, &nist_decap_parse, &decap);
266 if (size == 768 && test_type == TEST_TYPE_NORMAL)
267 return parse_test_file(fn, &decap_parse, &decap768);
268 if (size == 768 && test_type == TEST_TYPE_NIST)
269 return parse_test_file(fn, &nist_decap_parse, &decap768);
270 if (size == 1024 && test_type == TEST_TYPE_NORMAL)
271 return parse_test_file(fn, &decap_parse, &decap1024);
272 if (size == 1024 && test_type == TEST_TYPE_NIST)
273 return parse_test_file(fn, &nist_decap_parse, &decap1024);
274 282
275 errx(1, "unknown decap test: size %zu, type %d", size, test_type); 283 errx(1, "unknown decap test: rank %d, type %d", rank, test_type);
276} 284}
277 285
278struct encap_ctx { 286struct encap_ctx {
279 struct parse *parse_ctx; 287 struct parse *parse_ctx;
280 288
281 void *public_key; 289 int rank;
282 uint8_t *ciphertext;
283 size_t ciphertext_len;
284
285 mlkem_parse_public_key_fn parse_public_key;
286 mlkem_encap_external_entropy_fn encap_external_entropy;
287}; 290};
288 291
289enum encap_states { 292enum encap_states {
@@ -349,8 +352,12 @@ static int
349MlkemEncapFileTest(struct encap_ctx *encap) 352MlkemEncapFileTest(struct encap_ctx *encap)
350{ 353{
351 struct parse *p = encap->parse_ctx; 354 struct parse *p = encap->parse_ctx;
352 uint8_t shared_secret_buf[MLKEM_SHARED_SECRET_BYTES]; 355 MLKEM_public_key *pub_key = NULL;
353 CBS entropy, public_key, ciphertext, shared_secret; 356 CBS entropy, public_key, ciphertext, shared_secret;
357 uint8_t *ciphertext_buf = NULL;
358 size_t ciphertext_buf_len = 0;
359 uint8_t *shared_secret_buf = NULL;
360 size_t shared_secret_buf_len = 0;
354 int should_fail; 361 int should_fail;
355 int failed = 1; 362 int failed = 1;
356 363
@@ -360,18 +367,34 @@ MlkemEncapFileTest(struct encap_ctx *encap)
360 parse_get_cbs(p, ENCAP_SHARED_SECRET, &shared_secret); 367 parse_get_cbs(p, ENCAP_SHARED_SECRET, &shared_secret);
361 parse_get_int(p, ENCAP_RESULT, &should_fail); 368 parse_get_int(p, ENCAP_RESULT, &should_fail);
362 369
363 if (!encap->parse_public_key(encap->public_key, &public_key)) { 370 if ((pub_key = MLKEM_public_key_new(encap->rank)) == NULL)
371 parse_errx(p, "MLKEM_public_key_new");
372
373 if (!MLKEM_parse_public_key(pub_key,
374 CBS_data(&public_key), CBS_len(&public_key))) {
364 if ((failed = !should_fail)) 375 if ((failed = !should_fail))
365 parse_info(p, "parse public key"); 376 parse_info(p, "parse public key");
366 goto err; 377 goto err;
367 } 378 }
368 encap->encap_external_entropy(encap->ciphertext, shared_secret_buf, 379 if (!MLKEM_encap_external_entropy(pub_key, CBS_data(&entropy),
369 encap->public_key, CBS_data(&entropy)); 380 &ciphertext_buf, &ciphertext_buf_len,
381 &shared_secret_buf, &shared_secret_buf_len)) {
382 if ((failed = !should_fail))
383 parse_info(p, "encap_external_entropy");
384 goto err;
385 }
386
387 if (shared_secret_buf_len != MLKEM_SHARED_SECRET_LENGTH) {
388 if ((failed = !should_fail))
389 parse_info(p, "shared secret length %zu != %d",
390 shared_secret_buf_len, MLKEM_SHARED_SECRET_LENGTH);
391 goto err;
392 }
370 393
371 failed = !parse_data_equal(p, "shared_secret", &shared_secret, 394 failed = !parse_data_equal(p, "shared_secret", &shared_secret,
372 shared_secret_buf, sizeof(shared_secret_buf)); 395 shared_secret_buf, shared_secret_buf_len);
373 failed |= !parse_data_equal(p, "ciphertext", &ciphertext, 396 failed |= !parse_data_equal(p, "ciphertext", &ciphertext,
374 encap->ciphertext, encap->ciphertext_len); 397 ciphertext_buf, ciphertext_buf_len);
375 398
376 if (should_fail != failed) { 399 if (should_fail != failed) {
377 parse_info(p, "FAIL: should_fail %d, failed %d", 400 parse_info(p, "FAIL: should_fail %d, failed %d",
@@ -380,6 +403,10 @@ MlkemEncapFileTest(struct encap_ctx *encap)
380 } 403 }
381 404
382 err: 405 err:
406 MLKEM_public_key_free(pub_key);
407 freezero(ciphertext_buf, ciphertext_buf_len);
408 freezero(shared_secret_buf, shared_secret_buf_len);
409
383 return failed; 410 return failed;
384} 411}
385 412
@@ -400,48 +427,19 @@ static const struct test_parse encap_parse = {
400}; 427};
401 428
402static int 429static int
403mlkem_encap_tests(const char *fn, size_t size) 430mlkem_encap_tests(const char *fn, int rank)
404{ 431{
405 struct MLKEM768_public_key public_key768; 432 struct encap_ctx encap = {
406 uint8_t ciphertext768[MLKEM768_CIPHERTEXT_BYTES]; 433 .rank = rank,
407 struct encap_ctx encap768 = {
408 .public_key = &public_key768,
409 .ciphertext = ciphertext768,
410 .ciphertext_len = sizeof(ciphertext768),
411
412 .parse_public_key = mlkem768_parse_public_key,
413 .encap_external_entropy = mlkem768_encap_external_entropy,
414 };
415 struct MLKEM1024_public_key public_key1024;
416 uint8_t ciphertext1024[MLKEM1024_CIPHERTEXT_BYTES];
417 struct encap_ctx encap1024 = {
418 .public_key = &public_key1024,
419 .ciphertext = ciphertext1024,
420 .ciphertext_len = sizeof(ciphertext1024),
421
422 .parse_public_key = mlkem1024_parse_public_key,
423 .encap_external_entropy = mlkem1024_encap_external_entropy,
424 }; 434 };
425 435
426 if (size == 768) 436 return parse_test_file(fn, &encap_parse, &encap);
427 return parse_test_file(fn, &encap_parse, &encap768);
428 if (size == 1024)
429 return parse_test_file(fn, &encap_parse, &encap1024);
430
431 errx(1, "unknown encap test: size %zu", size);
432} 437}
433 438
434struct keygen_ctx { 439struct keygen_ctx {
435 struct parse *parse_ctx; 440 struct parse *parse_ctx;
436 441
437 void *private_key; 442 int rank;
438 void *encoded_public_key;
439 size_t encoded_public_key_len;
440 size_t private_key_len;
441 size_t public_key_len;
442
443 mlkem_generate_key_external_entropy_fn generate_key_external_entropy;
444 mlkem_encode_private_key_fn encode_private_key;
445}; 443};
446 444
447enum keygen_states { 445enum keygen_states {
@@ -492,27 +490,38 @@ static int
492MlkemKeygenFileTest(struct keygen_ctx *keygen) 490MlkemKeygenFileTest(struct keygen_ctx *keygen)
493{ 491{
494 struct parse *p = keygen->parse_ctx; 492 struct parse *p = keygen->parse_ctx;
493 MLKEM_private_key *priv_key = NULL;
495 CBS seed, public_key, private_key; 494 CBS seed, public_key, private_key;
496 uint8_t *encoded_private_key = NULL; 495 uint8_t *encoded_private_key = NULL;
497 size_t encoded_private_key_len = 0; 496 size_t encoded_private_key_len = 0;
497 uint8_t *encoded_public_key = NULL;
498 size_t encoded_public_key_len = 0;
498 int failed = 1; 499 int failed = 1;
499 500
500 parse_get_cbs(p, KEYGEN_SEED, &seed); 501 parse_get_cbs(p, KEYGEN_SEED, &seed);
501 parse_get_cbs(p, KEYGEN_PUBLIC_KEY, &public_key); 502 parse_get_cbs(p, KEYGEN_PUBLIC_KEY, &public_key);
502 parse_get_cbs(p, KEYGEN_PRIVATE_KEY, &private_key); 503 parse_get_cbs(p, KEYGEN_PRIVATE_KEY, &private_key);
503 504
504 if (!parse_length_equal(p, "seed", MLKEM_SEED_BYTES, CBS_len(&seed))) 505 if (!parse_length_equal(p, "seed", MLKEM_SEED_LENGTH, CBS_len(&seed)))
505 goto err; 506 goto err;
507
508 if ((priv_key = MLKEM_private_key_new(keygen->rank)) == NULL)
509 parse_errx(p, "MLKEM_public_key_free");
510
511 if (!MLKEM_generate_key_external_entropy(priv_key,
512 &encoded_public_key, &encoded_public_key_len, CBS_data(&seed))) {
513 parse_info(p, "generate_key_external_entropy");
514 goto err;
515 }
516
506 if (!parse_length_equal(p, "public key", 517 if (!parse_length_equal(p, "public key",
507 keygen->public_key_len, CBS_len(&public_key))) 518 encoded_public_key_len, CBS_len(&public_key)))
508 goto err; 519 goto err;
509 if (!parse_length_equal(p, "private key", 520 if (!parse_length_equal(p, "private key",
510 keygen->private_key_len, CBS_len(&private_key))) 521 MLKEM_private_key_encoded_length(priv_key), CBS_len(&private_key)))
511 goto err; 522 goto err;
512 523
513 keygen->generate_key_external_entropy(keygen->encoded_public_key, 524 if (!MLKEM_marshal_private_key(priv_key,
514 keygen->private_key, CBS_data(&seed));
515 if (!keygen->encode_private_key(keygen->private_key,
516 &encoded_private_key, &encoded_private_key_len)) { 525 &encoded_private_key, &encoded_private_key_len)) {
517 parse_info(p, "encode private key"); 526 parse_info(p, "encode private key");
518 goto err; 527 goto err;
@@ -521,10 +530,12 @@ MlkemKeygenFileTest(struct keygen_ctx *keygen)
521 failed = !parse_data_equal(p, "private key", &private_key, 530 failed = !parse_data_equal(p, "private key", &private_key,
522 encoded_private_key, encoded_private_key_len); 531 encoded_private_key, encoded_private_key_len);
523 failed |= !parse_data_equal(p, "public key", &public_key, 532 failed |= !parse_data_equal(p, "public key", &public_key,
524 keygen->encoded_public_key, keygen->encoded_public_key_len); 533 encoded_public_key, encoded_public_key_len);
525 534
526 err: 535 err:
536 MLKEM_private_key_free(priv_key);
527 freezero(encoded_private_key, encoded_private_key_len); 537 freezero(encoded_private_key, encoded_private_key_len);
538 freezero(encoded_public_key, encoded_public_key_len);
528 539
529 return failed; 540 return failed;
530} 541}
@@ -584,12 +595,15 @@ static int
584MlkemNistKeygenFileTest(struct keygen_ctx *keygen) 595MlkemNistKeygenFileTest(struct keygen_ctx *keygen)
585{ 596{
586 struct parse *p = keygen->parse_ctx; 597 struct parse *p = keygen->parse_ctx;
598 MLKEM_private_key *priv_key = NULL;
587 CBB seed_cbb; 599 CBB seed_cbb;
588 CBS z, d, ek, dk; 600 CBS z, d, ek, dk;
589 uint8_t seed[MLKEM_SEED_BYTES]; 601 uint8_t seed[MLKEM_SEED_LENGTH];
590 size_t seed_len; 602 size_t seed_len;
591 uint8_t *encoded_private_key = NULL; 603 uint8_t *encoded_private_key = NULL;
592 size_t encoded_private_key_len = 0; 604 size_t encoded_private_key_len = 0;
605 uint8_t *encoded_public_key = NULL;
606 size_t encoded_public_key_len = 0;
593 int failed = 1; 607 int failed = 1;
594 608
595 parse_get_cbs(p, NIST_KEYGEN_Z, &z); 609 parse_get_cbs(p, NIST_KEYGEN_Z, &z);
@@ -606,24 +620,33 @@ MlkemNistKeygenFileTest(struct keygen_ctx *keygen)
606 if (!CBB_finish(&seed_cbb, NULL, &seed_len)) 620 if (!CBB_finish(&seed_cbb, NULL, &seed_len))
607 parse_errx(p, "CBB_finish"); 621 parse_errx(p, "CBB_finish");
608 622
609 if (!parse_length_equal(p, "bogus z or d", MLKEM_SEED_BYTES, seed_len)) 623 if (!parse_length_equal(p, "bogus z or d", MLKEM_SEED_LENGTH, seed_len))
610 goto err; 624 goto err;
611 625
612 keygen->generate_key_external_entropy(keygen->encoded_public_key, 626 if ((priv_key = MLKEM_private_key_new(keygen->rank)) == NULL)
613 keygen->private_key, seed); 627 parse_errx(p, "MLKEM_private_key_new");
614 if (!keygen->encode_private_key(keygen->private_key, 628
629 if (!MLKEM_generate_key_external_entropy(priv_key,
630 &encoded_public_key, &encoded_public_key_len, seed)) {
631 parse_info(p, "MLKEM_generate_key_external_entropy");
632 goto err;
633 }
634
635 if (!MLKEM_marshal_private_key(priv_key,
615 &encoded_private_key, &encoded_private_key_len)) { 636 &encoded_private_key, &encoded_private_key_len)) {
616 parse_info(p, "encode private key"); 637 parse_info(p, "encode private key");
617 goto err; 638 goto err;
618 } 639 }
619 640
620 failed = !parse_data_equal(p, "public key", &ek, 641 failed = !parse_data_equal(p, "public key", &ek,
621 keygen->encoded_public_key, keygen->encoded_public_key_len); 642 encoded_public_key, encoded_public_key_len);
622 failed |= !parse_data_equal(p, "private key", &dk, 643 failed |= !parse_data_equal(p, "private key", &dk,
623 encoded_private_key, encoded_private_key_len); 644 encoded_private_key, encoded_private_key_len);
624 645
625 err: 646 err:
647 MLKEM_private_key_free(priv_key);
626 freezero(encoded_private_key, encoded_private_key_len); 648 freezero(encoded_private_key, encoded_private_key_len);
649 freezero(encoded_public_key, encoded_public_key_len);
627 650
628 return failed; 651 return failed;
629} 652}
@@ -645,73 +668,45 @@ static const struct test_parse nist_keygen_parse = {
645}; 668};
646 669
647static int 670static int
648mlkem_keygen_tests(const char *fn, size_t size, enum test_type test_type) 671mlkem_keygen_tests(const char *fn, int rank, enum test_type test_type)
649{ 672{
650 struct MLKEM768_private_key private_key768; 673 struct keygen_ctx keygen = {
651 uint8_t encoded_public_key768[MLKEM768_PUBLIC_KEY_BYTES]; 674 .rank = rank,
652 struct keygen_ctx keygen768 = {
653 .private_key = &private_key768,
654 .encoded_public_key = encoded_public_key768,
655 .encoded_public_key_len = sizeof(encoded_public_key768),
656 .private_key_len = MLKEM768_PRIVATE_KEY_BYTES,
657 .public_key_len = MLKEM768_PUBLIC_KEY_BYTES,
658 .generate_key_external_entropy =
659 mlkem768_generate_key_external_entropy,
660 .encode_private_key =
661 mlkem768_encode_private_key,
662 };
663 struct MLKEM1024_private_key private_key1024;
664 uint8_t encoded_public_key1024[MLKEM1024_PUBLIC_KEY_BYTES];
665 struct keygen_ctx keygen1024 = {
666 .private_key = &private_key1024,
667 .encoded_public_key = encoded_public_key1024,
668 .encoded_public_key_len = sizeof(encoded_public_key1024),
669 .private_key_len = MLKEM1024_PRIVATE_KEY_BYTES,
670 .public_key_len = MLKEM1024_PUBLIC_KEY_BYTES,
671
672 .generate_key_external_entropy =
673 mlkem1024_generate_key_external_entropy,
674 .encode_private_key =
675 mlkem1024_encode_private_key,
676 }; 675 };
677 676
678 if (size == 768 && test_type == TEST_TYPE_NORMAL) 677 if (test_type == TEST_TYPE_NORMAL)
679 return parse_test_file(fn, &keygen_parse, &keygen768); 678 return parse_test_file(fn, &keygen_parse, &keygen);
680 if (size == 768 && test_type == TEST_TYPE_NIST) 679 if (test_type == TEST_TYPE_NIST)
681 return parse_test_file(fn, &nist_keygen_parse, &keygen768); 680 return parse_test_file(fn, &nist_keygen_parse, &keygen);
682 if (size == 1024 && test_type == TEST_TYPE_NORMAL)
683 return parse_test_file(fn, &keygen_parse, &keygen1024);
684 if (size == 1024 && test_type == TEST_TYPE_NIST)
685 return parse_test_file(fn, &nist_keygen_parse, &keygen1024);
686 681
687 errx(1, "unknown keygen test: size %zu, type %d", size, test_type); 682 errx(1, "unknown keygen test: rank %d, type %d", rank, test_type);
688} 683}
689 684
690static int 685static int
691run_mlkem_test(const char *test, const char *fn) 686run_mlkem_test(const char *test, const char *fn)
692{ 687{
693 if (strcmp(test, "mlkem768_decap_tests") == 0) 688 if (strcmp(test, "mlkem768_decap_tests") == 0)
694 return mlkem_decap_tests(fn, 768, TEST_TYPE_NORMAL); 689 return mlkem_decap_tests(fn, RANK768, TEST_TYPE_NORMAL);
695 if (strcmp(test, "mlkem768_nist_decap_tests") == 0) 690 if (strcmp(test, "mlkem768_nist_decap_tests") == 0)
696 return mlkem_decap_tests(fn, 768, TEST_TYPE_NIST); 691 return mlkem_decap_tests(fn, RANK768, TEST_TYPE_NIST);
697 if (strcmp(test, "mlkem1024_decap_tests") == 0) 692 if (strcmp(test, "mlkem1024_decap_tests") == 0)
698 return mlkem_decap_tests(fn, 1024, TEST_TYPE_NORMAL); 693 return mlkem_decap_tests(fn, RANK1024, TEST_TYPE_NORMAL);
699 if (strcmp(test, "mlkem1024_nist_decap_tests") == 0) 694 if (strcmp(test, "mlkem1024_nist_decap_tests") == 0)
700 return mlkem_decap_tests(fn, 1024, TEST_TYPE_NIST); 695 return mlkem_decap_tests(fn, RANK1024, TEST_TYPE_NIST);
701 696
702 if (strcmp(test, "mlkem768_encap_tests") == 0) 697 if (strcmp(test, "mlkem768_encap_tests") == 0)
703 return mlkem_encap_tests(fn, 768); 698 return mlkem_encap_tests(fn, RANK768);
704 if (strcmp(test, "mlkem1024_encap_tests") == 0) 699 if (strcmp(test, "mlkem1024_encap_tests") == 0)
705 return mlkem_encap_tests(fn, 1024); 700 return mlkem_encap_tests(fn, RANK1024);
706 701
707 if (strcmp(test, "mlkem768_keygen_tests") == 0) 702 if (strcmp(test, "mlkem768_keygen_tests") == 0)
708 return mlkem_keygen_tests(fn, 768, TEST_TYPE_NORMAL); 703 return mlkem_keygen_tests(fn, RANK768, TEST_TYPE_NORMAL);
709 if (strcmp(test, "mlkem768_nist_keygen_tests") == 0) 704 if (strcmp(test, "mlkem768_nist_keygen_tests") == 0)
710 return mlkem_keygen_tests(fn, 768, TEST_TYPE_NIST); 705 return mlkem_keygen_tests(fn, RANK768, TEST_TYPE_NIST);
711 if (strcmp(test, "mlkem1024_keygen_tests") == 0) 706 if (strcmp(test, "mlkem1024_keygen_tests") == 0)
712 return mlkem_keygen_tests(fn, 1024, TEST_TYPE_NORMAL); 707 return mlkem_keygen_tests(fn, RANK1024, TEST_TYPE_NORMAL);
713 if (strcmp(test, "mlkem1024_nist_keygen_tests") == 0) 708 if (strcmp(test, "mlkem1024_nist_keygen_tests") == 0)
714 return mlkem_keygen_tests(fn, 1024, TEST_TYPE_NIST); 709 return mlkem_keygen_tests(fn, RANK1024, TEST_TYPE_NIST);
715 710
716 errx(1, "unknown test %s (test file %s)", test, fn); 711 errx(1, "unknown test %s (test file %s)", test, fn);
717} 712}
diff --git a/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.c b/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.c
index 1bb2ed3a8b..d2e0fbd7c7 100644
--- a/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.c
+++ b/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mlkem_tests_util.c,v 1.5 2024/12/26 00:04:24 tb Exp $ */ 1/* $OpenBSD: mlkem_tests_util.c,v 1.10 2025/08/15 14:47:54 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Google Inc. 3 * Copyright (c) 2024 Google Inc.
4 * Copyright (c) 2024 Bob Beck <beck@obtuse.com> 4 * Copyright (c) 2024 Bob Beck <beck@obtuse.com>
@@ -22,11 +22,6 @@
22#include <stdio.h> 22#include <stdio.h>
23#include <string.h> 23#include <string.h>
24 24
25#include "bytestring.h"
26#include "mlkem.h"
27
28#include "mlkem_internal.h"
29
30#include "mlkem_tests_util.h" 25#include "mlkem_tests_util.h"
31 26
32static void 27static void
@@ -59,209 +54,3 @@ compare_data(const uint8_t *want, const uint8_t *got, size_t len, const char *ms
59 54
60 return 1; 55 return 1;
61} 56}
62
63int
64mlkem768_encode_private_key(const void *private_key, uint8_t **out_buf,
65 size_t *out_len)
66{
67 CBB cbb;
68 int ret = 0;
69
70 if (!CBB_init(&cbb, MLKEM768_PUBLIC_KEY_BYTES))
71 goto err;
72 if (!MLKEM768_marshal_private_key(&cbb, private_key))
73 goto err;
74 if (!CBB_finish(&cbb, out_buf, out_len))
75 goto err;
76
77 ret = 1;
78
79 err:
80 CBB_cleanup(&cbb);
81
82 return ret;
83}
84
85int
86mlkem768_encode_public_key(const void *public_key, uint8_t **out_buf,
87 size_t *out_len)
88{
89 CBB cbb;
90 int ret = 0;
91
92 if (!CBB_init(&cbb, MLKEM768_PUBLIC_KEY_BYTES))
93 goto err;
94 if (!MLKEM768_marshal_public_key(&cbb, public_key))
95 goto err;
96 if (!CBB_finish(&cbb, out_buf, out_len))
97 goto err;
98
99 ret = 1;
100
101 err:
102 CBB_cleanup(&cbb);
103
104 return ret;
105}
106
107int
108mlkem1024_encode_private_key(const void *private_key, uint8_t **out_buf,
109 size_t *out_len)
110{
111 CBB cbb;
112 int ret = 0;
113
114 if (!CBB_init(&cbb, MLKEM1024_PUBLIC_KEY_BYTES))
115 goto err;
116 if (!MLKEM1024_marshal_private_key(&cbb, private_key))
117 goto err;
118 if (!CBB_finish(&cbb, out_buf, out_len))
119 goto err;
120
121 ret = 1;
122
123 err:
124 CBB_cleanup(&cbb);
125
126 return ret;
127}
128
129int
130mlkem1024_encode_public_key(const void *public_key, uint8_t **out_buf,
131 size_t *out_len)
132{
133 CBB cbb;
134 int ret = 0;
135
136 if (!CBB_init(&cbb, MLKEM1024_PUBLIC_KEY_BYTES))
137 goto err;
138 if (!MLKEM1024_marshal_public_key(&cbb, public_key))
139 goto err;
140 if (!CBB_finish(&cbb, out_buf, out_len))
141 goto err;
142
143 ret = 1;
144
145 err:
146 CBB_cleanup(&cbb);
147
148 return ret;
149}
150
151int
152mlkem768_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
153 const uint8_t *ciphertext, size_t ciphertext_len, const void *private_key)
154{
155 return MLKEM768_decap(out_shared_secret, ciphertext, ciphertext_len,
156 private_key);
157}
158
159void
160mlkem768_encap(uint8_t *out_ciphertext,
161 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
162 const void *public_key)
163{
164 MLKEM768_encap(out_ciphertext, out_shared_secret, public_key);
165}
166
167void
168mlkem768_encap_external_entropy(uint8_t *out_ciphertext,
169 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
170 const void *public_key, const uint8_t entropy[MLKEM_ENCAP_ENTROPY])
171{
172 MLKEM768_encap_external_entropy(out_ciphertext, out_shared_secret,
173 public_key, entropy);
174}
175
176void
177mlkem768_generate_key(uint8_t *out_encoded_public_key,
178 uint8_t optional_out_seed[MLKEM_SEED_BYTES], void *out_private_key)
179{
180 MLKEM768_generate_key(out_encoded_public_key, optional_out_seed,
181 out_private_key);
182}
183
184void
185mlkem768_generate_key_external_entropy(uint8_t *out_encoded_public_key,
186 void *out_private_key, const uint8_t entropy[MLKEM_SEED_BYTES])
187{
188 MLKEM768_generate_key_external_entropy(out_encoded_public_key,
189 out_private_key, entropy);
190}
191
192int
193mlkem768_parse_private_key(void *out_private_key, CBS *private_key_cbs)
194{
195 return MLKEM768_parse_private_key(out_private_key, private_key_cbs);
196}
197
198int
199mlkem768_parse_public_key(void *out_public_key, CBS *public_key_cbs)
200{
201 return MLKEM768_parse_public_key(out_public_key, public_key_cbs);
202}
203
204void
205mlkem768_public_from_private(void *out_public_key, const void *private_key)
206{
207 MLKEM768_public_from_private(out_public_key, private_key);
208}
209
210int
211mlkem1024_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
212 const uint8_t *ciphertext, size_t ciphertext_len, const void *private_key)
213{
214 return MLKEM1024_decap(out_shared_secret, ciphertext, ciphertext_len,
215 private_key);
216}
217
218void
219mlkem1024_encap(uint8_t *out_ciphertext,
220 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
221 const void *public_key)
222{
223 MLKEM1024_encap(out_ciphertext, out_shared_secret, public_key);
224}
225
226void
227mlkem1024_encap_external_entropy(uint8_t *out_ciphertext,
228 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
229 const void *public_key, const uint8_t entropy[MLKEM_ENCAP_ENTROPY])
230{
231 MLKEM1024_encap_external_entropy(out_ciphertext, out_shared_secret,
232 public_key, entropy);
233}
234
235void
236mlkem1024_generate_key(uint8_t *out_encoded_public_key,
237 uint8_t optional_out_seed[MLKEM_SEED_BYTES], void *out_private_key)
238{
239 MLKEM1024_generate_key(out_encoded_public_key, optional_out_seed,
240 out_private_key);
241}
242
243void
244mlkem1024_generate_key_external_entropy(uint8_t *out_encoded_public_key,
245 void *out_private_key, const uint8_t entropy[MLKEM_SEED_BYTES])
246{
247 MLKEM1024_generate_key_external_entropy(out_encoded_public_key,
248 out_private_key, entropy);
249}
250
251int
252mlkem1024_parse_private_key(void *out_private_key, CBS *private_key_cbs)
253{
254 return MLKEM1024_parse_private_key(out_private_key, private_key_cbs);
255}
256
257void
258mlkem1024_public_from_private(void *out_public_key, const void *private_key)
259{
260 MLKEM1024_public_from_private(out_public_key, private_key);
261}
262
263int
264mlkem1024_parse_public_key(void *out_public_key, CBS *public_key_cbs)
265{
266 return MLKEM1024_parse_public_key(out_public_key, public_key_cbs);
267}
diff --git a/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.h b/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.h
index 7fbe6f76a9..514a309112 100644
--- a/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.h
+++ b/src/regress/lib/libcrypto/mlkem/mlkem_tests_util.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: mlkem_tests_util.h,v 1.4 2024/12/26 00:04:24 tb Exp $ */ 1/* $OpenBSD: mlkem_tests_util.h,v 1.9 2025/08/15 14:47:54 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Bob Beck <beck@obtuse.com> 3 * Copyright (c) 2024 Bob Beck <beck@obtuse.com>
4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
@@ -22,68 +22,7 @@
22#include <stddef.h> 22#include <stddef.h>
23#include <stdint.h> 23#include <stdint.h>
24 24
25#include "bytestring.h"
26
27#include "mlkem.h"
28#include "mlkem_internal.h"
29
30int compare_data(const uint8_t *want, const uint8_t *got, size_t len, 25int compare_data(const uint8_t *want, const uint8_t *got, size_t len,
31 const char *msg); 26 const char *msg);
32 27
33int mlkem768_encode_private_key(const void *priv, uint8_t **out_buf,
34 size_t *out_len);
35int mlkem768_encode_public_key(const void *pub, uint8_t **out_buf,
36 size_t *out_len);
37int mlkem1024_encode_private_key(const void *priv, uint8_t **out_buf,
38 size_t *out_len);
39int mlkem1024_encode_public_key(const void *pub, uint8_t **out_buf,
40 size_t *out_len);
41
42int mlkem768_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
43 const uint8_t *ciphertext, size_t ciphertext_len, const void *priv);
44void mlkem768_encap(uint8_t *out_ciphertext,
45 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], const void *pub);
46void mlkem768_encap_external_entropy(uint8_t *out_ciphertext,
47 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], const void *pub,
48 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]);
49void mlkem768_generate_key(uint8_t *out_encoded_public_key,
50 uint8_t optional_out_seed[MLKEM_SEED_BYTES], void *out_private_key);
51void mlkem768_generate_key_external_entropy(uint8_t *out_encoded_public_key,
52 void *out_private_key, const uint8_t entropy[MLKEM_SEED_BYTES]);
53int mlkem768_parse_private_key(void *priv, CBS *private_key_cbs);
54int mlkem768_parse_public_key(void *pub, CBS *in);
55void mlkem768_public_from_private(void *out_public_key, const void *private_key);
56
57int mlkem1024_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES],
58 const uint8_t *ciphertext, size_t ciphertext_len, const void *priv);
59void mlkem1024_encap(uint8_t *out_ciphertext,
60 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], const void *pub);
61void mlkem1024_encap_external_entropy(uint8_t *out_ciphertext,
62 uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], const void *pub,
63 const uint8_t entropy[MLKEM_ENCAP_ENTROPY]);
64void mlkem1024_generate_key(uint8_t *out_encoded_public_key,
65 uint8_t optional_out_seed[MLKEM_SEED_BYTES], void *out_private_key);
66void mlkem1024_generate_key_external_entropy(uint8_t *out_encoded_public_key,
67 void *out_private_key, const uint8_t entropy[MLKEM_SEED_BYTES]);
68int mlkem1024_parse_private_key(void *priv, CBS *private_key_cbs);
69int mlkem1024_parse_public_key(void *pub, CBS *in);
70void mlkem1024_public_from_private(void *out_public_key, const void *private_key);
71
72typedef int (*mlkem_encode_private_key_fn)(const void *, uint8_t **, size_t *);
73typedef int (*mlkem_encode_public_key_fn)(const void *, uint8_t **, size_t *);
74typedef int (*mlkem_decap_fn)(uint8_t [MLKEM_SHARED_SECRET_BYTES],
75 const uint8_t *, size_t, const void *);
76typedef void (*mlkem_encap_fn)(uint8_t *, uint8_t [MLKEM_SHARED_SECRET_BYTES],
77 const void *);
78typedef void (*mlkem_encap_external_entropy_fn)(uint8_t *,
79 uint8_t [MLKEM_SHARED_SECRET_BYTES], const void *,
80 const uint8_t [MLKEM_ENCAP_ENTROPY]);
81typedef void (*mlkem_generate_key_fn)(uint8_t *, uint8_t *, void *);
82typedef void (*mlkem_generate_key_external_entropy_fn)(uint8_t *, void *,
83 const uint8_t [MLKEM_SEED_BYTES]);
84typedef int (*mlkem_parse_private_key_fn)(void *, CBS *);
85typedef int (*mlkem_parse_public_key_fn)(void *, CBS *);
86typedef void (*mlkem_public_from_private_fn)(void *out_public_key,
87 const void *private_key);
88
89#endif /* MLKEM_TEST_UTIL_H */ 28#endif /* MLKEM_TEST_UTIL_H */
diff --git a/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c b/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c
index 23b3d8b261..f802324189 100644
--- a/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c
+++ b/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mlkem_unittest.c,v 1.6 2024/12/26 12:35:25 tb Exp $ */ 1/* $OpenBSD: mlkem_unittest.c,v 1.15 2025/08/17 19:26:35 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Google Inc. 3 * Copyright (c) 2024 Google Inc.
4 * Copyright (c) 2024 Bob Beck <beck@obtuse.com> 4 * Copyright (c) 2024 Bob Beck <beck@obtuse.com>
@@ -22,132 +22,201 @@
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24 24
25#include "bytestring.h" 25#include <openssl/mlkem.h>
26#include "mlkem.h"
27 26
27#include "mlkem_internal.h"
28#include "mlkem_tests_util.h" 28#include "mlkem_tests_util.h"
29 29
30struct unittest_ctx {
31 void *priv;
32 void *pub;
33 void *priv2;
34 void *pub2;
35 uint8_t *encoded_public_key;
36 size_t encoded_public_key_len;
37 uint8_t *ciphertext;
38 size_t ciphertext_len;
39 mlkem_decap_fn decap;
40 mlkem_encap_fn encap;
41 mlkem_generate_key_fn generate_key;
42 mlkem_parse_private_key_fn parse_private_key;
43 mlkem_parse_public_key_fn parse_public_key;
44 mlkem_encode_private_key_fn encode_private_key;
45 mlkem_encode_public_key_fn encode_public_key;
46 mlkem_public_from_private_fn public_from_private;
47};
48
49static int 30static int
50MlKemUnitTest(struct unittest_ctx *ctx) 31MlKemUnitTest(int rank)
51{ 32{
52 uint8_t shared_secret1[MLKEM_SHARED_SECRET_BYTES]; 33 MLKEM_private_key *priv = NULL, *priv2 = NULL, *priv3 = NULL;
53 uint8_t shared_secret2[MLKEM_SHARED_SECRET_BYTES]; 34 MLKEM_public_key *pub = NULL, *pub2 = NULL, *pub3 = NULL;
35 uint8_t *encoded_public_key = NULL, *ciphertext = NULL,
36 *shared_secret2 = NULL, *shared_secret1 = NULL,
37 *encoded_private_key = NULL, *tmp_buf = NULL, *seed_buf = NULL;
38 size_t encoded_public_key_len, ciphertext_len,
39 encoded_private_key_len, tmp_buf_len;
54 uint8_t first_two_bytes[2]; 40 uint8_t first_two_bytes[2];
55 uint8_t *encoded_private_key = NULL, *tmp_buf = NULL; 41 size_t s_len = 0;
56 size_t encoded_private_key_len, tmp_buf_len;
57 CBS cbs;
58 int failed = 0; 42 int failed = 0;
59 43
60 ctx->generate_key(ctx->encoded_public_key, NULL, ctx->priv); 44 if ((pub = MLKEM_public_key_new(rank)) == NULL) {
45 warnx("public_key_new");
46 failed |= 1;
47 }
48
49 if ((pub2 = MLKEM_public_key_new(rank)) == NULL) {
50 warnx("public_key_new");
51 failed |= 1;
52 }
53
54 if ((priv = MLKEM_private_key_new(rank)) == NULL) {
55 warnx("private_key_new");
56 failed |= 1;
57 }
58
59 if ((priv2 = MLKEM_private_key_new(rank)) == NULL) {
60 warnx("private_key_new");
61 failed |= 1;
62 }
63
64 if (!MLKEM_generate_key(priv, &encoded_public_key,
65 &encoded_public_key_len, &seed_buf, &s_len)) {
66 warnx("generate_key failed");
67 failed |= 1;
68 }
69
70 if (s_len != MLKEM_SEED_LENGTH) {
71 warnx("seed length %zu != %d", s_len, MLKEM_SEED_LENGTH);
72 failed |= 1;
73 }
74
75 if ((priv3 = MLKEM_private_key_new(rank)) == NULL) {
76 warnx("private_key_new");
77 failed |= 1;
78 }
79
80 if ((pub3 = MLKEM_public_key_new(rank)) == NULL) {
81 warnx("public_key_new");
82 failed |= 1;
83 }
61 84
62 memcpy(first_two_bytes, ctx->encoded_public_key, sizeof(first_two_bytes)); 85 if (!MLKEM_private_key_from_seed(priv3, seed_buf, s_len)) {
63 memset(ctx->encoded_public_key, 0xff, sizeof(first_two_bytes)); 86 warnx("private_key_from_seed failed");
87 failed |= 1;
88 }
89
90 free(seed_buf);
91 seed_buf = NULL;
64 92
65 CBS_init(&cbs, ctx->encoded_public_key, ctx->encoded_public_key_len); 93 if (!MLKEM_public_from_private(priv3, pub3)) {
94 warnx("public_from_private");
95 failed |= 1;
96 }
97
98 memcpy(first_two_bytes, encoded_public_key, sizeof(first_two_bytes));
99 memset(encoded_public_key, 0xff, sizeof(first_two_bytes));
66 100
67 /* Parsing should fail because the first coefficient is >= kPrime. */ 101 /* Parsing should fail because the first coefficient is >= kPrime. */
68 if (ctx->parse_public_key(ctx->pub, &cbs)) { 102 if (MLKEM_parse_public_key(pub, encoded_public_key,
103 encoded_public_key_len)) {
69 warnx("parse_public_key should have failed"); 104 warnx("parse_public_key should have failed");
70 failed |= 1; 105 failed |= 1;
71 } 106 }
72 107
73 memcpy(ctx->encoded_public_key, first_two_bytes, sizeof(first_two_bytes)); 108 memcpy(encoded_public_key, first_two_bytes, sizeof(first_two_bytes));
74 CBS_init(&cbs, ctx->encoded_public_key, ctx->encoded_public_key_len); 109
75 if (!ctx->parse_public_key(ctx->pub, &cbs)) { 110 MLKEM_public_key_free(pub);
76 warnx("MLKEM768_parse_public_key"); 111 if ((pub = MLKEM_public_key_new(rank)) == NULL) {
112 warnx("public_key_new");
113 failed |= 1;
114 }
115 if (!MLKEM_parse_public_key(pub, encoded_public_key,
116 encoded_public_key_len)) {
117 warnx("MLKEM_parse_public_key");
77 failed |= 1; 118 failed |= 1;
78 } 119 }
79 120
80 if (CBS_len(&cbs) != 0u) { 121 if (!MLKEM_marshal_public_key(pub, &tmp_buf, &tmp_buf_len)) {
81 warnx("CBS_len must be 0"); 122 warnx("marshal_public_key");
123 failed |= 1;
124 }
125 if (encoded_public_key_len != tmp_buf_len) {
126 warnx("encoded public key lengths differ %d != %d",
127 (int) encoded_public_key_len, (int) tmp_buf_len);
82 failed |= 1; 128 failed |= 1;
83 } 129 }
84 130
85 if (!ctx->encode_public_key(ctx->pub, &tmp_buf, &tmp_buf_len)) { 131 if (compare_data(encoded_public_key, tmp_buf, tmp_buf_len,
86 warnx("encode_public_key"); 132 "encoded public keys") != 0) {
133 warnx("compare_data");
87 failed |= 1; 134 failed |= 1;
88 } 135 }
89 if (ctx->encoded_public_key_len != tmp_buf_len) { 136 free(tmp_buf);
90 warnx("encoded public key lengths differ"); 137 tmp_buf = NULL;
138 tmp_buf_len = 0;
139
140 if (!MLKEM_marshal_public_key(pub3, &tmp_buf, &tmp_buf_len)) {
141 warnx("marshal_public_key");
142 failed |= 1;
143 }
144 if (encoded_public_key_len != tmp_buf_len) {
145 warnx("encoded public key lengths differ %d != %d",
146 (int) encoded_public_key_len, (int) tmp_buf_len);
91 failed |= 1; 147 failed |= 1;
92 } 148 }
93 149
94 if (compare_data(ctx->encoded_public_key, tmp_buf, tmp_buf_len, 150 if (compare_data(encoded_public_key, tmp_buf, tmp_buf_len,
95 "encoded public keys") != 0) { 151 "encoded public keys") != 0) {
96 warnx("compare_data"); 152 warnx("compare_data");
97 failed |= 1; 153 failed |= 1;
98 } 154 }
99 free(tmp_buf); 155 free(tmp_buf);
100 tmp_buf = NULL; 156 tmp_buf = NULL;
157 tmp_buf_len = 0;
101 158
102 ctx->public_from_private(ctx->pub2, ctx->priv); 159 if (!MLKEM_public_from_private(priv, pub2)) {
103 if (!ctx->encode_public_key(ctx->pub2, &tmp_buf, &tmp_buf_len)) { 160 warnx("public_from_private");
104 warnx("encode_public_key"); 161 failed |= 1;
162 }
163 if (!MLKEM_marshal_public_key(pub2, &tmp_buf, &tmp_buf_len)) {
164 warnx("marshal_public_key");
105 failed |= 1; 165 failed |= 1;
106 } 166 }
107 if (ctx->encoded_public_key_len != tmp_buf_len) { 167 if (encoded_public_key_len != tmp_buf_len) {
108 warnx("encoded public key lengths differ"); 168 warnx("encoded public key lengths differ %d %d",
169 (int) encoded_public_key_len, (int) tmp_buf_len);
109 failed |= 1; 170 failed |= 1;
110 } 171 }
111 172
112 if (compare_data(ctx->encoded_public_key, tmp_buf, tmp_buf_len, 173 if (compare_data(encoded_public_key, tmp_buf, tmp_buf_len,
113 "encoded public keys") != 0) { 174 "encoded public keys") != 0) {
114 warnx("compare_data"); 175 warnx("compare_data");
115 failed |= 1; 176 failed |= 1;
116 } 177 }
117 free(tmp_buf); 178 free(tmp_buf);
118 tmp_buf = NULL; 179 tmp_buf = NULL;
180 tmp_buf_len = 0;
119 181
120 if (!ctx->encode_private_key(ctx->priv, &encoded_private_key, 182 if (!MLKEM_marshal_private_key(priv, &encoded_private_key,
121 &encoded_private_key_len)) { 183 &encoded_private_key_len)) {
122 warnx("mlkem768_encode_private_key"); 184 warnx("marshal_private_key");
123 failed |= 1; 185 failed |= 1;
124 } 186 }
125 187
126 memcpy(first_two_bytes, encoded_private_key, sizeof(first_two_bytes)); 188 memcpy(first_two_bytes, encoded_private_key, sizeof(first_two_bytes));
127 memset(encoded_private_key, 0xff, sizeof(first_two_bytes)); 189 memset(encoded_private_key, 0xff, sizeof(first_two_bytes));
128 CBS_init(&cbs, encoded_private_key, encoded_private_key_len);
129 190
130 /* Parsing should fail because the first coefficient is >= kPrime. */ 191 /* Parsing should fail because the first coefficient is >= kPrime. */
131 if (ctx->parse_private_key(ctx->priv2, &cbs)) { 192 if (MLKEM_parse_private_key(priv2, encoded_private_key,
132 warnx("MLKEM768_parse_private_key should have failed"); 193 encoded_private_key_len)) {
194 warnx("parse_private_key should have failed");
133 failed |= 1; 195 failed |= 1;
134 } 196 }
135 197
136 memcpy(encoded_private_key, first_two_bytes, sizeof(first_two_bytes)); 198 memcpy(encoded_private_key, first_two_bytes, sizeof(first_two_bytes));
137 CBS_init(&cbs, encoded_private_key, encoded_private_key_len);
138 199
139 if (!ctx->parse_private_key(ctx->priv2, &cbs)) { 200 MLKEM_private_key_free(priv2);
140 warnx("MLKEM768_parse_private_key"); 201 priv2 = NULL;
202
203 if ((priv2 = MLKEM_private_key_new(rank)) == NULL) {
204 warnx("private_key_new");
205 failed |= 1;
206 }
207 if (!MLKEM_parse_private_key(priv2, encoded_private_key,
208 encoded_private_key_len)) {
209 warnx("parse_private_key");
141 failed |= 1; 210 failed |= 1;
142 } 211 }
143 212
144 if (!ctx->encode_private_key(ctx->priv2, &tmp_buf, &tmp_buf_len)) { 213 if (!MLKEM_marshal_private_key(priv2, &tmp_buf, &tmp_buf_len)) {
145 warnx("encode_private_key"); 214 warnx("marshal_private_key");
146 failed |= 1; 215 failed |= 1;
147 } 216 }
148 217
149 if (encoded_private_key_len != tmp_buf_len) { 218 if (encoded_private_key_len != tmp_buf_len) {
150 warnx("encode private key lengths differ"); 219 warnx("encoded private key lengths differ");
151 failed |= 1; 220 failed |= 1;
152 } 221 }
153 222
@@ -160,100 +229,79 @@ MlKemUnitTest(struct unittest_ctx *ctx)
160 free(tmp_buf); 229 free(tmp_buf);
161 tmp_buf = NULL; 230 tmp_buf = NULL;
162 231
163 ctx->encap(ctx->ciphertext, shared_secret1, ctx->pub); 232 if (!MLKEM_encap(pub, &ciphertext, &ciphertext_len, &shared_secret1,
164 ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len, 233 &s_len)) {
165 ctx->priv); 234 warnx("encap failed using pub");
166 if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES, 235 failed |= 1;
236 }
237
238 if (s_len != MLKEM_SHARED_SECRET_LENGTH) {
239 warnx("seed length %zu != %d", s_len,
240 MLKEM_SHARED_SECRET_LENGTH);
241 failed |= 1;
242 }
243
244 if (!MLKEM_decap(priv, ciphertext, ciphertext_len,
245 &shared_secret2, &s_len)) {
246 warnx("decap() failed using priv");
247 failed |= 1;
248 }
249
250 if (s_len != MLKEM_SHARED_SECRET_LENGTH) {
251 warnx("seed length %zu != %d", s_len,
252 MLKEM_SHARED_SECRET_LENGTH);
253 failed |= 1;
254 }
255
256 if (compare_data(shared_secret1, shared_secret2, s_len,
167 "shared secrets with priv") != 0) { 257 "shared secrets with priv") != 0) {
168 warnx("compare_data"); 258 warnx("compare_data");
169 failed |= 1; 259 failed |= 1;
170 } 260 }
171 261
172 ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len, 262 free(shared_secret2);
173 ctx->priv2); 263 shared_secret2 = NULL;
174 if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES, 264
265 if (!MLKEM_decap(priv2, ciphertext, ciphertext_len,
266 &shared_secret2, &s_len)){
267 warnx("decap() failed using priv2");
268 failed |= 1;
269 }
270
271 if (s_len != MLKEM_SHARED_SECRET_LENGTH) {
272 warnx("seed length %zu != %d", s_len,
273 MLKEM_SHARED_SECRET_LENGTH);
274 failed |= 1;
275 }
276
277 if (compare_data(shared_secret1, shared_secret2, s_len,
175 "shared secrets with priv2") != 0) { 278 "shared secrets with priv2") != 0) {
176 warnx("compare_data"); 279 warnx("compare_data");
177 failed |= 1; 280 failed |= 1;
178 } 281 }
179 282
283 MLKEM_public_key_free(pub);
284 MLKEM_public_key_free(pub2);
285 MLKEM_public_key_free(pub3);
286 MLKEM_private_key_free(priv);
287 MLKEM_private_key_free(priv2);
288 MLKEM_private_key_free(priv3);
289 free(encoded_public_key);
290 free(ciphertext);
180 free(encoded_private_key); 291 free(encoded_private_key);
292 free(shared_secret1);
293 free(shared_secret2);
181 294
182 return failed; 295 return failed;
183} 296}
184 297
185static int
186mlkem768_unittest(void)
187{
188 struct MLKEM768_private_key mlkem768_priv, mlkem768_priv2;
189 struct MLKEM768_public_key mlkem768_pub, mlkem768_pub2;
190 uint8_t mlkem768_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES];
191 uint8_t mlkem768_ciphertext[MLKEM768_CIPHERTEXT_BYTES];
192 struct unittest_ctx mlkem768_test = {
193 .priv = &mlkem768_priv,
194 .pub = &mlkem768_pub,
195 .priv2 = &mlkem768_priv2,
196 .pub2 = &mlkem768_pub2,
197 .encoded_public_key = mlkem768_encoded_public_key,
198 .encoded_public_key_len = sizeof(mlkem768_encoded_public_key),
199 .ciphertext = mlkem768_ciphertext,
200 .ciphertext_len = sizeof(mlkem768_ciphertext),
201 .decap = mlkem768_decap,
202 .encap = mlkem768_encap,
203 .generate_key = mlkem768_generate_key,
204 .parse_private_key = mlkem768_parse_private_key,
205 .parse_public_key = mlkem768_parse_public_key,
206 .encode_private_key = mlkem768_encode_private_key,
207 .encode_public_key = mlkem768_encode_public_key,
208 .public_from_private = mlkem768_public_from_private,
209 };
210
211 return MlKemUnitTest(&mlkem768_test);
212}
213
214static int
215mlkem1024_unittest(void)
216{
217 struct MLKEM1024_private_key mlkem1024_priv, mlkem1024_priv2;
218 struct MLKEM1024_public_key mlkem1024_pub, mlkem1024_pub2;
219 uint8_t mlkem1024_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES];
220 uint8_t mlkem1024_ciphertext[MLKEM1024_CIPHERTEXT_BYTES];
221 struct unittest_ctx mlkem1024_test = {
222 .priv = &mlkem1024_priv,
223 .pub = &mlkem1024_pub,
224 .priv2 = &mlkem1024_priv2,
225 .pub2 = &mlkem1024_pub2,
226 .encoded_public_key = mlkem1024_encoded_public_key,
227 .encoded_public_key_len = sizeof(mlkem1024_encoded_public_key),
228 .ciphertext = mlkem1024_ciphertext,
229 .ciphertext_len = sizeof(mlkem1024_ciphertext),
230 .decap = mlkem1024_decap,
231 .encap = mlkem1024_encap,
232 .generate_key = mlkem1024_generate_key,
233 .parse_private_key = mlkem1024_parse_private_key,
234 .parse_public_key = mlkem1024_parse_public_key,
235 .encode_private_key = mlkem1024_encode_private_key,
236 .encode_public_key = mlkem1024_encode_public_key,
237 .public_from_private = mlkem1024_public_from_private,
238 };
239
240 return MlKemUnitTest(&mlkem1024_test);
241}
242
243int 298int
244main(void) 299main(void)
245{ 300{
246 int failed = 0; 301 int failed = 0;
247 302
248 /* 303 failed |= MlKemUnitTest(RANK768);
249 * XXX - this is split into two helper functions since having a few 304 failed |= MlKemUnitTest(RANK1024);
250 * ML-KEM key blobs on the stack makes Emscripten's stack explode,
251 * leading to inscrutable silent failures unles ASAN is enabled.
252 * Go figure.
253 */
254
255 failed |= mlkem768_unittest();
256 failed |= mlkem1024_unittest();
257 305
258 return failed; 306 return failed;
259} 307}
diff --git a/src/regress/lib/libcrypto/mlkem/parse_test_file.c b/src/regress/lib/libcrypto/mlkem/parse_test_file.c
index b68dc50431..9f3e5f3a1a 100644
--- a/src/regress/lib/libcrypto/mlkem/parse_test_file.c
+++ b/src/regress/lib/libcrypto/mlkem/parse_test_file.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: parse_test_file.c,v 1.4 2025/04/13 09:14:56 tb Exp $ */ 1/* $OpenBSD: parse_test_file.c,v 1.6 2025/06/03 10:29:37 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
@@ -646,7 +646,8 @@ parse_reinit(struct parse *p)
646 p->state.running_test_case = 0; 646 p->state.running_test_case = 0;
647 parse_line_data_clear(p); 647 parse_line_data_clear(p);
648 tctx->finish(p->ctx); 648 tctx->finish(p->ctx);
649 tctx->init(p->ctx, p); 649 if (!tctx->init(p->ctx, p))
650 parse_errx(p, "init failed");
650} 651}
651 652
652static int 653static int
@@ -708,7 +709,8 @@ parse_init(struct parse *p, const char *fn, const struct test_parse *tctx,
708 parse_state_init(&p->state, tctx->num_states, tctx->num_instructions); 709 parse_state_init(&p->state, tctx->num_states, tctx->num_instructions);
709 p->tctx = tctx; 710 p->tctx = tctx;
710 p->ctx = ctx; 711 p->ctx = ctx;
711 tctx->init(ctx, p); 712 if (!tctx->init(p->ctx, p))
713 parse_errx(p, "init failed");
712} 714}
713 715
714static int 716static int
@@ -734,7 +736,10 @@ parse_next_line(struct parse *p)
734static void 736static void
735parse_finish(struct parse *p) 737parse_finish(struct parse *p)
736{ 738{
739 const struct test_parse *tctx = p->tctx;
740
737 parse_state_finish(&p->state); 741 parse_state_finish(&p->state);
742 tctx->finish(p->ctx);
738 743
739 free(p->buf); 744 free(p->buf);
740 745
diff --git a/src/regress/lib/libcrypto/sha/Makefile b/src/regress/lib/libcrypto/sha/Makefile
index 6ec223116d..c6ab0398ba 100644
--- a/src/regress/lib/libcrypto/sha/Makefile
+++ b/src/regress/lib/libcrypto/sha/Makefile
@@ -1,9 +1,15 @@
1# $OpenBSD: Makefile,v 1.5 2022/09/01 14:02:41 tb Exp $ 1# $OpenBSD: Makefile,v 1.6 2025/05/22 03:35:40 joshua Exp $
2 2
3PROG = sha_test 3PROG = sha_test
4LDADD = -lcrypto 4LDADD = -lcrypto
5DPADD = ${LIBCRYPTO} 5DPADD = ${LIBCRYPTO}
6WARNINGS = Yes 6WARNINGS = Yes
7CFLAGS += -DLIBRESSL_INTERNAL -Werror 7CFLAGS += -DLIBRESSL_INTERNAL -Werror
8CFLAGS += -I${.CURDIR}/../test
9SRCS += sha_test.c
10SRCS += test.c
11SRCS += test_util.c
12
13.PATH: ${.CURDIR}/../test
8 14
9.include <bsd.regress.mk> 15.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/sha/sha_test.c b/src/regress/lib/libcrypto/sha/sha_test.c
index 82a0c4cceb..904924c890 100644
--- a/src/regress/lib/libcrypto/sha/sha_test.c
+++ b/src/regress/lib/libcrypto/sha/sha_test.c
@@ -1,6 +1,6 @@
1/* $OpenBSD: sha_test.c,v 1.6 2023/07/19 15:11:42 joshua Exp $ */ 1/* $OpenBSD: sha_test.c,v 1.7 2025/05/22 03:35:40 joshua Exp $ */
2/* 2/*
3 * Copyright (c) 2022, 2023 Joshua Sing <joshua@hypera.dev> 3 * Copyright (c) 2022, 2023, 2025 Joshua Sing <joshua@joshuasing.dev>
4 * 4 *
5 * Permission to use, copy, modify, and distribute this software for any 5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above 6 * purpose with or without fee is hereby granted, provided that the above
@@ -21,6 +21,8 @@
21#include <stdint.h> 21#include <stdint.h>
22#include <string.h> 22#include <string.h>
23 23
24#include "test.h"
25
24struct sha_test { 26struct sha_test {
25 const int algorithm; 27 const int algorithm;
26 const uint8_t in[128]; 28 const uint8_t in[128];
@@ -677,260 +679,240 @@ typedef unsigned char *(*sha_hash_func)(const unsigned char *, size_t,
677 unsigned char *); 679 unsigned char *);
678 680
679static int 681static int
680sha_hash_from_algorithm(int algorithm, const char **out_label, 682sha_hash_from_algorithm(int algorithm, sha_hash_func *out_func,
681 sha_hash_func *out_func, const EVP_MD **out_md, size_t *out_len) 683 const EVP_MD **out_md)
682{ 684{
683 const char *label;
684 sha_hash_func sha_func; 685 sha_hash_func sha_func;
685 const EVP_MD *md; 686 const EVP_MD *md;
686 size_t len;
687 687
688 switch (algorithm) { 688 switch (algorithm) {
689 case NID_sha1: 689 case NID_sha1:
690 label = SN_sha1;
691 sha_func = SHA1; 690 sha_func = SHA1;
692 md = EVP_sha1(); 691 md = EVP_sha1();
693 len = SHA_DIGEST_LENGTH;
694 break; 692 break;
695 case NID_sha224: 693 case NID_sha224:
696 label = SN_sha224;
697 sha_func = SHA224; 694 sha_func = SHA224;
698 md = EVP_sha224(); 695 md = EVP_sha224();
699 len = SHA224_DIGEST_LENGTH;
700 break; 696 break;
701 case NID_sha256: 697 case NID_sha256:
702 label = SN_sha256;
703 sha_func = SHA256; 698 sha_func = SHA256;
704 md = EVP_sha256(); 699 md = EVP_sha256();
705 len = SHA256_DIGEST_LENGTH;
706 break; 700 break;
707 case NID_sha384: 701 case NID_sha384:
708 label = SN_sha384;
709 sha_func = SHA384; 702 sha_func = SHA384;
710 md = EVP_sha384(); 703 md = EVP_sha384();
711 len = SHA384_DIGEST_LENGTH;
712 break; 704 break;
713 case NID_sha512: 705 case NID_sha512:
714 label = SN_sha512;
715 sha_func = SHA512; 706 sha_func = SHA512;
716 md = EVP_sha512(); 707 md = EVP_sha512();
717 len = SHA512_DIGEST_LENGTH;
718 break; 708 break;
719 case NID_sha3_224: 709 case NID_sha3_224:
720 label = SN_sha3_224;
721 sha_func = NULL; 710 sha_func = NULL;
722 md = EVP_sha3_224(); 711 md = EVP_sha3_224();
723 len = 224 / 8;
724 break; 712 break;
725 case NID_sha3_256: 713 case NID_sha3_256:
726 label = SN_sha3_256;
727 sha_func = NULL; 714 sha_func = NULL;
728 md = EVP_sha3_256(); 715 md = EVP_sha3_256();
729 len = 256 / 8;
730 break; 716 break;
731 case NID_sha3_384: 717 case NID_sha3_384:
732 label = SN_sha3_384;
733 sha_func = NULL; 718 sha_func = NULL;
734 md = EVP_sha3_384(); 719 md = EVP_sha3_384();
735 len = 384 / 8;
736 break; 720 break;
737 case NID_sha3_512: 721 case NID_sha3_512:
738 label = SN_sha3_512;
739 sha_func = NULL; 722 sha_func = NULL;
740 md = EVP_sha3_512(); 723 md = EVP_sha3_512();
741 len = 512 / 8;
742 break; 724 break;
743 default: 725 default:
744 fprintf(stderr, "FAIL: unknown algorithm (%d)\n",
745 algorithm);
746 return 0; 726 return 0;
747 } 727 }
748 728
749 if (out_label != NULL)
750 *out_label = label;
751 if (out_func != NULL) 729 if (out_func != NULL)
752 *out_func = sha_func; 730 *out_func = sha_func;
753 if (out_md != NULL) 731 if (out_md != NULL)
754 *out_md = md; 732 *out_md = md;
755 if (out_len != NULL)
756 *out_len = len;
757 733
758 return 1; 734 return 1;
759} 735}
760 736
761static int 737static void
762sha_test(void) 738test_sha_tv(struct test *t, const void *arg)
763{ 739{
740 const struct sha_test *st = arg;
764 sha_hash_func sha_func; 741 sha_hash_func sha_func;
765 const struct sha_test *st;
766 EVP_MD_CTX *hash = NULL; 742 EVP_MD_CTX *hash = NULL;
767 const EVP_MD *md; 743 const EVP_MD *md;
768 uint8_t out[EVP_MAX_MD_SIZE]; 744 uint8_t out[EVP_MAX_MD_SIZE];
769 size_t in_len, out_len; 745 size_t in_len, out_len;
770 size_t i;
771 const char *label;
772 int failed = 1;
773 746
774 if ((hash = EVP_MD_CTX_new()) == NULL) { 747 if ((hash = EVP_MD_CTX_new()) == NULL) {
775 fprintf(stderr, "FAIL: EVP_MD_CTX_new() failed\n"); 748 test_errorf(t, "EVP_MD_CTX_new()");
776 goto failed; 749 goto fail;
777 } 750 }
778 751
779 for (i = 0; i < N_SHA_TESTS; i++) { 752 if (!sha_hash_from_algorithm(st->algorithm, &sha_func, &md))
780 st = &sha_tests[i]; 753 goto fail;
781 if (!sha_hash_from_algorithm(st->algorithm, &label, &sha_func,
782 &md, &out_len))
783 goto failed;
784
785 /* Digest */
786 if (sha_func != NULL) {
787 memset(out, 0, sizeof(out));
788 sha_func(st->in, st->in_len, out);
789 if (memcmp(st->out, out, out_len) != 0) {
790 fprintf(stderr, "FAIL (%s:%zu): mismatch\n",
791 label, i);
792 goto failed;
793 }
794 }
795 754
796 /* EVP single-shot digest */ 755 out_len = EVP_MD_size(md);
797 memset(out, 0, sizeof(out));
798 if (!EVP_Digest(st->in, st->in_len, out, NULL, md, NULL)) {
799 fprintf(stderr, "FAIL (%s:%zu): EVP_Digest failed\n",
800 label, i);
801 goto failed;
802 }
803 756
757 /* Digest */
758 if (sha_func != NULL) {
759 memset(out, 0, sizeof(out));
760 sha_func(st->in, st->in_len, out);
804 if (memcmp(st->out, out, out_len) != 0) { 761 if (memcmp(st->out, out, out_len) != 0) {
805 fprintf(stderr, 762 test_errorf(t, "SHA: digest output mismatch");
806 "FAIL (%s:%zu): EVP single-shot mismatch\n", 763 test_hexdiff(t, out, out_len, st->out);
807 label, i);
808 goto failed;
809 } 764 }
765 }
810 766
811 /* EVP digest */ 767 /* EVP single-shot digest */
812 memset(out, 0, sizeof(out)); 768 memset(out, 0, sizeof(out));
813 if (!EVP_DigestInit_ex(hash, md, NULL)) { 769 if (!EVP_Digest(st->in, st->in_len, out, NULL, md, NULL)) {
814 fprintf(stderr, 770 test_errorf(t, "EVP_Digest()");
815 "FAIL (%s:%zu): EVP_DigestInit_ex failed\n", 771 goto fail;
816 label, i); 772 }
817 goto failed;
818 }
819 773
820 in_len = st->in_len / 2; 774 if (memcmp(st->out, out, out_len) != 0) {
821 if (!EVP_DigestUpdate(hash, st->in, in_len)) { 775 test_errorf(t, "EVP single-shot: output diget mismatch");
822 fprintf(stderr, 776 test_hexdiff(t, out, out_len, st->out);
823 "FAIL (%s:%zu): EVP_DigestUpdate first half " 777 }
824 "failed\n", label, i);
825 goto failed;
826 }
827 778
828 if (!EVP_DigestUpdate(hash, st->in + in_len, 779 /* EVP digest */
829 st->in_len - in_len)) { 780 memset(out, 0, sizeof(out));
830 fprintf(stderr, 781 if (!EVP_DigestInit_ex(hash, md, NULL)) {
831 "FAIL (%s:%zu): EVP_DigestUpdate second half " 782 test_errorf(t, "EVP_DigestInit_ex() ");
832 "failed\n", label, i); 783 goto fail;
833 goto failed; 784 }
834 }
835 785
836 if (!EVP_DigestFinal_ex(hash, out, NULL)) { 786 in_len = st->in_len / 2;
837 fprintf(stderr, 787 if (!EVP_DigestUpdate(hash, st->in, in_len)) {
838 "FAIL (%s:%zu): EVP_DigestFinal_ex failed\n", 788 test_errorf(t, "EVP_DigestUpdate() first half");
839 label, i); 789 goto fail;
840 goto failed; 790 }
841 }
842 791
843 if (memcmp(st->out, out, out_len) != 0) { 792 if (!EVP_DigestUpdate(hash, st->in + in_len,
844 fprintf(stderr, "FAIL (%s:%zu): EVP mismatch\n", 793 st->in_len - in_len)) {
845 label, i); 794 test_errorf(t, "EVP_DigestUpdate() second half");
846 goto failed; 795 goto fail;
847 }
848 } 796 }
849 797
850 failed = 0; 798 if (!EVP_DigestFinal_ex(hash, out, NULL)) {
799 test_errorf(t, "EVP_DigestFinal_ex()");
800 goto fail;
801 }
851 802
852 failed: 803 if (memcmp(st->out, out, out_len) != 0) {
804 test_errorf(t, "EVP: digest output mismatch");
805 test_hexdiff(t, out, out_len, st->out);
806 }
807
808
809 fail:
853 EVP_MD_CTX_free(hash); 810 EVP_MD_CTX_free(hash);
854 return failed;
855} 811}
856 812
857static int 813static void
858sha_repetition_test(void) 814test_sha(struct test *t, const void *arg)
859{ 815{
860 const struct sha_repetition_test *st; 816 const struct sha_test *st;
817 size_t i;
818 char *name;
819
820 for (i = 0; i < N_SHA_TESTS; i++) {
821 st = &sha_tests[i];
822 if (asprintf(&name, "%s: '%s'", OBJ_nid2sn(st->algorithm), st->in) == -1) {
823 test_errorf(t, "create test name failed");
824 return;
825 }
826
827 test_run(t, name, test_sha_tv, st);
828 free(name);
829 }
830}
831
832static void
833test_sha_repetition_tv(struct test *t, const void *arg)
834{
835 const struct sha_repetition_test *st = arg;
861 EVP_MD_CTX *hash = NULL; 836 EVP_MD_CTX *hash = NULL;
862 const EVP_MD *md; 837 const EVP_MD *md;
863 uint8_t buf[1024]; 838 uint8_t buf[1024];
864 uint8_t out[EVP_MAX_MD_SIZE]; 839 uint8_t out[EVP_MAX_MD_SIZE];
865 size_t out_len, part_len; 840 size_t out_len, part_len;
866 size_t i, j; 841 size_t i;
867 const char *label;
868 int failed = 1;
869 842
870 if ((hash = EVP_MD_CTX_new()) == NULL) { 843 if ((hash = EVP_MD_CTX_new()) == NULL) {
871 fprintf(stderr, "FAIL: EVP_MD_CTX_new() failed\n"); 844 test_errorf(t, "EVP_MD_CTX_new()");
872 goto failed; 845 goto fail;
873 } 846 }
874 847
875 for (i = 0; i < N_SHA_REPETITION_TESTS; i++) { 848 if (!sha_hash_from_algorithm(st->algorithm, NULL, &md))
876 st = &sha_repetition_tests[i]; 849 goto fail;
877 if (!sha_hash_from_algorithm(st->algorithm, &label, NULL, &md,
878 &out_len))
879 goto failed;
880
881 /* EVP digest */
882 if (!EVP_DigestInit_ex(hash, md, NULL)) {
883 fprintf(stderr,
884 "FAIL (%s:%zu): EVP_DigestInit_ex failed\n",
885 label, i);
886 goto failed;
887 }
888 850
889 memset(buf, st->in, sizeof(buf)); 851 out_len = EVP_MD_size(md);
890 852
891 for (j = 0; j < st->in_repetitions;) { 853 /* EVP digest */
892 part_len = arc4random_uniform(sizeof(buf)); 854 if (!EVP_DigestInit_ex(hash, md, NULL)) {
893 if (part_len > st->in_repetitions - j) 855 test_errorf(t, "EVP_DigestInit_ex()");
894 part_len = st->in_repetitions - j; 856 goto fail;
857 }
895 858
896 if (!EVP_DigestUpdate(hash, buf, part_len)) { 859 memset(buf, st->in, sizeof(buf));
897 fprintf(stderr,
898 "FAIL (%s:%zu): EVP_DigestUpdate failed\n",
899 label, i);
900 goto failed;
901 }
902 860
903 j += part_len; 861 for (i = 0; i < st->in_repetitions;) {
904 } 862 part_len = arc4random_uniform(sizeof(buf));
863 if (part_len > st->in_repetitions - i)
864 part_len = st->in_repetitions - i;
905 865
906 if (!EVP_DigestFinal_ex(hash, out, NULL)) { 866 if (!EVP_DigestUpdate(hash, buf, part_len)) {
907 fprintf(stderr, 867 test_errorf(t, "EVP_DigestUpdate()");
908 "FAIL (%s:%zu): EVP_DigestFinal_ex failed\n", 868 goto fail;
909 label, i);
910 goto failed;
911 } 869 }
912 870
913 if (memcmp(st->out, out, out_len) != 0) { 871 i += part_len;
914 fprintf(stderr, "FAIL (%s:%zu): EVP mismatch\n", 872 }
915 label, i); 873
916 goto failed; 874 if (!EVP_DigestFinal_ex(hash, out, NULL)) {
917 } 875 test_errorf(t, "EVP_DigestFinal_ex()");
876 goto fail;
918 } 877 }
919 878
920 failed = 0; 879 if (memcmp(st->out, out, out_len) != 0) {
880 test_errorf(t, "EVP: digest output mismatch");
881 test_hexdiff(t, out, out_len, st->out);
882 goto fail;
883 }
921 884
922 failed: 885 fail:
923 EVP_MD_CTX_free(hash); 886 EVP_MD_CTX_free(hash);
924 return failed; 887}
888
889static void
890test_sha_repetition(struct test *t, const void *arg)
891{
892 const struct sha_repetition_test *st;
893 size_t i;
894 char *name;
895
896 for (i = 0; i < N_SHA_REPETITION_TESTS; i++) {
897 st = &sha_repetition_tests[i];
898 if (asprintf(&name, "%s: '%hhu' x %zu", OBJ_nid2sn(st->algorithm),
899 st->in, st->in_repetitions) == -1) {
900 test_errorf(t, "create test name failed");
901 return;
902 }
903
904 test_run(t, name, test_sha_repetition_tv, st);
905 free(name);
906 }
925} 907}
926 908
927int 909int
928main(int argc, char **argv) 910main(int argc, char **argv)
929{ 911{
930 int failed = 0; 912 struct test *t = test_init();
931 913
932 failed |= sha_test(); 914 test_run(t, "sha", test_sha, NULL);
933 failed |= sha_repetition_test(); 915 test_run(t, "sha repetition", test_sha_repetition, NULL);
934 916
935 return failed; 917 return test_result(t);
936} 918}
diff --git a/src/regress/lib/libcrypto/test/test.c b/src/regress/lib/libcrypto/test/test.c
new file mode 100644
index 0000000000..1188ec34ef
--- /dev/null
+++ b/src/regress/lib/libcrypto/test/test.c
@@ -0,0 +1,226 @@
1/* $OpenBSD: test.c,v 1.4 2025/05/31 11:36:48 tb Exp $ */
2/*
3 * Copyright (c) 2025 Joshua Sing <joshua@joshuasing.dev>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <err.h>
19#include <stdarg.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <unistd.h>
24
25#include "test.h"
26
27struct test {
28 struct test *parent;
29 char *name;
30 FILE *out;
31 int skipped;
32 int failed;
33};
34
35static struct test *
36test_new(struct test *pt, const char *name)
37{
38 struct test *t;
39
40 if ((t = calloc(1, sizeof(*t))) == NULL)
41 err(1, "calloc");
42
43 if (name != NULL) {
44 if ((t->name = strdup(name)) == NULL)
45 err(1, "strdup");
46 }
47
48 if (pt != NULL)
49 t->out = pt->out;
50 t->parent = pt;
51
52 return t;
53}
54
55struct test *
56test_init(void)
57{
58 struct test *t;
59 char *tmp_file;
60 int out_fd;
61 char *v;
62
63 t = test_new(NULL, NULL);
64 t->out = stderr;
65
66 if (((v = getenv("TEST_VERBOSE")) != NULL) && strcmp(v, "0") != 0)
67 return t;
68
69 /* Create a temporary file for logging in non-verbose mode */
70 if ((tmp_file = strdup("/tmp/libressl-test.XXXXXXXX")) == NULL)
71 err(1, "strdup");
72 if ((out_fd = mkstemp(tmp_file)) == -1)
73 err(1, "mkstemp");
74
75 unlink(tmp_file);
76 free(tmp_file);
77 if ((t->out = fdopen(out_fd, "w+")) == NULL)
78 err(1, "fdopen");
79
80 return t;
81}
82
83static void
84test_cleanup(struct test *t)
85{
86 free(t->name);
87 free(t);
88}
89
90int
91test_result(struct test *t)
92{
93 int failed = t->failed;
94
95 if (t->parent == NULL && t->out != stderr)
96 fclose(t->out);
97
98 test_cleanup(t);
99
100 return failed;
101}
102
103void
104test_fail(struct test *t)
105{
106 t->failed = 1;
107
108 /* Also fail parent. */
109 if (t->parent != NULL)
110 test_fail(t->parent);
111}
112
113static void
114test_vprintf(struct test *t, const char *fmt, va_list ap)
115{
116 if (vfprintf(t->out, fmt, ap) == -1)
117 err(1, "vfprintf");
118}
119
120void
121test_printf(struct test *t, const char *fmt, ...)
122{
123 va_list ap;
124
125 va_start(ap, fmt);
126 test_vprintf(t, fmt, ap);
127 va_end(ap);
128}
129
130static void
131test_vlogf_internal(struct test *t, const char *label, const char *func,
132 const char *file, int line, const char *fmt, va_list ap)
133{
134 char *msg = NULL;
135 char *l = ": ";
136 const char *filename;
137
138 if (label == NULL) {
139 label = "";
140 l = "";
141 }
142
143 if (vasprintf(&msg, fmt, ap) == -1)
144 err(1, "vasprintf");
145
146 if ((filename = strrchr(file, '/')) != NULL)
147 filename++;
148 else
149 filename = file;
150
151 test_printf(t, "%s [%s:%d]%s%s: %s\n",
152 func, filename, line, l, label, msg);
153
154 free(msg);
155}
156
157void
158test_logf_internal(struct test *t, const char *label, const char *func,
159 const char *file, int line, const char *fmt, ...)
160{
161 va_list ap;
162
163 va_start(ap, fmt);
164 test_vlogf_internal(t, label, func, file, line, fmt, ap);
165 va_end(ap);
166}
167
168void
169test_skip(struct test *t, const char *reason)
170{
171 t->skipped = 1;
172 test_printf(t, "%s\n", reason);
173}
174
175void
176test_skipf(struct test *t, const char *fmt, ...)
177{
178 va_list ap;
179
180 t->skipped = 1;
181
182 va_start(ap, fmt);
183 test_vprintf(t, fmt, ap);
184 if (fputc('\n', t->out) == EOF)
185 err(1, "fputc");
186 va_end(ap);
187}
188
189void
190test_run(struct test *pt, const char *name, test_run_func *fn, const void *arg)
191{
192 struct test *t = test_new(pt, name);
193 char *status = "PASS";
194 char buf[1024];
195 size_t buflen;
196 int ferr;
197
198 /* Run test */
199 test_printf(t, "=== RUN %s\n", t->name);
200 fn(t, arg);
201
202 if (t->skipped)
203 status = "SKIP";
204 if (t->failed)
205 status = "FAIL";
206
207 test_printf(t, "--- %s: %s\n\n", status, t->name);
208
209 /* Print result of test */
210 if (t->failed && t->out != stderr) {
211 /* Copy logs to stderr */
212 rewind(t->out);
213 while ((buflen = fread(buf, 1, sizeof(buf), t->out)) > 0)
214 fwrite(buf, 1, buflen, stderr);
215 if ((ferr = ferror(t->out)) != 0)
216 errx(1, "ferror: %d", ferr);
217 }
218
219 if (t->out != NULL && t->out != stderr) {
220 /* Reset output file */
221 rewind(t->out);
222 ftruncate(fileno(t->out), 0);
223 }
224
225 test_cleanup(t);
226}
diff --git a/src/regress/lib/libcrypto/test/test.h b/src/regress/lib/libcrypto/test/test.h
new file mode 100644
index 0000000000..1c8391d4ec
--- /dev/null
+++ b/src/regress/lib/libcrypto/test/test.h
@@ -0,0 +1,137 @@
1/* $OpenBSD: test.h,v 1.4 2025/05/31 11:37:18 tb Exp $ */
2/*
3 * Copyright (c) 2025 Joshua Sing <joshua@joshuasing.dev>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef HEADER_TEST_H
19#define HEADER_TEST_H
20
21#include <stddef.h>
22#include <stdint.h>
23
24struct test;
25
26/*
27 * test_init creates a new root test struct.
28 *
29 * Additional tests may be run under the root test struct by calling test_run.
30 *
31 * If the TEST_VERBOSE environment variable is set and not equal to "0", then
32 * verbose mode will be enabled and all test logs will be written to stderr.
33 */
34struct test *test_init(void);
35
36/*
37 * test_result cleans up after all tests have completed and returns an
38 * appropriate exit code indicating the result of the tests.
39 */
40int test_result(struct test *_t);
41
42/*
43 * test_run_func is an individual test function. It is passed the test struct
44 * and an arbitrary argument which may be passed when test_run is called.
45 */
46typedef void (test_run_func)(struct test *_t, const void *_arg);
47
48/*
49 * test_fail marks the test and its parents as failed.
50 */
51void test_fail(struct test *_t);
52
53/*
54 * test_printf prints a test log message. When in verbose mode, the log message
55 * will be written to stderr, otherwise it will be buffered and only written to
56 * stderr if the test fails.
57 *
58 * This printf will write directly, without any additional formatting.
59 */
60void test_printf(struct test *_t, const char *_fmt, ...)
61 __attribute__((__format__ (printf, 2, 3)))
62 __attribute__((__nonnull__ (2)));
63
64/*
65 * test_logf_internal prints a test log message. When in verbose mode, the
66 * log message will be written to stderr, otherwise it will be buffered and
67 * only written to stderr if the test fails.
68 *
69 * label is an optional label indicating the severity of the log.
70 * func, file and line are used to show where the log comes from and are
71 * automatically set in the test log macros.
72 *
73 * This function should never be called directly.
74 */
75void test_logf_internal(struct test *_t, const char *_label, const char *_func,
76 const char *_file, int _line, const char *_fmt, ...)
77 __attribute__((__format__ (printf, 6, 7)))
78 __attribute__((__nonnull__ (6)));
79
80/*
81 * test_logf prints an informational log message. When in verbose mode, the log
82 * will be written to stderr, otherwise it will be buffered and only written to
83 * stderr if the test fails.
84 */
85#define test_logf(t, fmt, ...) \
86 do { \
87 test_logf_internal(t, NULL, __func__, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \
88 } while (0)
89
90/*
91 * test_errorf prints an error message. It will also cause the test to fail.
92 * If the test cannot proceed, it is recommended to return or goto a cleanup
93 * label.
94 *
95 * Tests should not fail-fast if continuing will provide more detailed
96 * information about what is broken.
97 */
98#define test_errorf(t, fmt, ...) \
99 do { \
100 test_logf_internal(t, "ERROR", __func__, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \
101 test_fail(t); \
102 } while (0)
103
104/*
105 * test_skip marks the test as skipped. Once called, the test should return.
106 */
107void test_skip(struct test *_t, const char *_reason);
108
109/*
110 * test_skipf marks the test as skipped with a formatted reason. Once called,
111 * the test should return.
112 */
113void test_skipf(struct test *_t, const char *_fmt, ...)
114 __attribute__((__format__ (printf, 2, 3)))
115 __attribute__((__nonnull__ (2)));
116
117/*
118 * test_run runs a test function. It will create a new test struct with the
119 * given test as the parent. An argument may be provided to pass data to the
120 * test function, otherwise NULL should be passed.
121 *
122 * Each test should have a unique and informational name.
123 */
124void test_run(struct test *_t, const char *_name, test_run_func *_fn, const void *_arg);
125
126/*
127 * test_hexdump prints the given data as hexadecimal.
128 */
129void test_hexdump(struct test *_t, const unsigned char *_buf, size_t _len);
130
131/*
132 * test_hexdiff prints the given data as hexadecimal. If a second comparison
133 * buffer is not NULL, any differing bytes will be marked with an astrix.
134 */
135void test_hexdiff(struct test *_t, const uint8_t *_buf, size_t _len, const uint8_t *_compare);
136
137#endif /* HEADER_TEST_H */
diff --git a/src/regress/lib/libcrypto/test/test_util.c b/src/regress/lib/libcrypto/test/test_util.c
new file mode 100644
index 0000000000..6ecb574788
--- /dev/null
+++ b/src/regress/lib/libcrypto/test/test_util.c
@@ -0,0 +1,51 @@
1/* $OpenBSD: test_util.c,v 1.1 2025/05/21 08:57:13 joshua Exp $ */
2/*
3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <stdio.h>
20#include <stdint.h>
21
22#include "test.h"
23
24void
25test_hexdump(struct test *t, const unsigned char *buf, size_t len)
26{
27 size_t i;
28
29 for (i = 1; i <= len; i++)
30 test_printf(t, " 0x%02x,%s", buf[i - 1], i % 8 ? "" : "\n");
31
32 if ((len % 8) != 0)
33 test_printf(t, "\n");
34}
35
36void
37test_hexdiff(struct test *t, const uint8_t *buf, size_t len, const uint8_t *compare)
38{
39 const char *mark = "", *newline;
40 size_t i;
41
42 for (i = 1; i <= len; i++) {
43 if (compare != NULL)
44 mark = (buf[i - 1] != compare[i - 1]) ? "*" : " ";
45 newline = i % 8 ? "" : "\n";
46 test_printf(t, " %s0x%02x,%s", mark, buf[i - 1], newline);
47 }
48
49 if ((len % 8) != 0)
50 test_printf(t, "\n");
51}
diff --git a/src/regress/lib/libcrypto/wycheproof/Makefile b/src/regress/lib/libcrypto/wycheproof/Makefile
index f2f7910b5b..a68a270580 100644
--- a/src/regress/lib/libcrypto/wycheproof/Makefile
+++ b/src/regress/lib/libcrypto/wycheproof/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.9 2023/07/08 19:41:07 tb Exp $ 1# $OpenBSD: Makefile,v 1.10 2025/07/09 05:04:35 tb Exp $
2 2
3WYCHEPROOF_TESTVECTORS = /usr/local/share/wycheproof/testvectors/ 3WYCHEPROOF_TESTVECTORS = /usr/local/share/wycheproof/testvectors/
4 4
@@ -18,11 +18,17 @@ REGRESS_TARGETS += regress-wycheproof
18CLEANFILES += wycheproof 18CLEANFILES += wycheproof
19 19
20wycheproof: wycheproof.go 20wycheproof: wycheproof.go
21 go build -o wycheproof ${.CURDIR}/wycheproof.go 21 env GOCACHE=${.OBJDIR}/go-build go build -o wycheproof ${.CURDIR}/wycheproof.go
22 22
23regress-wycheproof: wycheproof 23regress-wycheproof: wycheproof
24 ./wycheproof 24 ./wycheproof
25 25
26REGRESS_CLEANUP = clean-go-cache
27
28clean-go-cache:
29 env GOCACHE=${.OBJDIR}/go-build go clean -cache
30 rm -rf ${.OBJDIR}/go-build
31
26. endif 32. endif
27 33
28PROGS += wycheproof-primes 34PROGS += wycheproof-primes
diff --git a/src/regress/lib/libcrypto/x509/Makefile b/src/regress/lib/libcrypto/x509/Makefile
index 19e65efddd..94e9e476a0 100644
--- a/src/regress/lib/libcrypto/x509/Makefile
+++ b/src/regress/lib/libcrypto/x509/Makefile
@@ -1,6 +1,6 @@
1# $OpenBSD: Makefile,v 1.24 2025/03/15 06:37:49 tb Exp $ 1# $OpenBSD: Makefile,v 1.25 2025/05/05 06:33:34 tb Exp $
2 2
3PROGS = constraints verify x509attribute x509name x509req_ext callback 3PROGS = constraints verify x509attribute x509req_ext callback
4PROGS += expirecallback callbackfailures x509_asn1 x509_extensions_test 4PROGS += expirecallback callbackfailures x509_asn1 x509_extensions_test
5PROGS += x509_name_test 5PROGS += x509_name_test
6LDADD = -lcrypto 6LDADD = -lcrypto
@@ -16,7 +16,7 @@ CFLAGS += -I${.CURDIR}/../../../../lib/libcrypto/bytestring
16 16
17SUBDIR += bettertls policy rfc3779 17SUBDIR += bettertls policy rfc3779
18 18
19CLEANFILES += x509name.result callback.out 19CLEANFILES += callback.out
20 20
21.if make(clean) || make(cleandir) 21.if make(clean) || make(cleandir)
22. if ${.OBJDIR} != ${.CURDIR} 22. if ${.OBJDIR} != ${.CURDIR}
@@ -29,10 +29,6 @@ run-regress-verify: verify
29 perl ${.CURDIR}/make-dir-roots.pl ${.CURDIR}/../certs . 29 perl ${.CURDIR}/make-dir-roots.pl ${.CURDIR}/../certs .
30 ./verify ${.CURDIR}/../certs 30 ./verify ${.CURDIR}/../certs
31 31
32run-regress-x509name: x509name
33 ./x509name > x509name.result
34 diff -u ${.CURDIR}/x509name.expected x509name.result
35
36run-regress-callback: callback 32run-regress-callback: callback
37 ./callback ${.CURDIR}/../certs 33 ./callback ${.CURDIR}/../certs
38 perl ${.CURDIR}/callback.pl callback.out 34 perl ${.CURDIR}/callback.pl callback.out
diff --git a/src/regress/lib/libcrypto/x509/bettertls/Makefile b/src/regress/lib/libcrypto/x509/bettertls/Makefile
index 2724140635..2a06239fc5 100644
--- a/src/regress/lib/libcrypto/x509/bettertls/Makefile
+++ b/src/regress/lib/libcrypto/x509/bettertls/Makefile
@@ -1,10 +1,10 @@
1# $OpenBSD: Makefile,v 1.6 2024/12/27 08:02:27 tb Exp $ 1# $OpenBSD: Makefile,v 1.7 2025/07/23 07:46:12 tb Exp $
2 2
3PROGS = verify 3PROGS = verify
4 4
5.ifdef EOPENSSL33 5.ifdef EOPENSSL35
6LDADD += -Wl,-rpath,/usr/local/lib/eopenssl33 -L/usr/local/lib/eopenssl33 6LDADD += -Wl,-rpath,/usr/local/lib/eopenssl35 -L/usr/local/lib/eopenssl35
7CFLAGS += -I/usr/local/include/eopenssl33/ 7CFLAGS += -I/usr/local/include/eopenssl35/
8.endif 8.endif
9 9
10LDADD += -lcrypto 10LDADD += -lcrypto
diff --git a/src/regress/lib/libcrypto/x509/x509_name_test.c b/src/regress/lib/libcrypto/x509/x509_name_test.c
index eaf7076d74..24e62cc766 100644
--- a/src/regress/lib/libcrypto/x509/x509_name_test.c
+++ b/src/regress/lib/libcrypto/x509/x509_name_test.c
@@ -1,7 +1,9 @@
1/* $OpenBSD: x509_name_test.c,v 1.2 2025/03/19 11:19:17 tb Exp $ */ 1/* $OpenBSD: x509_name_test.c,v 1.3 2025/05/05 06:33:34 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2025 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
5 * Copyright (c) 2025 Kenjiro Nakayama <nakayamakenjiro@gmail.com>
6 * Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
5 * 7 *
6 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
@@ -288,12 +290,131 @@ x509_name_compat_test(void)
288 return failed; 290 return failed;
289} 291}
290 292
293static const struct x509_name_entry_test {
294 const char *field;
295 const char *value;
296 int loc;
297 int set;
298 const char *expected_str;
299 const int expected_set[4];
300 const int expected_count;
301} entry_tests[] = {
302 {
303 .field = "ST",
304 .value = "BaWue",
305 .loc = -1,
306 .set = 0,
307 .expected_str = "ST=BaWue",
308 .expected_set = { 0 },
309 .expected_count = 1,
310 },
311 {
312 .field = "O",
313 .value = "KIT",
314 .loc = -1,
315 .set = 0,
316 .expected_str = "ST=BaWue, O=KIT",
317 .expected_set = { 0, 1 },
318 .expected_count = 2,
319 },
320 {
321 .field = "L",
322 .value = "Karlsruhe",
323 .loc = 1,
324 .set = 0,
325 .expected_str = "ST=BaWue, L=Karlsruhe, O=KIT",
326 .expected_set = { 0, 1, 2 },
327 .expected_count = 3,
328 },
329 {
330 .field = "C",
331 .value = "DE",
332 .loc = 0,
333 .set = 1,
334 .expected_str = "C=DE + ST=BaWue, L=Karlsruhe, O=KIT",
335 .expected_set = { 0, 0, 1, 2 },
336 .expected_count = 4,
337 },
338};
339
340#define N_ENTRY_TESTS (sizeof(entry_tests) / sizeof(entry_tests[0]))
341
342static int
343verify_x509_name_output(X509_NAME *name, const struct x509_name_entry_test *tc)
344{
345 BIO *bio;
346 char *got;
347 long got_len;
348 int loc, ret;
349 int failed = 1;
350
351 if ((bio = BIO_new(BIO_s_mem())) == NULL)
352 goto fail;
353
354 if ((ret = X509_NAME_print_ex(bio, name, 0, XN_FLAG_SEP_CPLUS_SPC)) == -1)
355 goto fail;
356
357 if ((got_len = BIO_get_mem_data(bio, &got)) < 0)
358 goto fail;
359
360 if (ret != got_len || strlen(tc->expected_str) != (size_t)ret)
361 goto fail;
362
363 if (strncmp(tc->expected_str, got, got_len) != 0)
364 goto fail;
365
366 if (X509_NAME_entry_count(name) != tc->expected_count)
367 goto fail;
368
369 for (loc = 0; loc < X509_NAME_entry_count(name); loc++) {
370 X509_NAME_ENTRY *e = X509_NAME_get_entry(name, loc);
371 if (e == NULL || X509_NAME_ENTRY_set(e) != tc->expected_set[loc])
372 goto fail;
373 }
374
375 failed = 0;
376
377 fail:
378 BIO_free(bio);
379
380 return failed;
381}
382
383static int
384x509_name_add_entry_test(void)
385{
386 X509_NAME *name;
387 int failed = 1;
388
389 if ((name = X509_NAME_new()) == NULL)
390 goto done;
391
392 for (size_t i = 0; i < N_ENTRY_TESTS; i++) {
393 const struct x509_name_entry_test *t = &entry_tests[i];
394
395 if (!X509_NAME_add_entry_by_txt(name, t->field, MBSTRING_ASC,
396 (const unsigned char *)t->value, -1, t->loc, t->set))
397 goto done;
398
399 if (verify_x509_name_output(name, t))
400 goto done;
401 }
402
403 failed = 0;
404
405 done:
406 X509_NAME_free(name);
407
408 return failed;
409}
410
291int 411int
292main(void) 412main(void)
293{ 413{
294 int failed = 0; 414 int failed = 0;
295 415
296 failed |= x509_name_compat_test(); 416 failed |= x509_name_compat_test();
417 failed |= x509_name_add_entry_test();
297 418
298 return failed; 419 return failed;
299} 420}
diff --git a/src/regress/lib/libcrypto/x509/x509name.c b/src/regress/lib/libcrypto/x509/x509name.c
deleted file mode 100644
index 9deeeb2986..0000000000
--- a/src/regress/lib/libcrypto/x509/x509name.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/* $OpenBSD: x509name.c,v 1.3 2021/10/31 08:27:15 tb Exp $ */
2/*
3 * Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <err.h>
19#include <stdio.h>
20
21#include <openssl/x509.h>
22
23static void debug_print(X509_NAME *);
24
25static void
26debug_print(X509_NAME *name)
27{
28 int loc;
29
30 for (loc = 0; loc < X509_NAME_entry_count(name); loc++)
31 printf("%d:",
32 X509_NAME_ENTRY_set(X509_NAME_get_entry(name, loc)));
33 putchar(' ');
34 X509_NAME_print_ex_fp(stdout, name, 0, XN_FLAG_SEP_CPLUS_SPC);
35 putchar('\n');
36}
37
38int
39main(void)
40{
41 X509_NAME *name;
42
43 if ((name = X509_NAME_new()) == NULL)
44 err(1, NULL);
45 X509_NAME_add_entry_by_txt(name, "ST", MBSTRING_ASC,
46 "BaWue", -1, -1, 0);
47 X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC,
48 "KIT", -1, -1, 0);
49 debug_print(name);
50
51 X509_NAME_add_entry_by_txt(name, "L", MBSTRING_ASC,
52 "Karlsruhe", -1, 1, 0);
53 debug_print(name);
54
55 X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC,
56 "DE", -1, 0, 1);
57 debug_print(name);
58
59 X509_NAME_free(name);
60
61 return 0;
62}
diff --git a/src/regress/lib/libcrypto/x509/x509name.expected b/src/regress/lib/libcrypto/x509/x509name.expected
deleted file mode 100644
index 6cee7cc435..0000000000
--- a/src/regress/lib/libcrypto/x509/x509name.expected
+++ /dev/null
@@ -1,3 +0,0 @@
10:1: ST=BaWue, O=KIT
20:1:2: ST=BaWue, L=Karlsruhe, O=KIT
30:0:1:2: C=DE + ST=BaWue, L=Karlsruhe, O=KIT
diff --git a/src/regress/lib/libssl/interop/Makefile b/src/regress/lib/libssl/interop/Makefile
index bdc67f627a..e1e9633d37 100644
--- a/src/regress/lib/libssl/interop/Makefile
+++ b/src/regress/lib/libssl/interop/Makefile
@@ -1,6 +1,6 @@
1# $OpenBSD: Makefile,v 1.21 2025/01/15 10:54:17 tb Exp $ 1# $OpenBSD: Makefile,v 1.23 2025/07/25 16:33:15 tb Exp $
2 2
3SUBDIR = libressl openssl33 openssl34 3SUBDIR = libressl openssl35
4 4
5# the above binaries must have been built before we can continue 5# the above binaries must have been built before we can continue
6SUBDIR += netcat 6SUBDIR += netcat
diff --git a/src/regress/lib/libssl/interop/botan/Makefile b/src/regress/lib/libssl/interop/botan/Makefile
index 85877d4290..56bcdaf4bd 100644
--- a/src/regress/lib/libssl/interop/botan/Makefile
+++ b/src/regress/lib/libssl/interop/botan/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.10 2025/01/15 10:54:17 tb Exp $ 1# $OpenBSD: Makefile,v 1.12 2025/07/25 16:33:15 tb Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -20,11 +20,8 @@ CXX = /usr/local/bin/eg++
20.endif 20.endif
21 21
22LIBRARIES = libressl 22LIBRARIES = libressl
23.if exists(/usr/local/bin/eopenssl33) 23.if exists(/usr/local/bin/eopenssl35)
24LIBRARIES += openssl33 24LIBRARIES += openssl35
25.endif
26.if exists(/usr/local/bin/eopenssl34)
27LIBRARIES += openssl34
28.endif 25.endif
29 26
30PROGS = client 27PROGS = client
diff --git a/src/regress/lib/libssl/interop/cert/Makefile b/src/regress/lib/libssl/interop/cert/Makefile
index 74c63c86a8..9698c56acd 100644
--- a/src/regress/lib/libssl/interop/cert/Makefile
+++ b/src/regress/lib/libssl/interop/cert/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.14 2025/01/15 10:54:17 tb Exp $ 1# $OpenBSD: Makefile,v 1.16 2025/07/25 16:33:15 tb Exp $
2 2
3# Connect a client to a server. Both can be current libressl, or 3# Connect a client to a server. Both can be current libressl, or
4# openssl 3.x. Create client and server certificates 4# openssl 3.x. Create client and server certificates
@@ -7,11 +7,8 @@
7# and check the result of certificate verification. 7# and check the result of certificate verification.
8 8
9LIBRARIES = libressl 9LIBRARIES = libressl
10.if exists(/usr/local/bin/eopenssl33) 10.if exists(/usr/local/bin/eopenssl35)
11LIBRARIES += openssl33 11LIBRARIES += openssl35
12.endif
13.if exists(/usr/local/bin/eopenssl34)
14LIBRARIES += openssl34
15.endif 12.endif
16 13
17.for cca in noca ca fakeca 14.for cca in noca ca fakeca
diff --git a/src/regress/lib/libssl/interop/cipher/Makefile b/src/regress/lib/libssl/interop/cipher/Makefile
index fa7e25f9ee..5bdc9089fe 100644
--- a/src/regress/lib/libssl/interop/cipher/Makefile
+++ b/src/regress/lib/libssl/interop/cipher/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.17 2025/01/15 10:54:17 tb Exp $ 1# $OpenBSD: Makefile,v 1.19 2025/07/25 16:33:15 tb Exp $
2 2
3# Connect a client to a server. Both can be current libressl, or 3# Connect a client to a server. Both can be current libressl, or
4# openssl 1.1 or 3.0. Create lists of supported ciphers 4# openssl 1.1 or 3.0. Create lists of supported ciphers
@@ -7,11 +7,8 @@
7# have used correct cipher by grepping in their session print out. 7# have used correct cipher by grepping in their session print out.
8 8
9LIBRARIES = libressl 9LIBRARIES = libressl
10.if exists(/usr/local/bin/eopenssl33) 10.if exists(/usr/local/bin/eopenssl35)
11LIBRARIES += openssl33 11LIBRARIES += openssl35
12.endif
13.if exists(/usr/local/bin/eopenssl34)
14LIBRARIES += openssl34
15.endif 12.endif
16 13
17CLEANFILES = *.tmp *.ciphers ciphers.mk 14CLEANFILES = *.tmp *.ciphers ciphers.mk
@@ -41,8 +38,7 @@ client-${clib}-server-${slib}.ciphers: \
41 uniq -d <$@.tmp >$@ 38 uniq -d <$@.tmp >$@
42 # we are only interested in ciphers supported by libressl 39 # we are only interested in ciphers supported by libressl
43 sort $@ client-libressl.ciphers >$@.tmp 40 sort $@ client-libressl.ciphers >$@.tmp
44. if "${clib}" == "openssl33" || "${slib}" == "openssl33" || \ 41. if "${clib}" == "openssl35" || "${slib}" == "openssl35"
45 "${clib}" == "openssl34" || "${slib}" == "openssl34"
46 # OpenSSL's SSL_CTX_set_cipher_list doesn't accept TLSv1.3 ciphers 42 # OpenSSL's SSL_CTX_set_cipher_list doesn't accept TLSv1.3 ciphers
47 sed -i '/^TLS_/d' $@.tmp 43 sed -i '/^TLS_/d' $@.tmp
48. endif 44. endif
@@ -70,8 +66,7 @@ regress: ciphers.mk
70.endif 66.endif
71 67
72LEVEL_libressl = 68LEVEL_libressl =
73LEVEL_openssl33 = ,@SECLEVEL=0 69LEVEL_openssl35 = ,@SECLEVEL=0
74LEVEL_openssl34 = ,@SECLEVEL=0
75 70
76.for clib in ${LIBRARIES} 71.for clib in ${LIBRARIES}
77.for slib in ${LIBRARIES} 72.for slib in ${LIBRARIES}
@@ -132,7 +127,7 @@ check-cipher-${cipher}-client-${clib}-server-${slib}: \
132. endif 127. endif
133. if "${clib}" == "libressl" 128. if "${clib}" == "libressl"
134 # libressl client may prefer chacha-poly if aes-ni is not supported 129 # libressl client may prefer chacha-poly if aes-ni is not supported
135. if "${slib}" == "openssl33" || "${slib}" == "openssl34" 130. if "${slib}" == "openssl35"
136 egrep -q ' Cipher *: TLS_(AES_256_GCM_SHA384|CHACHA20_POLY1305_SHA256)$$' ${@:S/^check/server/}.out 131 egrep -q ' Cipher *: TLS_(AES_256_GCM_SHA384|CHACHA20_POLY1305_SHA256)$$' ${@:S/^check/server/}.out
137. else 132. else
138 egrep -q ' Cipher *: TLS_(AES_256_GCM_SHA384|CHACHA20_POLY1305_SHA256)$$' ${@:S/^check/server/}.out 133 egrep -q ' Cipher *: TLS_(AES_256_GCM_SHA384|CHACHA20_POLY1305_SHA256)$$' ${@:S/^check/server/}.out
diff --git a/src/regress/lib/libssl/interop/netcat/Makefile b/src/regress/lib/libssl/interop/netcat/Makefile
index 3b8e3f95be..cff6b7ea76 100644
--- a/src/regress/lib/libssl/interop/netcat/Makefile
+++ b/src/regress/lib/libssl/interop/netcat/Makefile
@@ -1,11 +1,8 @@
1# $OpenBSD: Makefile,v 1.10 2025/01/15 10:54:17 tb Exp $ 1# $OpenBSD: Makefile,v 1.12 2025/07/25 16:33:15 tb Exp $
2 2
3LIBRARIES = libressl 3LIBRARIES = libressl
4.if exists(/usr/local/bin/eopenssl33) 4.if exists(/usr/local/bin/eopenssl35)
5LIBRARIES += openssl33 5LIBRARIES += openssl35
6.endif
7.if exists(/usr/local/bin/eopenssl34)
8LIBRARIES += openssl34
9.endif 6.endif
10 7
11# run netcat server and connect with test client 8# run netcat server and connect with test client
diff --git a/src/regress/lib/libssl/interop/openssl33/Makefile b/src/regress/lib/libssl/interop/openssl33/Makefile
deleted file mode 100644
index eff61704d0..0000000000
--- a/src/regress/lib/libssl/interop/openssl33/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
1# $OpenBSD: Makefile,v 1.1 2025/01/15 10:54:17 tb Exp $
2
3.if ! exists(/usr/local/bin/eopenssl33)
4regress:
5 # install openssl-3.3 from ports for interop tests
6 @echo 'Run "pkg_add openssl--%3.3" to run tests against OpenSSL 3.3'
7 @echo SKIPPED
8.else
9
10PROGS = client server
11CFLAGS += -DOPENSSL_SUPPRESS_DEPRECATED
12CPPFLAGS = -I /usr/local/include/eopenssl33
13LDFLAGS = -L /usr/local/lib/eopenssl33
14LDADD = -lssl -lcrypto
15DPADD = /usr/local/lib/eopenssl33/libssl.a \
16 /usr/local/lib/eopenssl33/libcrypto.a
17LD_LIBRARY_PATH = /usr/local/lib/eopenssl33
18REGRESS_TARGETS = run-self-client-server
19.for p in ${PROGS}
20REGRESS_TARGETS += run-ldd-$p run-version-$p run-protocol-$p
21.endfor
22
23.for p in ${PROGS}
24
25run-ldd-$p: ldd-$p.out
26 # check that $p is linked with OpenSSL 3.3
27 grep -q /usr/local/lib/eopenssl33/libcrypto.so ldd-$p.out
28 grep -q /usr/local/lib/eopenssl33/libssl.so ldd-$p.out
29 # check that $p is not linked with LibreSSL
30 ! grep -v libc.so ldd-$p.out | grep /usr/lib/
31
32run-version-$p: $p-self.out
33 # check that runtime version is OpenSSL 3.3
34 grep 'SSLEAY_VERSION: OpenSSL 3.3' $p-self.out
35
36run-protocol-$p: $p-self.out
37 # check that OpenSSL 3.3 protocol version is TLS 1.3
38 grep 'Protocol *: TLSv1.3' $p-self.out
39
40.endfor
41
42.endif # exists(/usr/local/bin/eopenssl33)
43
44.include <bsd.regress.mk>
diff --git a/src/regress/lib/libssl/interop/openssl34/Makefile b/src/regress/lib/libssl/interop/openssl34/Makefile
deleted file mode 100644
index 72246bb621..0000000000
--- a/src/regress/lib/libssl/interop/openssl34/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
1# $OpenBSD: Makefile,v 1.1 2025/01/15 10:54:17 tb Exp $
2
3.if ! exists(/usr/local/bin/eopenssl34)
4regress:
5 # install openssl-3.4 from ports for interop tests
6 @echo 'Run "pkg_add openssl--%3.4" to run tests against OpenSSL 3.4'
7 @echo SKIPPED
8.else
9
10PROGS = client server
11CFLAGS += -DOPENSSL_SUPPRESS_DEPRECATED
12CPPFLAGS = -I /usr/local/include/eopenssl34
13LDFLAGS = -L /usr/local/lib/eopenssl34
14LDADD = -lssl -lcrypto
15DPADD = /usr/local/lib/eopenssl34/libssl.a \
16 /usr/local/lib/eopenssl34/libcrypto.a
17LD_LIBRARY_PATH = /usr/local/lib/eopenssl34
18REGRESS_TARGETS = run-self-client-server
19.for p in ${PROGS}
20REGRESS_TARGETS += run-ldd-$p run-version-$p run-protocol-$p
21.endfor
22
23.for p in ${PROGS}
24
25run-ldd-$p: ldd-$p.out
26 # check that $p is linked with OpenSSL 3.4
27 grep -q /usr/local/lib/eopenssl34/libcrypto.so ldd-$p.out
28 grep -q /usr/local/lib/eopenssl34/libssl.so ldd-$p.out
29 # check that $p is not linked with LibreSSL
30 ! grep -v libc.so ldd-$p.out | grep /usr/lib/
31
32run-version-$p: $p-self.out
33 # check that runtime version is OpenSSL 3.4
34 grep 'SSLEAY_VERSION: OpenSSL 3.4' $p-self.out
35
36run-protocol-$p: $p-self.out
37 # check that OpenSSL 3.4 protocol version is TLS 1.3
38 grep 'Protocol *: TLSv1.3' $p-self.out
39
40.endfor
41
42.endif # exists(/usr/local/bin/eopenssl34)
43
44.include <bsd.regress.mk>
diff --git a/src/regress/lib/libssl/interop/openssl35/Makefile b/src/regress/lib/libssl/interop/openssl35/Makefile
new file mode 100644
index 0000000000..e11ad5dd20
--- /dev/null
+++ b/src/regress/lib/libssl/interop/openssl35/Makefile
@@ -0,0 +1,44 @@
1# $OpenBSD: Makefile,v 1.1 2025/07/09 17:48:02 tb Exp $
2
3.if ! exists(/usr/local/bin/eopenssl35)
4regress:
5 # install openssl-3.5 from ports for interop tests
6 @echo 'Run "pkg_add openssl--%3.5" to run tests against OpenSSL 3.5'
7 @echo SKIPPED
8.else
9
10PROGS = client server
11CFLAGS += -DOPENSSL_SUPPRESS_DEPRECATED
12CPPFLAGS = -I /usr/local/include/eopenssl35
13LDFLAGS = -L /usr/local/lib/eopenssl35
14LDADD = -lssl -lcrypto
15DPADD = /usr/local/lib/eopenssl35/libssl.a \
16 /usr/local/lib/eopenssl35/libcrypto.a
17LD_LIBRARY_PATH = /usr/local/lib/eopenssl35
18REGRESS_TARGETS = run-self-client-server
19.for p in ${PROGS}
20REGRESS_TARGETS += run-ldd-$p run-version-$p run-protocol-$p
21.endfor
22
23.for p in ${PROGS}
24
25run-ldd-$p: ldd-$p.out
26 # check that $p is linked with OpenSSL 3.5
27 grep -q /usr/local/lib/eopenssl35/libcrypto.so ldd-$p.out
28 grep -q /usr/local/lib/eopenssl35/libssl.so ldd-$p.out
29 # check that $p is not linked with LibreSSL
30 ! grep -v -e libc.so -e libpthread.so ldd-$p.out | grep /usr/lib/
31
32run-version-$p: $p-self.out
33 # check that runtime version is OpenSSL 3.5
34 grep 'SSLEAY_VERSION: OpenSSL 3.5' $p-self.out
35
36run-protocol-$p: $p-self.out
37 # check that OpenSSL 3.5 protocol version is TLS 1.3
38 grep 'Protocol *: TLSv1.3' $p-self.out
39
40.endfor
41
42.endif # exists(/usr/local/bin/eopenssl35)
43
44.include <bsd.regress.mk>
diff --git a/src/regress/lib/libssl/interop/session/Makefile b/src/regress/lib/libssl/interop/session/Makefile
index e9a353f99e..fff66b169b 100644
--- a/src/regress/lib/libssl/interop/session/Makefile
+++ b/src/regress/lib/libssl/interop/session/Makefile
@@ -1,11 +1,8 @@
1# $OpenBSD: Makefile,v 1.12 2025/01/15 10:54:17 tb Exp $ 1# $OpenBSD: Makefile,v 1.14 2025/07/25 16:33:15 tb Exp $
2 2
3LIBRARIES = libressl 3LIBRARIES = libressl
4.if exists(/usr/local/bin/eopenssl33) 4.if exists(/usr/local/bin/eopenssl35)
5#LIBRARIES += openssl33 5#LIBRARIES += openssl35
6.endif
7.if exists(/usr/local/bin/eopenssl34)
8#LIBRARIES += openssl34
9.endif 6.endif
10 7
11run-session-client-libressl-server-libressl: 8run-session-client-libressl-server-libressl:
diff --git a/src/regress/lib/libssl/interop/version/Makefile b/src/regress/lib/libssl/interop/version/Makefile
index 605fba252f..5ee7d4c4f3 100644
--- a/src/regress/lib/libssl/interop/version/Makefile
+++ b/src/regress/lib/libssl/interop/version/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.10 2025/01/15 10:54:17 tb Exp $ 1# $OpenBSD: Makefile,v 1.12 2025/07/25 16:33:15 tb Exp $
2 2
3# Connect a client to a server. Both can be current libressl, or 3# Connect a client to a server. Both can be current libressl, or
4# openssl 1.1 or openssl 3.0. Pin client or server to a fixed TLS 4# openssl 1.1 or openssl 3.0. Pin client or server to a fixed TLS
@@ -7,11 +7,8 @@
7# print out. 7# print out.
8 8
9LIBRARIES = libressl 9LIBRARIES = libressl
10.if exists(/usr/local/bin/eopenssl33) 10.if exists(/usr/local/bin/eopenssl35)
11LIBRARIES += openssl33 11LIBRARIES += openssl35
12.endif
13.if exists(/usr/local/bin/eopenssl34)
14LIBRARIES += openssl34
15.endif 12.endif
16 13
17VERSIONS = any TLS1_2 TLS1_3 14VERSIONS = any TLS1_2 TLS1_3
@@ -29,8 +26,7 @@ FAIL_${cver}_${sver} = !
29.for slib in ${LIBRARIES} 26.for slib in ${LIBRARIES}
30 27
31.if ("${cver}" != TLS1_3 && "${sver}" != TLS1_3) && \ 28.if ("${cver}" != TLS1_3 && "${sver}" != TLS1_3) && \
32 ((("${clib}" != openssl33 && "${slib}" != openssl33)) || \ 29 ((("${clib}" != openssl35 && "${slib}" != openssl35)) || \
33 (("${clib}" != openssl34 && "${slib}" != openssl34)) || \
34 (("${cver}" != any && "${sver}" != any) && \ 30 (("${cver}" != any && "${sver}" != any) && \
35 ("${cver}" != TLS1 && "${sver}" != TLS1) && \ 31 ("${cver}" != TLS1 && "${sver}" != TLS1) && \
36 ("${cver}" != TLS1_1 && "${sver}" != TLS1_1))) 32 ("${cver}" != TLS1_1 && "${sver}" != TLS1_1)))
diff --git a/src/regress/lib/libssl/openssl-ruby/Makefile b/src/regress/lib/libssl/openssl-ruby/Makefile
index af8083f662..19d2f2fc40 100644
--- a/src/regress/lib/libssl/openssl-ruby/Makefile
+++ b/src/regress/lib/libssl/openssl-ruby/Makefile
@@ -1,10 +1,10 @@
1# $OpenBSD: Makefile,v 1.14 2024/08/31 11:14:58 tb Exp $ 1# $OpenBSD: Makefile,v 1.17 2025/06/27 03:32:08 tb Exp $
2 2
3OPENSSL_RUBY_TESTS = /usr/local/share/openssl-ruby-tests 3OPENSSL_RUBY_TESTS = /usr/local/share/openssl-ruby-tests
4.if exists(/usr/local/bin/ruby32) 4.if exists(/usr/local/bin/ruby33)
5RUBY_BINREV = 32
6.else
7RUBY_BINREV = 33 5RUBY_BINREV = 33
6.else
7RUBY_BINREV = 34
8.endif 8.endif
9RUBY = ruby${RUBY_BINREV} 9RUBY = ruby${RUBY_BINREV}
10 10
@@ -71,6 +71,21 @@ ${_t}: ${_BUILD_COOKIE}
71 -n ${_t} 71 -n ${_t}
72.endfor 72.endfor
73 73
74# These tests can be a pain to run. To run a small set of individual
75# ssl tests, set the test names separated by spaces in the environment
76# variable RUBY_SSL_TEST_TARGETS - then you can type "make <test_name>"
77# to run a single ruby ssl test.
78.for _t in ${RUBY_SSL_TEST_TARGETS}
79REGRESS_TARGETS += ${_t}
80REGRESS_EXPECTED_FAILURES += ${_t}
81${_t}: ${_BUILD_COOKIE}
82 cd ${BUILDDIR} && \
83 ${RUBY} -I. -I${OPENSSL_RUBY_TESTS}/test/openssl \
84 -I${OPENSSL_RUBY_TESTS}/lib \
85 ${OPENSSL_RUBY_TESTS}/test/openssl/test_ssl.rb \
86 -n ${_t}
87.endfor
88
74CLEANFILES += ${_BUILD_COOKIE} ${_TEST_COOKIE} ${_BUILDDIR_COOKIE} 89CLEANFILES += ${_BUILD_COOKIE} ${_TEST_COOKIE} ${_BUILDDIR_COOKIE}
75 90
76. if make(clean) || make(cleandir) 91. if make(clean) || make(cleandir)
diff --git a/src/regress/lib/libssl/pqueue/Makefile b/src/regress/lib/libssl/pqueue/Makefile
index 48c2cb7e61..05fe9a268d 100644
--- a/src/regress/lib/libssl/pqueue/Makefile
+++ b/src/regress/lib/libssl/pqueue/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.1 2016/11/04 19:45:12 jsing Exp $ 1# $OpenBSD: Makefile,v 1.2 2025/05/04 11:04:02 tb Exp $
2 2
3PROG= pq_test 3PROG= pq_test
4SRC= ${.CURDIR}/../../../../lib/libssl 4SRC= ${.CURDIR}/../../../../lib/libssl
@@ -9,9 +9,4 @@ DPADD= ${LIBSSL} ${LIBCRYPTO}
9WARNINGS= Yes 9WARNINGS= Yes
10CFLAGS+= -DLIBRESSL_INTERNAL -Werror 10CFLAGS+= -DLIBRESSL_INTERNAL -Werror
11 11
12REGRESS_TARGETS= regress-pq_test
13
14regress-pq_test: ${PROG}
15 ${.OBJDIR}/pq_test | cmp -s ${.CURDIR}/expected.txt /dev/stdin
16
17.include <bsd.regress.mk> 12.include <bsd.regress.mk>
diff --git a/src/regress/lib/libssl/pqueue/expected.txt b/src/regress/lib/libssl/pqueue/expected.txt
deleted file mode 100644
index c59d6cd838..0000000000
--- a/src/regress/lib/libssl/pqueue/expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
1item 6966726167696c69
2item 7374696365787069
3item 737570657263616c
diff --git a/src/regress/lib/libssl/pqueue/pq_test.c b/src/regress/lib/libssl/pqueue/pq_test.c
index a078ba5366..822fdea961 100644
--- a/src/regress/lib/libssl/pqueue/pq_test.c
+++ b/src/regress/lib/libssl/pqueue/pq_test.c
@@ -59,60 +59,77 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62
62#include "pqueue.h" 63#include "pqueue.h"
63 64
64/* remember to change expected.txt if you change these values */ 65static const unsigned char *pq_expected[3] = {
65unsigned char prio1[8] = "supercal"; 66 "ifragili",
66unsigned char prio2[8] = "ifragili"; 67 "sticexpi",
67unsigned char prio3[8] = "sticexpi"; 68 "supercal"
69};
68 70
69static void 71static int
70pqueue_print(pqueue pq) 72test_pqueue(void)
71{ 73{
72 pitem *iter, *item; 74 const unsigned char *prio1 = pq_expected[2];
73 75 const unsigned char *prio2 = pq_expected[0];
74 iter = pqueue_iterator(pq); 76 const unsigned char *prio3 = pq_expected[1];
75 for (item = pqueue_next(&iter); item != NULL; 77 pqueue pq = NULL;
76 item = pqueue_next(&iter)) { 78 pitem *item = NULL;
77 printf("item\t%02x%02x%02x%02x%02x%02x%02x%02x\n", 79 pitem *iter = NULL;
78 item->priority[0], item->priority[1], 80 int i = 0;
79 item->priority[2], item->priority[3], 81 int failed = 1;
80 item->priority[4], item->priority[5],
81 item->priority[6], item->priority[7]);
82 }
83}
84 82
85int 83 if ((pq = pqueue_new()) == NULL)
86main(void) 84 goto failure;
87{
88 pitem *item;
89 pqueue pq;
90 85
91 pq = pqueue_new(); 86 if (!pqueue_insert(pq, pitem_new(prio3, NULL)))
87 goto failure;
88 if (!pqueue_insert(pq, pitem_new(prio1, NULL)))
89 goto failure;
90 if (!pqueue_insert(pq, pitem_new(prio2, NULL)))
91 goto failure;
92 92
93 item = pitem_new(prio3, NULL); 93 if (pqueue_size(pq) != 3)
94 pqueue_insert(pq, item); 94 goto failure;
95 95
96 item = pitem_new(prio1, NULL); 96 if ((item = pqueue_find(pq, prio1)) == NULL)
97 pqueue_insert(pq, item); 97 goto failure;
98 if ((item = pqueue_find(pq, prio2)) == NULL)
99 goto failure;
100 if ((item = pqueue_find(pq, prio3)) == NULL)
101 goto failure;
98 102
99 item = pitem_new(prio2, NULL); 103 if ((item = pqueue_peek(pq)) == NULL)
100 pqueue_insert(pq, item); 104 goto failure;
101 105
102 item = pqueue_find(pq, prio1); 106 if (memcmp(item->priority, pq_expected[0], 8))
103 fprintf(stderr, "found %p\n", item->priority); 107 goto failure;
104 108
105 item = pqueue_find(pq, prio2); 109 iter = pqueue_iterator(pq);
106 fprintf(stderr, "found %p\n", item->priority); 110 for (item = pqueue_next(&iter); item != NULL; item = pqueue_next(&iter)) {
111 if (memcmp(item->priority, pq_expected[i], 8) != 0)
112 goto failure;
113 i++;
114 }
107 115
108 item = pqueue_find(pq, prio3); 116 failed = (i != 3);
109 fprintf(stderr, "found %p\n", item ? item->priority: 0);
110 117
111 pqueue_print(pq); 118 failure:
112 119
113 for (item = pqueue_pop(pq); item != NULL; item = pqueue_pop(pq)) 120 for (item = pqueue_pop(pq); item != NULL; item = pqueue_pop(pq))
114 pitem_free(item); 121 pitem_free(item);
115
116 pqueue_free(pq); 122 pqueue_free(pq);
117 return 0; 123
124 return failed;
125}
126
127int
128main(void)
129{
130 int failed = 0;
131
132 failed |= test_pqueue();
133
134 return failed;
118} 135}
diff --git a/src/regress/lib/libssl/tlsext/tlsexttest.c b/src/regress/lib/libssl/tlsext/tlsexttest.c
index 4adf27421d..68584998ce 100644
--- a/src/regress/lib/libssl/tlsext/tlsexttest.c
+++ b/src/regress/lib/libssl/tlsext/tlsexttest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tlsexttest.c,v 1.92 2024/09/11 15:04:16 tb Exp $ */ 1/* $OpenBSD: tlsexttest.c,v 1.94 2025/05/03 08:37:28 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -3740,6 +3740,11 @@ test_tlsext_keyshare_client(void)
3740 FAIL("Did not select a key share"); 3740 FAIL("Did not select a key share");
3741 goto done; 3741 goto done;
3742 } 3742 }
3743 if (tls_key_share_group(ssl->s3->hs.key_share) != 29) {
3744 FAIL("wrong key share group: got %d, expected 29\n",
3745 tls_key_share_group(ssl->s3->hs.key_share));
3746 goto done;
3747 }
3743 3748
3744 /* 3749 /*
3745 * Pretend the client did not send the supported groups extension. We 3750 * Pretend the client did not send the supported groups extension. We
@@ -4542,12 +4547,10 @@ test_tlsext_valid_hostnames(void)
4542#define N_TLSEXT_RANDOMIZATION_TESTS 1000 4547#define N_TLSEXT_RANDOMIZATION_TESTS 1000
4543 4548
4544static int 4549static int
4545test_tlsext_check_extension_order(SSL *ssl) 4550test_tlsext_check_psk_is_last_extension(SSL *ssl)
4546{ 4551{
4547 const struct tls_extension *ext; 4552 const struct tls_extension *ext;
4548 uint16_t type; 4553 uint16_t type;
4549 size_t alpn_idx, sni_idx;
4550 size_t i;
4551 4554
4552 if (ssl->tlsext_build_order_len == 0) { 4555 if (ssl->tlsext_build_order_len == 0) {
4553 FAIL("Unexpected zero build order length"); 4556 FAIL("Unexpected zero build order length");
@@ -4560,34 +4563,6 @@ test_tlsext_check_extension_order(SSL *ssl)
4560 return 1; 4563 return 1;
4561 } 4564 }
4562 4565
4563 if (ssl->server)
4564 return 0;
4565
4566 alpn_idx = sni_idx = ssl->tlsext_build_order_len;
4567 for (i = 0; i < ssl->tlsext_build_order_len; i++) {
4568 ext = ssl->tlsext_build_order[i];
4569 if (tls_extension_type(ext) == TLSEXT_TYPE_alpn)
4570 alpn_idx = i;
4571 if (tls_extension_type(ext) == TLSEXT_TYPE_server_name)
4572 sni_idx = i;
4573 }
4574
4575 if (alpn_idx == ssl->tlsext_build_order_len) {
4576 FAIL("could not find alpn extension\n");
4577 return 1;
4578 }
4579
4580 if (sni_idx == ssl->tlsext_build_order_len) {
4581 FAIL("could not find alpn extension\n");
4582 return 1;
4583 }
4584
4585 if (sni_idx >= alpn_idx) {
4586 FAIL("sni does not precede alpn: %zu >= %zu\n",
4587 sni_idx, alpn_idx);
4588 return 1;
4589 }
4590
4591 return 0; 4566 return 0;
4592} 4567}
4593 4568
@@ -4600,7 +4575,7 @@ test_tlsext_randomized_extensions(SSL *ssl)
4600 for (i = 0; i < N_TLSEXT_RANDOMIZATION_TESTS; i++) { 4575 for (i = 0; i < N_TLSEXT_RANDOMIZATION_TESTS; i++) {
4601 if (!tlsext_randomize_build_order(ssl)) 4576 if (!tlsext_randomize_build_order(ssl))
4602 errx(1, "failed to randomize extensions"); 4577 errx(1, "failed to randomize extensions");
4603 failed |= test_tlsext_check_extension_order(ssl); 4578 failed |= test_tlsext_check_psk_is_last_extension(ssl);
4604 } 4579 }
4605 4580
4606 return failed; 4581 return failed;
diff --git a/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py b/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py
index 91aedad165..ff678ec9a8 100644
--- a/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py
+++ b/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py
@@ -1,4 +1,4 @@
1# $OpenBSD: tlsfuzzer.py,v 1.56 2024/09/18 19:12:37 tb Exp $ 1# $OpenBSD: tlsfuzzer.py,v 1.57 2025/06/15 09:44:57 tb Exp $
2# 2#
3# Copyright (c) 2020 Theo Buehler <tb@openbsd.org> 3# Copyright (c) 2020 Theo Buehler <tb@openbsd.org>
4# 4#
@@ -72,7 +72,7 @@ def substitute_alert(want, got):
72 return f"Expected alert description \"{want}\" " \ 72 return f"Expected alert description \"{want}\" " \
73 + f"does not match received \"{got}\"" 73 + f"does not match received \"{got}\""
74 74
75# test-tls13-finished.py has 70 failing tests that expect a "decode_error" 75# test_tls13_finished.py has 70 failing tests that expect a "decode_error"
76# instead of the "decrypt_error" sent by tls13_server_finished_recv(). 76# instead of the "decrypt_error" sent by tls13_server_finished_recv().
77# Both alerts appear to be reasonable in this context, so work around this 77# Both alerts appear to be reasonable in this context, so work around this
78# in the test instead of the library. 78# in the test instead of the library.
@@ -164,46 +164,46 @@ def generate_test_tls13_finished_args():
164 return args 164 return args
165 165
166tls13_tests = TestGroup("TLSv1.3 tests", [ 166tls13_tests = TestGroup("TLSv1.3 tests", [
167 Test("test-tls13-ccs.py"), 167 Test("test_tls13_ccs.py"),
168 Test("test-tls13-conversation.py"), 168 Test("test_tls13_conversation.py"),
169 Test("test-tls13-count-tickets.py"), 169 Test("test_tls13_count_tickets.py"),
170 Test("test-tls13-empty-alert.py"), 170 Test("test_tls13_empty_alert.py"),
171 Test("test-tls13-finished.py", generate_test_tls13_finished_args()), 171 Test("test_tls13_finished.py", generate_test_tls13_finished_args()),
172 Test("test-tls13-finished-plaintext.py"), 172 Test("test_tls13_finished_plaintext.py"),
173 Test("test-tls13-hrr.py"), 173 Test("test_tls13_hrr.py"),
174 Test("test-tls13-keyshare-omitted.py"), 174 Test("test_tls13_keyshare_omitted.py"),
175 Test("test-tls13-legacy-version.py"), 175 Test("test_tls13_legacy_version.py"),
176 Test("test-tls13-nociphers.py"), 176 Test("test_tls13_nociphers.py"),
177 Test("test-tls13-record-padding.py"), 177 Test("test_tls13_record_padding.py"),
178 # Exclude QUIC transport parameters 178 # Exclude QUIC transport parameters
179 Test("test-tls13-shuffled-extentions.py", [ "--exc", "57" ]), 179 Test("test_tls13_shuffled_extentions.py", [ "--exc", "57" ]),
180 Test("test-tls13-zero-content-type.py"), 180 Test("test_tls13_zero_content_type.py"),
181 181
182 # The skipped tests fail due to a bug in BIO_gets() which masks the retry 182 # The skipped tests fail due to a bug in BIO_gets() which masks the retry
183 # signalled from an SSL_read() failure. Testing with httpd(8) shows we're 183 # signalled from an SSL_read() failure. Testing with httpd(8) shows we're
184 # handling these corner cases correctly since tls13_record_layer.c -r1.47. 184 # handling these corner cases correctly since tls13_record_layer.c -r1.47.
185 Test("test-tls13-zero-length-data.py", [ 185 Test("test_tls13_zero_length_data.py", [
186 "-e", "zero-length app data", 186 "-e", "zero-length app data",
187 "-e", "zero-length app data with large padding", 187 "-e", "zero-length app data with large padding",
188 "-e", "zero-length app data with padding", 188 "-e", "zero-length app data with padding",
189 ]), 189 ]),
190 190
191 # We don't currently handle NSTs 191 # We don't currently handle NSTs
192 Test("test-tls13-connection-abort.py", ["-e", "After NewSessionTicket"]), 192 Test("test_tls13_connection_abort.py", ["-e", "After NewSessionTicket"]),
193]) 193])
194 194
195# Tests that take a lot of time (> ~30s on an x280) 195# Tests that take a lot of time (> ~30s on an x280)
196tls13_slow_tests = TestGroup("slow TLSv1.3 tests", [ 196tls13_slow_tests = TestGroup("slow TLSv1.3 tests", [
197 # XXX: Investigate the occasional message 197 # XXX: Investigate the occasional message
198 # "Got shared secret with 1 most significant bytes equal to zero." 198 # "Got shared secret with 1 most significant bytes equal to zero."
199 Test("test-tls13-dhe-shared-secret-padding.py", tls13_unsupported_ciphers), 199 Test("test_tls13_dhe_shared_secret_padding.py", tls13_unsupported_ciphers),
200 200
201 Test("test-tls13-invalid-ciphers.py"), 201 Test("test_tls13_invalid_ciphers.py"),
202 Test("test-tls13-serverhello-random.py", tls13_unsupported_ciphers), 202 Test("test_tls13_serverhello_random.py", tls13_unsupported_ciphers),
203 203
204 # Mark two tests cases as xfail for now. The tests expect an arguably 204 # Mark two tests cases as xfail for now. The tests expect an arguably
205 # correct decode_error while we send a decrypt_error (like fizz/boring). 205 # correct decode_error while we send a decrypt_error (like fizz/boring).
206 Test("test-tls13-record-layer-limits.py", [ 206 Test("test_tls13_record_layer_limits.py", [
207 "-x", "max size payload (2**14) of Finished msg, with 16348 bytes of left padding, cipher TLS_AES_128_GCM_SHA256", 207 "-x", "max size payload (2**14) of Finished msg, with 16348 bytes of left padding, cipher TLS_AES_128_GCM_SHA256",
208 "-X", substitute_alert("decode_error", "decrypt_error"), 208 "-X", substitute_alert("decode_error", "decrypt_error"),
209 "-x", "max size payload (2**14) of Finished msg, with 16348 bytes of left padding, cipher TLS_CHACHA20_POLY1305_SHA256", 209 "-x", "max size payload (2**14) of Finished msg, with 16348 bytes of left padding, cipher TLS_CHACHA20_POLY1305_SHA256",
@@ -212,22 +212,22 @@ tls13_slow_tests = TestGroup("slow TLSv1.3 tests", [
212 # We don't accept an empty ECPF extension since it must advertise the 212 # We don't accept an empty ECPF extension since it must advertise the
213 # uncompressed point format. Exclude this extension type from the test. 213 # uncompressed point format. Exclude this extension type from the test.
214 Test( 214 Test(
215 "test-tls13-large-number-of-extensions.py", 215 "test_tls13_large_number_of_extensions.py",
216 tls13_args = ["--exc", "11"], 216 tls13_args = ["--exc", "11"],
217 ), 217 ),
218]) 218])
219 219
220tls13_extra_cert_tests = TestGroup("TLSv1.3 certificate tests", [ 220tls13_extra_cert_tests = TestGroup("TLSv1.3 certificate tests", [
221 # need to set up client certs to run these 221 # need to set up client certs to run these
222 Test("test-tls13-certificate-request.py"), 222 Test("test_tls13_certificate_request.py"),
223 Test("test-tls13-certificate-verify.py"), 223 Test("test_tls13_certificate_verify.py"),
224 Test("test-tls13-ecdsa-in-certificate-verify.py"), 224 Test("test_tls13_ecdsa_in_certificate_verify.py"),
225 Test("test-tls13-eddsa-in-certificate-verify.py"), 225 Test("test_tls13_eddsa_in_certificate_verify.py"),
226 226
227 # Test expects the server to have installed three certificates: 227 # Test expects the server to have installed three certificates:
228 # with P-256, P-384 and P-521 curve. Also SHA1+ECDSA is verified 228 # with P-256, P-384 and P-521 curve. Also SHA1+ECDSA is verified
229 # to not work. 229 # to not work.
230 Test("test-tls13-ecdsa-support.py"), 230 Test("test_tls13_ecdsa_support.py"),
231]) 231])
232 232
233tls13_failing_tests = TestGroup("failing TLSv1.3 tests", [ 233tls13_failing_tests = TestGroup("failing TLSv1.3 tests", [
@@ -235,7 +235,7 @@ tls13_failing_tests = TestGroup("failing TLSv1.3 tests", [
235 # With X25519, we accept weak peer public keys and fail when we actually 235 # With X25519, we accept weak peer public keys and fail when we actually
236 # compute the keyshare. Other tests seem to indicate that we could be 236 # compute the keyshare. Other tests seem to indicate that we could be
237 # stricter about what keyshares we accept. 237 # stricter about what keyshares we accept.
238 Test("test-tls13-crfg-curves.py", [ 238 Test("test_tls13_crfg_curves.py", [
239 '-e', 'all zero x448 key share', 239 '-e', 'all zero x448 key share',
240 '-e', 'empty x448 key share', 240 '-e', 'empty x448 key share',
241 '-e', 'sanity x448 with compression ansiX962_compressed_char2', 241 '-e', 'sanity x448 with compression ansiX962_compressed_char2',
@@ -245,7 +245,7 @@ tls13_failing_tests = TestGroup("failing TLSv1.3 tests", [
245 '-e', 'too small x448 key share', 245 '-e', 'too small x448 key share',
246 '-e', 'x448 key share of "1"', 246 '-e', 'x448 key share of "1"',
247 ]), 247 ]),
248 Test("test-tls13-ecdhe-curves.py", [ 248 Test("test_tls13_ecdhe_curves.py", [
249 '-e', 'sanity - x448', 249 '-e', 'sanity - x448',
250 '-e', 'x448 - key share from other curve', 250 '-e', 'x448 - key share from other curve',
251 '-e', 'x448 - point at infinity', 251 '-e', 'x448 - point at infinity',
@@ -258,21 +258,21 @@ tls13_failing_tests = TestGroup("failing TLSv1.3 tests", [
258 # We have the logic corresponding to NSS's fix for CVE-2020-25648 258 # We have the logic corresponding to NSS's fix for CVE-2020-25648
259 # https://hg.mozilla.org/projects/nss/rev/57bbefa793232586d27cee83e74411171e128361 259 # https://hg.mozilla.org/projects/nss/rev/57bbefa793232586d27cee83e74411171e128361
260 # so should not be affected by this issue. 260 # so should not be affected by this issue.
261 Test("test-tls13-multiple-ccs-messages.py"), 261 Test("test_tls13_multiple_ccs_messages.py"),
262 262
263 # https://github.com/openssl/openssl/issues/8369 263 # https://github.com/openssl/openssl/issues/8369
264 Test("test-tls13-obsolete-curves.py"), 264 Test("test_tls13_obsolete_curves.py"),
265 265
266 # 3 failing rsa_pss_pss tests 266 # 3 failing rsa_pss_pss tests
267 Test("test-tls13-rsa-signatures.py"), 267 Test("test_tls13_rsa_signatures.py"),
268 268
269 # The failing tests all expect an ri extension. What's up with that? 269 # The failing tests all expect an ri extension. What's up with that?
270 Test("test-tls13-version-negotiation.py"), 270 Test("test_tls13_version_negotiation.py"),
271]) 271])
272 272
273tls13_slow_failing_tests = TestGroup("slow, failing TLSv1.3 tests", [ 273tls13_slow_failing_tests = TestGroup("slow, failing TLSv1.3 tests", [
274 # Other test failures bugs in keyshare/tlsext negotiation? 274 # Other test failures bugs in keyshare/tlsext negotiation?
275 Test("test-tls13-unrecognised-groups.py"), # unexpected closure 275 Test("test_tls13_unrecognised_groups.py"), # unexpected closure
276 276
277 # 5 occasional failures: 277 # 5 occasional failures:
278 # 'app data split, conversation with KeyUpdate msg' 278 # 'app data split, conversation with KeyUpdate msg'
@@ -280,43 +280,43 @@ tls13_slow_failing_tests = TestGroup("slow, failing TLSv1.3 tests", [
280 # 'multiple KeyUpdate messages' 280 # 'multiple KeyUpdate messages'
281 # 'post-handshake KeyUpdate msg with update_not_request' 281 # 'post-handshake KeyUpdate msg with update_not_request'
282 # 'post-handshake KeyUpdate msg with update_request' 282 # 'post-handshake KeyUpdate msg with update_request'
283 Test("test-tls13-keyupdate.py"), 283 Test("test_tls13_keyupdate.py"),
284 284
285 Test("test-tls13-symetric-ciphers.py"), # unexpected message from peer 285 Test("test_tls13_symetric_ciphers.py"), # unexpected message from peer
286 286
287 # 6 tests fail: 'rsa_pkcs1_{md5,sha{1,224,256,384,512}} signature' 287 # 6 tests fail: 'rsa_pkcs1_{md5,sha{1,224,256,384,512}} signature'
288 # We send server hello, but the test expects handshake_failure 288 # We send server hello, but the test expects handshake_failure
289 Test("test-tls13-pkcs-signature.py"), 289 Test("test_tls13_pkcs_signature.py"),
290 # 8 tests fail: 'tls13 signature rsa_pss_{pss,rsae}_sha{256,384,512} 290 # 8 tests fail: 'tls13 signature rsa_pss_{pss,rsae}_sha{256,384,512}
291 Test("test-tls13-rsapss-signatures.py"), 291 Test("test_tls13_rsapss_signatures.py"),
292]) 292])
293 293
294tls13_unsupported_tests = TestGroup("TLSv1.3 tests for unsupported features", [ 294tls13_unsupported_tests = TestGroup("TLSv1.3 tests for unsupported features", [
295 # Tests for features we don't support 295 # Tests for features we don't support
296 Test("test-tls13-0rtt-garbage.py"), 296 Test("test_tls13_0rtt_garbage.py"),
297 Test("test-tls13-ffdhe-groups.py"), 297 Test("test_tls13_ffdhe_groups.py"),
298 Test("test-tls13-ffdhe-sanity.py"), 298 Test("test_tls13_ffdhe_sanity.py"),
299 Test("test-tls13-psk_dhe_ke.py"), 299 Test("test_tls13_psk_dhe_ke.py"),
300 Test("test-tls13-psk_ke.py"), 300 Test("test_tls13_psk_ke.py"),
301 301
302 # need server to react to HTTP GET for /keyupdate 302 # need server to react to HTTP GET for /keyupdate
303 Test("test-tls13-keyupdate-from-server.py"), 303 Test("test_tls13_keyupdate_from_server.py"),
304 304
305 # needs an echo server 305 # needs an echo server
306 Test("test-tls13-lengths.py"), 306 Test("test_tls13_lengths.py"),
307 307
308 # Weird test: tests servers that don't support 1.3 308 # Weird test: tests servers that don't support 1.3
309 Test("test-tls13-non-support.py"), 309 Test("test_tls13_non_support.py"),
310 310
311 # broken test script 311 # broken test script
312 # UnboundLocalError: local variable 'cert' referenced before assignment 312 # UnboundLocalError: local variable 'cert' referenced before assignment
313 Test("test-tls13-post-handshake-auth.py"), 313 Test("test_tls13_post_handshake_auth.py"),
314 314
315 # ExpectNewSessionTicket 315 # ExpectNewSessionTicket
316 Test("test-tls13-session-resumption.py"), 316 Test("test_tls13_session_resumption.py"),
317 317
318 # Server must be configured to support only rsa_pss_rsae_sha512 318 # Server must be configured to support only rsa_pss_rsae_sha512
319 Test("test-tls13-signature-algorithms.py"), 319 Test("test_tls13_signature_algorithms.py"),
320]) 320])
321 321
322tls12_exclude_legacy_protocols = [ 322tls12_exclude_legacy_protocols = [
@@ -345,52 +345,52 @@ tls12_exclude_legacy_protocols = [
345 345
346tls12_tests = TestGroup("TLSv1.2 tests", [ 346tls12_tests = TestGroup("TLSv1.2 tests", [
347 # Tests that pass as they are. 347 # Tests that pass as they are.
348 Test("test-aes-gcm-nonces.py"), 348 Test("test_aes_gcm_nonces.py"),
349 Test("test-connection-abort.py"), 349 Test("test_connection_abort.py"),
350 Test("test-conversation.py"), 350 Test("test_conversation.py"),
351 Test("test-cve-2016-2107.py"), 351 Test("test_cve_2016_2107.py"),
352 Test("test-cve-2016-6309.py"), 352 Test("test_cve_2016_6309.py"),
353 Test("test-dhe-rsa-key-exchange.py"), 353 Test("test_dhe_rsa_key_exchange.py"),
354 Test("test-early-application-data.py"), 354 Test("test_early_application_data.py"),
355 Test("test-empty-extensions.py"), 355 Test("test_empty_extensions.py"),
356 Test("test-extensions.py"), 356 Test("test_extensions.py"),
357 Test("test-fuzzed-MAC.py"), 357 Test("test_fuzzed_MAC.py"),
358 Test("test-fuzzed-ciphertext.py"), 358 Test("test_fuzzed_ciphertext.py"),
359 Test("test-fuzzed-finished.py"), 359 Test("test_fuzzed_finished.py"),
360 Test("test-fuzzed-padding.py"), 360 Test("test_fuzzed_padding.py"),
361 Test("test-fuzzed-plaintext.py"), # fails once in a while 361 Test("test_fuzzed_plaintext.py"), # fails once in a while
362 Test("test-hello-request-by-client.py"), 362 Test("test_hello_request_by_client.py"),
363 Test("test-invalid-cipher-suites.py"), 363 Test("test_invalid_cipher_suites.py"),
364 Test("test-invalid-content-type.py"), 364 Test("test_invalid_content_type.py"),
365 Test("test-invalid-session-id.py"), 365 Test("test_invalid_session_id.py"),
366 Test("test-invalid-version.py"), 366 Test("test_invalid_version.py"),
367 Test("test-large-number-of-extensions.py"), 367 Test("test_large_number_of_extensions.py"),
368 Test("test-lucky13.py"), 368 Test("test_lucky13.py"),
369 Test("test-message-skipping.py"), 369 Test("test_message_skipping.py"),
370 Test("test-no-heartbeat.py"), 370 Test("test_no_heartbeat.py"),
371 Test("test-record-layer-fragmentation.py"), 371 Test("test_record_layer_fragmentation.py"),
372 Test("test-sslv2-connection.py"), 372 Test("test_sslv2_connection.py"),
373 Test("test-truncating-of-finished.py"), 373 Test("test_truncating_of_finished.py"),
374 Test("test-truncating-of-kRSA-client-key-exchange.py"), 374 Test("test_truncating_of_kRSA_client_key_exchange.py"),
375 Test("test-unsupported-curve-fallback.py"), 375 Test("test_unsupported_curve_fallback.py"),
376 Test("test-version-numbers.py"), 376 Test("test_version_numbers.py"),
377 Test("test-zero-length-data.py"), 377 Test("test_zero_length_data.py"),
378 378
379 # Tests that need tweaking for unsupported features and ciphers. 379 # Tests that need tweaking for unsupported features and ciphers.
380 Test( 380 Test(
381 "test-atypical-padding.py", [ 381 "test_atypical_padding.py", [
382 "-e", "sanity - encrypt then MAC", 382 "-e", "sanity - encrypt then MAC",
383 "-e", "2^14 bytes of AppData with 256 bytes of padding (SHA1 + Encrypt then MAC)", 383 "-e", "2^14 bytes of AppData with 256 bytes of padding (SHA1 + Encrypt then MAC)",
384 ] 384 ]
385 ), 385 ),
386 Test( 386 Test(
387 "test-ccs.py", [ 387 "test_ccs.py", [
388 "-x", "two bytes long CCS", 388 "-x", "two bytes long CCS",
389 "-X", substitute_alert("unexpected_message", "decode_error"), 389 "-X", substitute_alert("unexpected_message", "decode_error"),
390 ] 390 ]
391 ), 391 ),
392 Test( 392 Test(
393 "test-dhe-rsa-key-exchange-signatures.py", [ 393 "test_dhe_rsa_key_exchange_signatures.py", [
394 "-e", "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA sha224 signature", 394 "-e", "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA sha224 signature",
395 "-e", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 sha224 signature", 395 "-e", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 sha224 signature",
396 "-e", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA sha224 signature", 396 "-e", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA sha224 signature",
@@ -398,14 +398,14 @@ tls12_tests = TestGroup("TLSv1.2 tests", [
398 "-e", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA sha224 signature", 398 "-e", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA sha224 signature",
399 ] 399 ]
400 ), 400 ),
401 Test("test-dhe-rsa-key-exchange-with-bad-messages.py", [ 401 Test("test_dhe_rsa_key_exchange_with_bad_messages.py", [
402 "-x", "invalid dh_Yc value - missing", 402 "-x", "invalid dh_Yc value - missing",
403 "-X", substitute_alert("decode_error", "illegal_parameter"), 403 "-X", substitute_alert("decode_error", "illegal_parameter"),
404 ]), 404 ]),
405 Test("test-dhe-key-share-random.py", tls12_exclude_legacy_protocols), 405 Test("test_dhe_key_share_random.py", tls12_exclude_legacy_protocols),
406 Test("test-export-ciphers-rejected.py", ["--min-ver", "TLSv1.2"]), 406 Test("test_export_ciphers_rejected.py", ["--min-ver", "TLSv1.2"]),
407 Test( 407 Test(
408 "test-downgrade-protection.py", 408 "test_downgrade_protection.py",
409 tls12_args = ["--server-max-protocol", "TLSv1.2"], 409 tls12_args = ["--server-max-protocol", "TLSv1.2"],
410 tls13_args = [ 410 tls13_args = [
411 "--server-max-protocol", "TLSv1.3", 411 "--server-max-protocol", "TLSv1.3",
@@ -414,7 +414,7 @@ tls12_tests = TestGroup("TLSv1.2 tests", [
414 ] 414 ]
415 ), 415 ),
416 Test( 416 Test(
417 "test-fallback-scsv.py", 417 "test_fallback_scsv.py",
418 tls13_args = [ 418 tls13_args = [
419 "--tls-1.3", 419 "--tls-1.3",
420 "-e", "FALLBACK - hello TLSv1.1 - pos 0", 420 "-e", "FALLBACK - hello TLSv1.1 - pos 0",
@@ -428,7 +428,7 @@ tls12_tests = TestGroup("TLSv1.2 tests", [
428 ] 428 ]
429 ), 429 ),
430 430
431 Test("test-invalid-compression-methods.py", [ 431 Test("test_invalid_compression_methods.py", [
432 "-x", "invalid compression methods", 432 "-x", "invalid compression methods",
433 "-X", substitute_alert("illegal_parameter", "decode_error"), 433 "-X", substitute_alert("illegal_parameter", "decode_error"),
434 "-x", "only deflate compression method", 434 "-x", "only deflate compression method",
@@ -437,134 +437,134 @@ tls12_tests = TestGroup("TLSv1.2 tests", [
437 437
438 # Skip extended_master_secret test. Since we don't support this 438 # Skip extended_master_secret test. Since we don't support this
439 # extension, we don't notice that it was dropped. 439 # extension, we don't notice that it was dropped.
440 Test("test-renegotiation-changed-clienthello.py", [ 440 Test("test_renegotiation_changed_clienthello.py", [
441 "-e", "drop extended_master_secret in renegotiation", 441 "-e", "drop extended_master_secret in renegotiation",
442 ]), 442 ]),
443 443
444 Test("test-sessionID-resumption.py", [ 444 Test("test_sessionID_resumption.py", [
445 "-x", "Client Hello too long session ID", 445 "-x", "Client Hello too long session ID",
446 "-X", substitute_alert("decode_error", "illegal_parameter"), 446 "-X", substitute_alert("decode_error", "illegal_parameter"),
447 ]), 447 ]),
448 448
449 # Without --sig-algs-drop-ok, two tests fail since we do not currently 449 # Without --sig-algs-drop-ok, two tests fail since we do not currently
450 # implement the signature_algorithms_cert extension (although we MUST). 450 # implement the signature_algorithms_cert extension (although we MUST).
451 Test("test-sig-algs-renegotiation-resumption.py", ["--sig-algs-drop-ok"]), 451 Test("test_sig_algs_renegotiation_resumption.py", ["--sig-algs-drop-ok"]),
452 452
453 Test("test-serverhello-random.py", args = tls12_exclude_legacy_protocols), 453 Test("test_serverhello_random.py", args = tls12_exclude_legacy_protocols),
454 454
455 Test("test-chacha20.py", [ "-e", "Chacha20 in TLS1.1" ]), 455 Test("test_chacha20.py", [ "-e", "Chacha20 in TLS1.1" ]),
456]) 456])
457 457
458tls12_slow_tests = TestGroup("slow TLSv1.2 tests", [ 458tls12_slow_tests = TestGroup("slow TLSv1.2 tests", [
459 Test("test-cve-2016-7054.py"), 459 Test("test_cve_2016_7054.py"),
460 Test("test-dhe-no-shared-secret-padding.py", tls12_exclude_legacy_protocols), 460 Test("test_dhe_no_shared_secret_padding.py", tls12_exclude_legacy_protocols),
461 Test("test-ecdhe-padded-shared-secret.py", tls12_exclude_legacy_protocols), 461 Test("test_ecdhe_padded_shared_secret.py", tls12_exclude_legacy_protocols),
462 Test("test-ecdhe-rsa-key-share-random.py", tls12_exclude_legacy_protocols), 462 Test("test_ecdhe_rsa_key_share_random.py", tls12_exclude_legacy_protocols),
463 # Start at extension number 58 to avoid QUIC transport parameters (57) 463 # Start at extension number 58 to avoid QUIC transport parameters (57)
464 Test("test-large-hello.py", [ "-m", "58" ]), 464 Test("test_large_hello.py", [ "-m", "58" ]),
465]) 465])
466 466
467tls12_failing_tests = TestGroup("failing TLSv1.2 tests", [ 467tls12_failing_tests = TestGroup("failing TLSv1.2 tests", [
468 # no shared cipher 468 # no shared cipher
469 Test("test-aesccm.py"), 469 Test("test_aesccm.py"),
470 # need server to set up alpn 470 # need server to set up alpn
471 Test("test-alpn-negotiation.py"), 471 Test("test_alpn_negotiation.py"),
472 # Failing on TLS_RSA_WITH_AES_128_CBC_SHA because server does not support it. 472 # Failing on TLS_RSA_WITH_AES_128_CBC_SHA because server does not support it.
473 Test("test-bleichenbacher-timing-pregenerate.py"), 473 Test("test_bleichenbacher_timing_pregenerate.py"),
474 # many tests fail due to unexpected server_name extension 474 # many tests fail due to unexpected server_name extension
475 Test("test-bleichenbacher-workaround.py"), 475 Test("test_bleichenbacher_workaround.py"),
476 476
477 # need client key and cert plus extra server setup 477 # need client key and cert plus extra server setup
478 Test("test-certificate-malformed.py"), 478 Test("test_certificate_malformed.py"),
479 Test("test-certificate-request.py"), 479 Test("test_certificate_request.py"),
480 Test("test-certificate-verify-malformed-sig.py"), 480 Test("test_certificate_verify_malformed_sig.py"),
481 Test("test-certificate-verify-malformed.py"), 481 Test("test_certificate_verify_malformed.py"),
482 Test("test-certificate-verify.py"), 482 Test("test_certificate_verify.py"),
483 Test("test-ecdsa-in-certificate-verify.py"), 483 Test("test_ecdsa_in_certificate_verify.py"),
484 Test("test-eddsa-in-certificate-verify.py"), 484 Test("test_eddsa_in_certificate_verify.py"),
485 Test("test-renegotiation-disabled-client-cert.py"), 485 Test("test_renegotiation_disabled_client_cert.py"),
486 Test("test-rsa-pss-sigs-on-certificate-verify.py"), 486 Test("test_rsa_pss_sigs_on_certificate_verify.py"),
487 Test("test-rsa-sigs-on-certificate-verify.py"), 487 Test("test_rsa_sigs_on_certificate_verify.py"),
488 488
489 # test doesn't expect session ticket 489 # test doesn't expect session ticket
490 Test("test-client-compatibility.py"), 490 Test("test_client_compatibility.py"),
491 # abrupt closure 491 # abrupt closure
492 Test("test-client-hello-max-size.py"), 492 Test("test_client_hello_max_size.py"),
493 # unknown signature algorithms 493 # unknown signature algorithms
494 Test("test-clienthello-md5.py"), 494 Test("test_clienthello_md5.py"),
495 495
496 # Tests expect an illegal_parameter or a decode_error alert. Should be 496 # Tests expect an illegal_parameter or a decode_error alert. Should be
497 # added to ssl3_get_client_key_exchange on kex function failure. 497 # added to ssl3_get_client_key_exchange on kex function failure.
498 Test("test-ecdhe-rsa-key-exchange-with-bad-messages.py"), 498 Test("test_ecdhe_rsa_key_exchange_with_bad_messages.py"),
499 499
500 # We send a handshake_failure due to no shared ciphers while the 500 # We send a handshake_failure due to no shared ciphers while the
501 # test expects to succeed. 501 # test expects to succeed.
502 Test("test-ecdhe-rsa-key-exchange.py"), 502 Test("test_ecdhe_rsa_key_exchange.py"),
503 503
504 # no shared cipher 504 # no shared cipher
505 Test("test-ecdsa-sig-flexibility.py"), 505 Test("test_ecdsa_sig_flexibility.py"),
506 506
507 # Tests expect SH but we send unexpected_message or handshake_failure 507 # Tests expect SH but we send unexpected_message or handshake_failure
508 # 'Application data inside Client Hello' 508 # 'Application data inside Client Hello'
509 # 'Application data inside Client Key Exchange' 509 # 'Application data inside Client Key Exchange'
510 # 'Application data inside Finished' 510 # 'Application data inside Finished'
511 Test("test-interleaved-application-data-and-fragmented-handshakes-in-renegotiation.py"), 511 Test("test_interleaved_application_data_and_fragmented_handshakes_in_renegotiation.py"),
512 # Tests expect SH but we send handshake_failure 512 # Tests expect SH but we send handshake_failure
513 # 'Application data before Change Cipher Spec' 513 # 'Application data before Change Cipher Spec'
514 # 'Application data before Client Key Exchange' 514 # 'Application data before Client Key Exchange'
515 # 'Application data before Finished' 515 # 'Application data before Finished'
516 Test("test-interleaved-application-data-in-renegotiation.py"), 516 Test("test_interleaved_application_data_in_renegotiation.py"),
517 517
518 # broken test script 518 # broken test script
519 # TypeError: '<' not supported between instances of 'int' and 'NoneType' 519 # TypeError: '<' not supported between instances of 'int' and 'NoneType'
520 Test("test-invalid-client-hello-w-record-overflow.py"), 520 Test("test_invalid_client_hello_w_record_overflow.py"),
521 521
522 # Lots of failures. abrupt closure 522 # Lots of failures. abrupt closure
523 Test("test-invalid-client-hello.py"), 523 Test("test_invalid_client_hello.py"),
524 524
525 # abrupt closure 525 # abrupt closure
526 # 'encrypted premaster set to all zero (n)' n in 256 384 512 526 # 'encrypted premaster set to all zero (n)' n in 256 384 512
527 Test("test-invalid-rsa-key-exchange-messages.py"), 527 Test("test_invalid_rsa_key_exchange_messages.py"),
528 528
529 # test expects illegal_parameter, we send unrecognized_name (which seems 529 # test expects illegal_parameter, we send unrecognized_name (which seems
530 # correct according to rfc 6066?) 530 # correct according to rfc 6066?)
531 Test("test-invalid-server-name-extension-resumption.py"), 531 Test("test_invalid_server_name_extension_resumption.py"),
532 # let through some server names without sending an alert 532 # let through some server names without sending an alert
533 # again illegal_parameter vs unrecognized_name 533 # again illegal_parameter vs unrecognized_name
534 Test("test-invalid-server-name-extension.py"), 534 Test("test_invalid_server_name_extension.py"),
535 535
536 # 4 failures: 536 # 4 failures:
537 # 'insecure (legacy) renegotiation with GET after 2nd handshake' 537 # 'insecure (legacy) renegotiation with GET after 2nd handshake'
538 # 'insecure (legacy) renegotiation with incomplete GET' 538 # 'insecure (legacy) renegotiation with incomplete GET'
539 # 'secure renegotiation with GET after 2nd handshake' 539 # 'secure renegotiation with GET after 2nd handshake'
540 # 'secure renegotiation with incomplete GET' 540 # 'secure renegotiation with incomplete GET'
541 Test("test-legacy-renegotiation.py"), 541 Test("test_legacy_renegotiation.py"),
542 542
543 # 1 failure (timeout): we don't send the unexpected_message alert 543 # 1 failure (timeout): we don't send the unexpected_message alert
544 # 'duplicate change cipher spec after Finished' 544 # 'duplicate change cipher spec after Finished'
545 Test("test-message-duplication.py"), 545 Test("test_message_duplication.py"),
546 546
547 # server should send status_request 547 # server should send status_request
548 Test("test-ocsp-stapling.py"), 548 Test("test_ocsp_stapling.py"),
549 549
550 # unexpected closure 550 # unexpected closure
551 Test("test-openssl-3712.py"), 551 Test("test_openssl_3712.py"),
552 552
553 # failed: 3 (expect an alert, we send AD) 553 # failed: 3 (expect an alert, we send AD)
554 # 'try insecure (legacy) renegotiation with incomplete GET' 554 # 'try insecure (legacy) renegotiation with incomplete GET'
555 # 'try secure renegotiation with GET after 2nd CH' 555 # 'try secure renegotiation with GET after 2nd CH'
556 # 'try secure renegotiation with incomplete GET' 556 # 'try secure renegotiation with incomplete GET'
557 Test("test-renegotiation-disabled.py"), 557 Test("test_renegotiation_disabled.py"),
558 558
559 # 'resumption of safe session with NULL cipher' 559 # 'resumption of safe session with NULL cipher'
560 # 'resumption with cipher from old CH but not selected by server' 560 # 'resumption with cipher from old CH but not selected by server'
561 Test("test-resumption-with-wrong-ciphers.py"), 561 Test("test_resumption_with_wrong_ciphers.py"),
562 562
563 # 'session resumption with empty session_id' 563 # 'session resumption with empty session_id'
564 # 'session resumption with random session_id' 564 # 'session resumption with random session_id'
565 # 'session resumption with renegotiation' 565 # 'session resumption with renegotiation'
566 # AssertionError: Server did not send extension(s): session_ticket 566 # AssertionError: Server did not send extension(s): session_ticket
567 Test("test-session-ticket-resumption.py"), 567 Test("test_session_ticket_resumption.py"),
568 568
569 # 5 failures: 569 # 5 failures:
570 # 'empty sigalgs' 570 # 'empty sigalgs'
@@ -572,7 +572,7 @@ tls12_failing_tests = TestGroup("failing TLSv1.2 tests", [
572 # 'rsa_pss_pss_sha256 only' 572 # 'rsa_pss_pss_sha256 only'
573 # 'rsa_pss_pss_sha384 only' 573 # 'rsa_pss_pss_sha384 only'
574 # 'rsa_pss_pss_sha512 only' 574 # 'rsa_pss_pss_sha512 only'
575 Test("test-sig-algs.py"), 575 Test("test_sig_algs.py"),
576 576
577 # 13 failures: 577 # 13 failures:
578 # 'duplicated n non-rsa schemes' for n in 202 2342 8119 23741 32744 578 # 'duplicated n non-rsa schemes' for n in 202 2342 8119 23741 32744
@@ -581,51 +581,51 @@ tls12_failing_tests = TestGroup("failing TLSv1.2 tests", [
581 # 'tolerance 32758 methods with sig_alg_cert' 581 # 'tolerance 32758 methods with sig_alg_cert'
582 # 'tolerance max 32744 number of methods with sig_alg_cert' 582 # 'tolerance max 32744 number of methods with sig_alg_cert'
583 # 'tolerance max (32760) number of methods' 583 # 'tolerance max (32760) number of methods'
584 Test("test-signature-algorithms.py"), 584 Test("test_signature_algorithms.py"),
585 585
586 # times out 586 # times out
587 Test("test-ssl-death-alert.py"), 587 Test("test_ssl_death_alert.py"),
588 588
589 # 17 pass, 13 fail. padding and truncation 589 # 17 pass, 13 fail. padding and truncation
590 Test("test-truncating-of-client-hello.py"), 590 Test("test_truncating_of_client_hello.py"),
591 591
592 # x448 tests need disabling plus x25519 corner cases need sorting out 592 # x448 tests need disabling plus x25519 corner cases need sorting out
593 Test("test-x25519.py"), 593 Test("test_x25519.py"),
594 594
595 # Needs TLS 1.0 or 1.1 595 # Needs TLS 1.0 or 1.1
596 Test("test-TLSv1_2-rejected-without-TLSv1_2.py"), 596 Test("test_TLSv1_2_rejected_without_TLSv1_2.py"),
597]) 597])
598 598
599tls12_unsupported_tests = TestGroup("TLSv1.2 for unsupported features", [ 599tls12_unsupported_tests = TestGroup("TLSv1.2 for unsupported features", [
600 # protocol_version 600 # protocol_version
601 Test("test-SSLv3-padding.py"), 601 Test("test_SSLv3_padding.py"),
602 # we don't do RSA key exchanges 602 # we don't do RSA key exchanges
603 Test("test-bleichenbacher-timing.py"), 603 Test("test_bleichenbacher_timing.py"),
604 # no encrypt-then-mac 604 # no encrypt-then-mac
605 Test("test-encrypt-then-mac-renegotiation.py"), 605 Test("test_encrypt_then_mac_renegotiation.py"),
606 Test("test-encrypt-then-mac.py"), 606 Test("test_encrypt_then_mac.py"),
607 # no EME support 607 # no EME support
608 Test("test-extended-master-secret-extension-with-client-cert.py"), 608 Test("test_extended_master_secret_extension_with_client_cert.py"),
609 Test("test-extended-master-secret-extension.py"), 609 Test("test_extended_master_secret_extension.py"),
610 # no ffdhe 610 # no ffdhe
611 Test("test-ffdhe-expected-params.py"), 611 Test("test_ffdhe_expected_params.py"),
612 Test("test-ffdhe-negotiation.py"), 612 Test("test_ffdhe_negotiation.py"),
613 # record_size_limit/max_fragment_length extension (RFC 8449) 613 # record_size_limit/max_fragment_length extension (RFC 8449)
614 Test("test-record-size-limit.py"), 614 Test("test_record_size_limit.py"),
615 # expects the server to send the heartbeat extension 615 # expects the server to send the heartbeat extension
616 Test("test-heartbeat.py"), 616 Test("test_heartbeat.py"),
617 # needs an echo server 617 # needs an echo server
618 Test("test-lengths.py"), 618 Test("test_lengths.py"),
619]) 619])
620 620
621# These tests take a ton of time to fail against an 1.3 server, 621# These tests take a ton of time to fail against an 1.3 server,
622# so don't run them against 1.3 pending further investigation. 622# so don't run them against 1.3 pending further investigation.
623legacy_tests = TestGroup("Legacy protocol tests", [ 623legacy_tests = TestGroup("Legacy protocol tests", [
624 Test("test-sslv2-force-cipher-3des.py"), 624 Test("test_sslv2_force_cipher_3des.py"),
625 Test("test-sslv2-force-cipher-non3des.py"), 625 Test("test_sslv2_force_cipher_non3des.py"),
626 Test("test-sslv2-force-cipher.py"), 626 Test("test_sslv2_force_cipher.py"),
627 Test("test-sslv2-force-export-cipher.py"), 627 Test("test_sslv2_force_export_cipher.py"),
628 Test("test-sslv2hello-protocol.py"), 628 Test("test_sslv2hello_protocol.py"),
629]) 629])
630 630
631all_groups = [ 631all_groups = [
diff --git a/src/regress/lib/libtls/tls/tlstest.c b/src/regress/lib/libtls/tls/tlstest.c
index b675c798b4..d52156128d 100644
--- a/src/regress/lib/libtls/tls/tlstest.c
+++ b/src/regress/lib/libtls/tls/tlstest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tlstest.c,v 1.16 2024/08/02 15:02:22 tb Exp $ */ 1/* $OpenBSD: tlstest.c,v 1.17 2025/06/04 10:28:00 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -531,6 +531,142 @@ do_tls_version_tests(void)
531 return failure; 531 return failure;
532} 532}
533 533
534static int
535test_tls_alpn(const char *client_alpn, const char *server_alpn,
536 const char *selected)
537{
538 struct tls_config *client_cfg, *server_cfg;
539 struct tls *client, *server, *server_cctx;
540 const char *got_server, *got_client;
541 int failed = 1;
542
543 if ((client = tls_client()) == NULL)
544 errx(1, "failed to create tls client");
545 if ((client_cfg = tls_config_new()) == NULL)
546 errx(1, "failed to create tls client config");
547 tls_config_insecure_noverifyname(client_cfg);
548 if (tls_config_set_alpn(client_cfg, client_alpn) == -1)
549 errx(1, "failed to set alpn: %s", tls_config_error(client_cfg));
550 if (tls_config_set_ca_file(client_cfg, cafile) == -1)
551 errx(1, "failed to set ca: %s", tls_config_error(client_cfg));
552
553 if ((server = tls_server()) == NULL)
554 errx(1, "failed to create tls server");
555 if ((server_cfg = tls_config_new()) == NULL)
556 errx(1, "failed to create tls server config");
557 if (tls_config_set_alpn(server_cfg, server_alpn) == -1)
558 errx(1, "failed to set alpn: %s", tls_config_error(server_cfg));
559 if (tls_config_set_keypair_file(server_cfg, certfile, keyfile) == -1)
560 errx(1, "failed to set keypair: %s",
561 tls_config_error(server_cfg));
562
563 if (tls_configure(client, client_cfg) == -1)
564 errx(1, "failed to configure client: %s", tls_error(client));
565 tls_reset(server);
566 if (tls_configure(server, server_cfg) == -1)
567 errx(1, "failed to configure server: %s", tls_error(server));
568
569 tls_config_free(client_cfg);
570 tls_config_free(server_cfg);
571
572 circular_init();
573
574 if (tls_accept_cbs(server, &server_cctx, server_read, server_write,
575 NULL) == -1)
576 errx(1, "failed to accept: %s", tls_error(server));
577
578 if (tls_connect_cbs(client, client_read, client_write, NULL,
579 "test") == -1)
580 errx(1, "failed to connect: %s", tls_error(client));
581
582 if (do_client_server_test("alpn", client, server_cctx) != 0)
583 goto fail;
584
585 got_server = tls_conn_alpn_selected(server_cctx);
586 got_client = tls_conn_alpn_selected(client);
587
588 if (got_server == NULL || got_client == NULL) {
589 printf("FAIL: expected ALPN for server and client, got "
590 "server: %p, client %p\n", got_server, got_client);
591 goto fail;
592 }
593
594 if (strcmp(got_server, got_client) != 0) {
595 printf("FAIL: ALPN mismatch: server %s, client %s\n",
596 got_server, got_client);
597 goto fail;
598 }
599
600 if (strcmp(selected, got_server) != 0) {
601 printf("FAIL: ALPN mismatch: want %s, got %s\n",
602 selected, got_server);
603 goto fail;
604 }
605
606 failed = 0;
607
608 fail:
609 tls_free(client);
610 tls_free(server);
611 tls_free(server_cctx);
612
613 return (failed);
614}
615
616static const struct test_alpn {
617 const char *client;
618 const char *server;
619 const char *selected;
620} tls_test_alpn[] = {
621 {
622 .client = "http/2,http/1.1",
623 .server = "http/1.1",
624 .selected = "http/1.1",
625 },
626 {
627 .client = "http/2,http/1.1",
628 .server = "http/2,http/1.1",
629 .selected = "http/2",
630 },
631 {
632 .client = "http/1.1,http/2",
633 .server = "http/2,http/1.1",
634 .selected = "http/2",
635 },
636 {
637 .client = "http/2,http/1.1",
638 .server = "http/1.1,http/2",
639 .selected = "http/1.1",
640 },
641 {
642 .client = "http/1.1",
643 .server = "http/2,http/1.1",
644 .selected = "http/1.1",
645 },
646};
647
648#define N_TLS_ALPN_TESTS (sizeof(tls_test_alpn) / sizeof(tls_test_alpn[0]))
649
650static int
651do_tls_alpn_tests(void)
652{
653 const struct test_alpn *ta;
654 int failure = 0;
655 size_t i;
656
657 printf("== TLS alpn tests ==\n");
658
659 for (i = 0; i < N_TLS_ALPN_TESTS; i++) {
660 ta = &tls_test_alpn[i];
661 printf("INFO: alpn test %zu - client alpn '%s' "
662 "and server alpn '%s'\n", i, ta->client, ta->server);
663 failure |= test_tls_alpn(ta->client, ta->server, ta->selected);
664 printf("\n");
665 }
666
667 return failure;
668}
669
534int 670int
535main(int argc, char **argv) 671main(int argc, char **argv)
536{ 672{
@@ -549,6 +685,7 @@ main(int argc, char **argv)
549 failure |= do_tls_tests(); 685 failure |= do_tls_tests();
550 failure |= do_tls_ordering_tests(); 686 failure |= do_tls_ordering_tests();
551 failure |= do_tls_version_tests(); 687 failure |= do_tls_version_tests();
688 failure |= do_tls_alpn_tests();
552 689
553 return (failure); 690 return (failure);
554} 691}
diff --git a/src/usr.bin/nc/nc.1 b/src/usr.bin/nc/nc.1
index 76b6dc018e..2ffdcd1ea6 100644
--- a/src/usr.bin/nc/nc.1
+++ b/src/usr.bin/nc/nc.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: nc.1,v 1.98 2024/04/01 12:40:18 deraadt Exp $ 1.\" $OpenBSD: nc.1,v 1.101 2025/06/24 13:37:39 tb Exp $
2.\" 2.\"
3.\" Copyright (c) 1996 David Sacerdote 3.\" Copyright (c) 1996 David Sacerdote
4.\" All rights reserved. 4.\" All rights reserved.
@@ -25,7 +25,7 @@
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\" 27.\"
28.Dd $Mdocdate: April 1 2024 $ 28.Dd $Mdocdate: June 24 2025 $
29.Dt NC 1 29.Dt NC 1
30.Os 30.Os
31.Sh NAME 31.Sh NAME
@@ -257,6 +257,10 @@ with the handshake.
257The following TLS options specify a value in the form of a 257The following TLS options specify a value in the form of a
258.Ar key Ns = Ns Ar value 258.Ar key Ns = Ns Ar value
259pair: 259pair:
260.Cm alpn ,
261which allows the TLS ALPN to be specified (see
262.Xr tls_config_set_alpn 3
263for further details);
260.Cm ciphers , 264.Cm ciphers ,
261which allows the supported TLS ciphers to be specified (see 265which allows the supported TLS ciphers to be specified (see
262.Xr tls_config_set_ciphers 3 266.Xr tls_config_set_ciphers 3
@@ -338,12 +342,18 @@ when talking to the proxy server.
338Supported protocols are 342Supported protocols are
339.Cm 4 343.Cm 4
340(SOCKS v.4), 344(SOCKS v.4),
345.Cm 4A
346(SOCKS v.4A),
341.Cm 5 347.Cm 5
342(SOCKS v.5) 348(SOCKS v.5)
343and 349and
344.Cm connect 350.Cm connect
345(HTTPS proxy). 351(HTTPS proxy).
346If the protocol is not specified, SOCKS version 5 is used. 352If the protocol is not specified, SOCKS version 5 is used.
353Note that the SOCKS v.4 protocol is very limited and can only be used when
354the destination host can be resolved to an IPv4 address.
355The other protocols pass the destination as a string to be interpreted
356by the remote proxy and do not have this limitation.
347.It Fl x Ar proxy_address Ns Op : Ns Ar port 357.It Fl x Ar proxy_address Ns Op : Ns Ar port
348Connect to 358Connect to
349.Ar destination 359.Ar destination
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
index 8c60fd1882..e3c9c939e2 100644
--- a/src/usr.bin/nc/netcat.c
+++ b/src/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: netcat.c,v 1.229 2024/11/02 17:19:27 tb Exp $ */ 1/* $OpenBSD: netcat.c,v 1.234 2025/06/24 13:37:11 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> 3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
4 * Copyright (c) 2015 Bob Beck. All rights reserved. 4 * Copyright (c) 2015 Bob Beck. All rights reserved.
@@ -108,6 +108,7 @@ char *tls_expectname; /* required name in peer cert */
108char *tls_expecthash; /* required hash of peer cert */ 108char *tls_expecthash; /* required hash of peer cert */
109char *tls_ciphers; /* TLS ciphers */ 109char *tls_ciphers; /* TLS ciphers */
110char *tls_protocols; /* TLS protocols */ 110char *tls_protocols; /* TLS protocols */
111char *tls_alpn; /* TLS ALPN */
111FILE *Zflag; /* file to save peer cert */ 112FILE *Zflag; /* file to save peer cert */
112 113
113int recvcount, recvlimit; 114int recvcount, recvlimit;
@@ -190,6 +191,8 @@ main(int argc, char *argv[])
190 socksv = -1; /* HTTP proxy CONNECT */ 191 socksv = -1; /* HTTP proxy CONNECT */
191 else if (strcmp(optarg, "4") == 0) 192 else if (strcmp(optarg, "4") == 0)
192 socksv = 4; /* SOCKS v.4 */ 193 socksv = 4; /* SOCKS v.4 */
194 else if (strcasecmp(optarg, "4A") == 0)
195 socksv = 44; /* SOCKS v.4A */
193 else if (strcmp(optarg, "5") == 0) 196 else if (strcmp(optarg, "5") == 0)
194 socksv = 5; /* SOCKS v.5 */ 197 socksv = 5; /* SOCKS v.5 */
195 else 198 else
@@ -532,6 +535,8 @@ main(int argc, char *argv[])
532 errx(1, "%s", tls_config_error(tls_cfg)); 535 errx(1, "%s", tls_config_error(tls_cfg));
533 if (tls_config_set_ciphers(tls_cfg, tls_ciphers) == -1) 536 if (tls_config_set_ciphers(tls_cfg, tls_ciphers) == -1)
534 errx(1, "%s", tls_config_error(tls_cfg)); 537 errx(1, "%s", tls_config_error(tls_cfg));
538 if (tls_alpn != NULL && tls_config_set_alpn(tls_cfg, tls_alpn) == -1)
539 errx(1, "%s", tls_config_error(tls_cfg));
535 if (!lflag && (TLSopt & TLS_CCERT)) 540 if (!lflag && (TLSopt & TLS_CCERT))
536 errx(1, "clientcert is only valid with -l"); 541 errx(1, "clientcert is only valid with -l");
537 if (TLSopt & TLS_NONAME) 542 if (TLSopt & TLS_NONAME)
@@ -1669,11 +1674,12 @@ process_tls_opt(char *s, int *flags)
1669 int flag; 1674 int flag;
1670 char **value; 1675 char **value;
1671 } *t, tlskeywords[] = { 1676 } *t, tlskeywords[] = {
1677 { "alpn", -1, &tls_alpn },
1672 { "ciphers", -1, &tls_ciphers }, 1678 { "ciphers", -1, &tls_ciphers },
1673 { "clientcert", TLS_CCERT, NULL }, 1679 { "clientcert", TLS_CCERT, NULL },
1674 { "muststaple", TLS_MUSTSTAPLE, NULL }, 1680 { "muststaple", TLS_MUSTSTAPLE, NULL },
1675 { "noverify", TLS_NOVERIFY, NULL },
1676 { "noname", TLS_NONAME, NULL }, 1681 { "noname", TLS_NONAME, NULL },
1682 { "noverify", TLS_NOVERIFY, NULL },
1677 { "protocols", -1, &tls_protocols }, 1683 { "protocols", -1, &tls_protocols },
1678 { NULL, -1, NULL }, 1684 { NULL, -1, NULL },
1679 }; 1685 };
@@ -1692,6 +1698,8 @@ process_tls_opt(char *s, int *flags)
1692 errx(1, "invalid tls value `%s'", s); 1698 errx(1, "invalid tls value `%s'", s);
1693 *t->value = v; 1699 *t->value = v;
1694 } else { 1700 } else {
1701 if (v != NULL)
1702 errx(1, "invalid tls value `%s'", s);
1695 *flags |= t->flag; 1703 *flags |= t->flag;
1696 } 1704 }
1697 return 1; 1705 return 1;
@@ -1718,7 +1726,7 @@ void
1718report_tls(struct tls *tls_ctx, char *host) 1726report_tls(struct tls *tls_ctx, char *host)
1719{ 1727{
1720 time_t t; 1728 time_t t;
1721 const char *ocsp_url; 1729 const char *alpn_proto, *ocsp_url;
1722 1730
1723 fprintf(stderr, "TLS handshake negotiated %s/%s with host %s\n", 1731 fprintf(stderr, "TLS handshake negotiated %s/%s with host %s\n",
1724 tls_conn_version(tls_ctx), tls_conn_cipher(tls_ctx), host); 1732 tls_conn_version(tls_ctx), tls_conn_cipher(tls_ctx), host);
@@ -1770,6 +1778,8 @@ report_tls(struct tls *tls_ctx, char *host)
1770 tls_peer_ocsp_result(tls_ctx)); 1778 tls_peer_ocsp_result(tls_ctx));
1771 break; 1779 break;
1772 } 1780 }
1781 if ((alpn_proto = tls_conn_alpn_selected(tls_ctx)) != NULL)
1782 fprintf(stderr, "Application Layer Protocol: %s\n", alpn_proto);
1773} 1783}
1774 1784
1775void 1785void
@@ -1842,7 +1852,7 @@ help(void)
1842 \t-v Verbose\n\ 1852 \t-v Verbose\n\
1843 \t-W recvlimit Terminate after receiving a number of packets\n\ 1853 \t-W recvlimit Terminate after receiving a number of packets\n\
1844 \t-w timeout Timeout for connects and final net reads\n\ 1854 \t-w timeout Timeout for connects and final net reads\n\
1845 \t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\ 1855 \t-X proto Proxy protocol: \"4\", \"4A\", \"5\" (SOCKS) or \"connect\"\n\
1846 \t-x addr[:port]\tSpecify proxy address and port\n\ 1856 \t-x addr[:port]\tSpecify proxy address and port\n\
1847 \t-Z Peer certificate file\n\ 1857 \t-Z Peer certificate file\n\
1848 \t-z Zero-I/O mode [used for scanning]\n\ 1858 \t-z Zero-I/O mode [used for scanning]\n\
diff --git a/src/usr.bin/nc/socks.c b/src/usr.bin/nc/socks.c
index 7c7448c9c5..1f1fb96e2a 100644
--- a/src/usr.bin/nc/socks.c
+++ b/src/usr.bin/nc/socks.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: socks.c,v 1.31 2022/06/08 20:20:26 djm Exp $ */ 1/* $OpenBSD: socks.c,v 1.34 2025/05/22 06:40:26 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. 4 * Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
@@ -293,19 +293,33 @@ socks_connect(const char *host, const char *port,
293 default: 293 default:
294 errx(1, "connection failed, unsupported address type"); 294 errx(1, "connection failed, unsupported address type");
295 } 295 }
296 } else if (socksv == 4) { 296 } else if (socksv == 4 || socksv == 44) {
297 /* This will exit on lookup failure */ 297 if (socksv == 4) {
298 decode_addrport(host, port, (struct sockaddr *)&addr, 298 /* This will exit on lookup failure */
299 sizeof(addr), 1, 0); 299 decode_addrport(host, port, (struct sockaddr *)&addr,
300 sizeof(addr), 1, 0);
301 }
300 302
301 /* Version 4 */ 303 /* Version 4 */
302 buf[0] = SOCKS_V4; 304 buf[0] = SOCKS_V4;
303 buf[1] = SOCKS_CONNECT; /* connect */ 305 buf[1] = SOCKS_CONNECT; /* connect */
304 memcpy(buf + 2, &in4->sin_port, sizeof in4->sin_port); 306 memcpy(buf + 2, &in4->sin_port, sizeof in4->sin_port);
305 memcpy(buf + 4, &in4->sin_addr, sizeof in4->sin_addr); 307 if (socksv == 4) {
308 memcpy(buf + 4, &in4->sin_addr, sizeof in4->sin_addr);
309 } else {
310 /* SOCKS4A uses addr of 0.0.0.x, and hostname later */
311 buf[4] = buf[5] = buf[6] = 0;
312 buf[7] = 1;
313 }
306 buf[8] = 0; /* empty username */ 314 buf[8] = 0; /* empty username */
307 wlen = 9; 315 wlen = 9;
308 316 if (socksv == 44) {
317 /* SOCKS4A has nul-terminated hostname after user */
318 if (strlcpy(buf + 9, host,
319 sizeof(buf) - 9) >= sizeof(buf) - 9)
320 errx(1, "hostname too big");
321 wlen = 9 + strlen(host) + 1;
322 }
309 cnt = atomicio(vwrite, proxyfd, buf, wlen); 323 cnt = atomicio(vwrite, proxyfd, buf, wlen);
310 if (cnt != wlen) 324 if (cnt != wlen)
311 err(1, "write failed (%zu/%zu)", cnt, wlen); 325 err(1, "write failed (%zu/%zu)", cnt, wlen);
@@ -373,16 +387,16 @@ socks_connect(const char *host, const char *port,
373 /* Read status reply */ 387 /* Read status reply */
374 proxy_read_line(proxyfd, buf, sizeof(buf)); 388 proxy_read_line(proxyfd, buf, sizeof(buf));
375 if (proxyuser != NULL && 389 if (proxyuser != NULL &&
376 (strncmp(buf, "HTTP/1.0 407 ", 12) == 0 || 390 (strncmp(buf, "HTTP/1.0 407 ", 13) == 0 ||
377 strncmp(buf, "HTTP/1.1 407 ", 12) == 0)) { 391 strncmp(buf, "HTTP/1.1 407 ", 13) == 0)) {
378 if (authretry > 1) { 392 if (authretry > 1) {
379 fprintf(stderr, "Proxy authentication " 393 fprintf(stderr, "Proxy authentication "
380 "failed\n"); 394 "failed\n");
381 } 395 }
382 close(proxyfd); 396 close(proxyfd);
383 goto again; 397 goto again;
384 } else if (strncmp(buf, "HTTP/1.0 200 ", 12) != 0 && 398 } else if (strncmp(buf, "HTTP/1.0 200 ", 13) != 0 &&
385 strncmp(buf, "HTTP/1.1 200 ", 12) != 0) 399 strncmp(buf, "HTTP/1.1 200 ", 13) != 0)
386 errx(1, "Proxy error: \"%s\"", buf); 400 errx(1, "Proxy error: \"%s\"", buf);
387 401
388 /* Headers continue until we hit an empty line */ 402 /* Headers continue until we hit an empty line */
diff --git a/src/usr.bin/openssl/certhash.c b/src/usr.bin/openssl/certhash.c
index 5ee29b8d01..1ee1165516 100644
--- a/src/usr.bin/openssl/certhash.c
+++ b/src/usr.bin/openssl/certhash.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: certhash.c,v 1.21 2023/03/06 14:32:05 tb Exp $ */ 1/* $OpenBSD: certhash.c,v 1.22 2025/07/27 14:46:20 joshua Exp $ */
2/* 2/*
3 * Copyright (c) 2014, 2015 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014, 2015 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -297,11 +297,10 @@ hashinfo_from_linkname(const char *linkname, const char *target)
297} 297}
298 298
299static struct hashinfo * 299static struct hashinfo *
300certhash_cert(BIO *bio, const char *filename) 300certhash_cert(BIO *bio, const char *filename, const EVP_MD *digest)
301{ 301{
302 unsigned char fingerprint[EVP_MAX_MD_SIZE]; 302 unsigned char fingerprint[EVP_MAX_MD_SIZE];
303 struct hashinfo *hi = NULL; 303 struct hashinfo *hi = NULL;
304 const EVP_MD *digest;
305 X509 *cert = NULL; 304 X509 *cert = NULL;
306 unsigned long hash; 305 unsigned long hash;
307 unsigned int len; 306 unsigned int len;
@@ -311,7 +310,6 @@ certhash_cert(BIO *bio, const char *filename)
311 310
312 hash = X509_subject_name_hash(cert); 311 hash = X509_subject_name_hash(cert);
313 312
314 digest = EVP_sha256();
315 if (X509_digest(cert, digest, fingerprint, &len) != 1) { 313 if (X509_digest(cert, digest, fingerprint, &len) != 1) {
316 fprintf(stderr, "out of memory\n"); 314 fprintf(stderr, "out of memory\n");
317 goto err; 315 goto err;
@@ -326,11 +324,10 @@ certhash_cert(BIO *bio, const char *filename)
326} 324}
327 325
328static struct hashinfo * 326static struct hashinfo *
329certhash_crl(BIO *bio, const char *filename) 327certhash_crl(BIO *bio, const char *filename, const EVP_MD *digest)
330{ 328{
331 unsigned char fingerprint[EVP_MAX_MD_SIZE]; 329 unsigned char fingerprint[EVP_MAX_MD_SIZE];
332 struct hashinfo *hi = NULL; 330 struct hashinfo *hi = NULL;
333 const EVP_MD *digest;
334 X509_CRL *crl = NULL; 331 X509_CRL *crl = NULL;
335 unsigned long hash; 332 unsigned long hash;
336 unsigned int len; 333 unsigned int len;
@@ -340,7 +337,6 @@ certhash_crl(BIO *bio, const char *filename)
340 337
341 hash = X509_NAME_hash(X509_CRL_get_issuer(crl)); 338 hash = X509_NAME_hash(X509_CRL_get_issuer(crl));
342 339
343 digest = EVP_sha256();
344 if (X509_CRL_digest(crl, digest, fingerprint, &len) != 1) { 340 if (X509_CRL_digest(crl, digest, fingerprint, &len) != 1) {
345 fprintf(stderr, "out of memory\n"); 341 fprintf(stderr, "out of memory\n");
346 goto err; 342 goto err;
@@ -509,7 +505,7 @@ certhash_link(struct dirent *dep, struct hashinfo **links)
509 505
510static int 506static int
511certhash_file(struct dirent *dep, struct hashinfo **certs, 507certhash_file(struct dirent *dep, struct hashinfo **certs,
512 struct hashinfo **crls) 508 struct hashinfo **crls, const EVP_MD *digest)
513{ 509{
514 struct hashinfo *hi = NULL; 510 struct hashinfo *hi = NULL;
515 int has_cert, has_crl; 511 int has_cert, has_crl;
@@ -529,7 +525,7 @@ certhash_file(struct dirent *dep, struct hashinfo **certs,
529 goto err; 525 goto err;
530 } 526 }
531 527
532 if ((hi = certhash_cert(bio, dep->d_name)) != NULL) { 528 if ((hi = certhash_cert(bio, dep->d_name, digest)) != NULL) {
533 has_cert = 1; 529 has_cert = 1;
534 *certs = hashinfo_chain(*certs, hi); 530 *certs = hashinfo_chain(*certs, hi);
535 } 531 }
@@ -539,7 +535,7 @@ certhash_file(struct dirent *dep, struct hashinfo **certs,
539 goto err; 535 goto err;
540 } 536 }
541 537
542 if ((hi = certhash_crl(bio, dep->d_name)) != NULL) { 538 if ((hi = certhash_crl(bio, dep->d_name, digest)) != NULL) {
543 has_crl = hi->is_crl = 1; 539 has_crl = hi->is_crl = 1;
544 *crls = hashinfo_chain(*crls, hi); 540 *crls = hashinfo_chain(*crls, hi);
545 } 541 }
@@ -557,7 +553,7 @@ certhash_file(struct dirent *dep, struct hashinfo **certs,
557} 553}
558 554
559static int 555static int
560certhash_directory(const char *path) 556certhash_directory(const char *path, const EVP_MD *digest)
561{ 557{
562 struct hashinfo *links = NULL, *certs = NULL, *crls = NULL, *link; 558 struct hashinfo *links = NULL, *certs = NULL, *crls = NULL, *link;
563 int ret = 0; 559 int ret = 0;
@@ -579,7 +575,7 @@ certhash_directory(const char *path)
579 goto err; 575 goto err;
580 } 576 }
581 if (filename_is_pem(dep->d_name)) { 577 if (filename_is_pem(dep->d_name)) {
582 if (certhash_file(dep, &certs, &crls) == -1) 578 if (certhash_file(dep, &certs, &crls, digest) == -1)
583 goto err; 579 goto err;
584 } 580 }
585 } 581 }
@@ -678,7 +674,7 @@ certhash_main(int argc, char **argv)
678 ret = 1; 674 ret = 1;
679 continue; 675 continue;
680 } 676 }
681 ret |= certhash_directory(argv[i]); 677 ret |= certhash_directory(argv[i], EVP_sha256());
682 if (fchdir(cwdfd) == -1) { 678 if (fchdir(cwdfd) == -1) {
683 perror("failed to restore current directory"); 679 perror("failed to restore current directory");
684 ret = 1; 680 ret = 1;
diff --git a/src/usr.bin/openssl/cms.c b/src/usr.bin/openssl/cms.c
index 7420d0ab8c..458ddb0e3b 100644
--- a/src/usr.bin/openssl/cms.c
+++ b/src/usr.bin/openssl/cms.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms.c,v 1.36 2024/08/12 15:34:58 job Exp $ */ 1/* $OpenBSD: cms.c,v 1.38 2025/06/07 08:24:15 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -193,15 +193,33 @@ get_cipher_by_name(char *name)
193static int 193static int
194cms_opt_cipher(int argc, char **argv, int *argsused) 194cms_opt_cipher(int argc, char **argv, int *argsused)
195{ 195{
196 const EVP_CIPHER *cipher;
196 char *name = argv[0]; 197 char *name = argv[0];
197 198
198 if (*name++ != '-') 199 if (*name++ != '-')
199 return (1); 200 return (1);
200 201
201 if ((cfg.cipher = get_cipher_by_name(name)) == NULL) 202 if ((cipher = get_cipher_by_name(name)) == NULL)
202 if ((cfg.cipher = EVP_get_cipherbyname(name)) == NULL) 203 if ((cipher = EVP_get_cipherbyname(name)) == NULL)
203 return (1); 204 return (1);
204 205
206 /*
207 * XXX - this should really be done in CMS_{encrypt,decrypt}() until
208 * we have proper support for AuthEnvelopedData (RFC 5084), but this
209 * is good enough for now to avoid outputting garbage with this rusty
210 * swiss army knife.
211 */
212 if ((EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) != 0) {
213 BIO_printf(bio_err, "AuthEnvelopedData is not supported\n");
214 return (1);
215 }
216 if (EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE) {
217 BIO_printf(bio_err, "XTS mode not supported\n");
218 return (1);
219 }
220
221 cfg.cipher = cipher;
222
205 *argsused = 1; 223 *argsused = 1;
206 return (0); 224 return (0);
207} 225}
@@ -475,7 +493,7 @@ static const struct option cms_options[] = {
475 }, 493 },
476 { 494 {
477 .name = "aes256", 495 .name = "aes256",
478 .desc = "Encrypt PEM output with CBC AES", 496 .desc = "Encrypt PEM output with CBC AES (default)",
479 .type = OPTION_ARGV_FUNC, 497 .type = OPTION_ARGV_FUNC,
480 .opt.argvfunc = cms_opt_cipher, 498 .opt.argvfunc = cms_opt_cipher,
481 }, 499 },
@@ -509,7 +527,7 @@ static const struct option cms_options[] = {
509 }, 527 },
510 { 528 {
511 .name = "des3", 529 .name = "des3",
512 .desc = "Encrypt with triple DES (default)", 530 .desc = "Encrypt with triple DES",
513 .type = OPTION_ARGV_FUNC, 531 .type = OPTION_ARGV_FUNC,
514 .opt.argvfunc = cms_opt_cipher, 532 .opt.argvfunc = cms_opt_cipher,
515 }, 533 },
@@ -1291,14 +1309,8 @@ cms_main(int argc, char **argv)
1291 } 1309 }
1292 1310
1293 if (cfg.operation == SMIME_ENCRYPT) { 1311 if (cfg.operation == SMIME_ENCRYPT) {
1294 if (cfg.cipher == NULL) { 1312 if (cfg.cipher == NULL)
1295#ifndef OPENSSL_NO_DES 1313 cfg.cipher = EVP_aes_256_cbc();
1296 cfg.cipher = EVP_des_ede3_cbc();
1297#else
1298 BIO_printf(bio_err, "No cipher selected\n");
1299 goto end;
1300#endif
1301 }
1302 if (cfg.secret_key != NULL && 1314 if (cfg.secret_key != NULL &&
1303 cfg.secret_keyid == NULL) { 1315 cfg.secret_keyid == NULL) {
1304 BIO_printf(bio_err, "No secret key id\n"); 1316 BIO_printf(bio_err, "No secret key id\n");
diff --git a/src/usr.bin/openssl/gendsa.c b/src/usr.bin/openssl/gendsa.c
index 00635c4551..69a7994da7 100644
--- a/src/usr.bin/openssl/gendsa.c
+++ b/src/usr.bin/openssl/gendsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gendsa.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ 1/* $OpenBSD: gendsa.c,v 1.18 2025/06/07 08:33:58 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -80,7 +80,8 @@ static struct {
80 char *passargout; 80 char *passargout;
81} cfg; 81} cfg;
82 82
83static const EVP_CIPHER *get_cipher_by_name(char *name) 83static const EVP_CIPHER *
84get_cipher_by_name(char *name)
84{ 85{
85 if (name == NULL || strcmp(name, "") == 0) 86 if (name == NULL || strcmp(name, "") == 0)
86 return (NULL); 87 return (NULL);
diff --git a/src/usr.bin/openssl/genrsa.c b/src/usr.bin/openssl/genrsa.c
index 0b5323fa5f..647780d8fa 100644
--- a/src/usr.bin/openssl/genrsa.c
+++ b/src/usr.bin/openssl/genrsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: genrsa.c,v 1.22 2023/03/06 14:32:06 tb Exp $ */ 1/* $OpenBSD: genrsa.c,v 1.23 2025/06/07 08:33:58 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -108,7 +108,8 @@ set_public_exponent(int argc, char **argv, int *argsused)
108 return (0); 108 return (0);
109} 109}
110 110
111static const EVP_CIPHER *get_cipher_by_name(char *name) 111static const EVP_CIPHER *
112get_cipher_by_name(char *name)
112{ 113{
113 if (name == NULL || strcmp(name, "") == 0) 114 if (name == NULL || strcmp(name, "") == 0)
114 return (NULL); 115 return (NULL);
diff --git a/src/usr.bin/openssl/ocsp.c b/src/usr.bin/openssl/ocsp.c
index d35940a7ae..01d28aa1f0 100644
--- a/src/usr.bin/openssl/ocsp.c
+++ b/src/usr.bin/openssl/ocsp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp.c,v 1.26 2024/08/31 18:39:25 tb Exp $ */ 1/* $OpenBSD: ocsp.c,v 1.27 2025/05/09 12:50:59 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -194,18 +194,18 @@ x509v3_add_value(const char *name, const char *value,
194 int ret = 0; 194 int ret = 0;
195 195
196 if ((conf_value = calloc(1, sizeof(*conf_value))) == NULL) { 196 if ((conf_value = calloc(1, sizeof(*conf_value))) == NULL) {
197 X509V3error(ERR_R_MALLOC_FAILURE); 197 perror("calloc");
198 goto err; 198 goto err;
199 } 199 }
200 if (name != NULL) { 200 if (name != NULL) {
201 if ((conf_value->name = strdup(name)) == NULL) { 201 if ((conf_value->name = strdup(name)) == NULL) {
202 X509V3error(ERR_R_MALLOC_FAILURE); 202 perror("strdup");
203 goto err; 203 goto err;
204 } 204 }
205 } 205 }
206 if (value != NULL) { 206 if (value != NULL) {
207 if ((conf_value->value = strdup(value)) == NULL) { 207 if ((conf_value->value = strdup(value)) == NULL) {
208 X509V3error(ERR_R_MALLOC_FAILURE); 208 perror("strdup");
209 goto err; 209 goto err;
210 } 210 }
211 } 211 }
@@ -213,12 +213,12 @@ x509v3_add_value(const char *name, const char *value,
213 if ((extlist = *out_extlist) == NULL) 213 if ((extlist = *out_extlist) == NULL)
214 extlist = sk_CONF_VALUE_new_null(); 214 extlist = sk_CONF_VALUE_new_null();
215 if (extlist == NULL) { 215 if (extlist == NULL) {
216 X509V3error(ERR_R_MALLOC_FAILURE); 216 perror("sk_CONF_VALUE_new_null");
217 goto err; 217 goto err;
218 } 218 }
219 219
220 if (!sk_CONF_VALUE_push(extlist, conf_value)) { 220 if (!sk_CONF_VALUE_push(extlist, conf_value)) {
221 X509V3error(ERR_R_MALLOC_FAILURE); 221 perror("sk_CONF_VALUE_push");
222 goto err; 222 goto err;
223 } 223 }
224 conf_value = NULL; 224 conf_value = NULL;
diff --git a/src/usr.bin/openssl/openssl.1 b/src/usr.bin/openssl/openssl.1
index d27b504ce3..40defdc38b 100644
--- a/src/usr.bin/openssl/openssl.1
+++ b/src/usr.bin/openssl/openssl.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: openssl.1,v 1.164 2025/04/19 17:20:24 kn Exp $ 1.\" $OpenBSD: openssl.1,v 1.167 2025/06/07 08:29:20 tb Exp $
2.\" ==================================================================== 2.\" ====================================================================
3.\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3.\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4.\" 4.\"
@@ -110,7 +110,7 @@
110.\" copied and put under another distribution licence 110.\" copied and put under another distribution licence
111.\" [including the GNU Public Licence.] 111.\" [including the GNU Public Licence.]
112.\" 112.\"
113.Dd $Mdocdate: April 19 2025 $ 113.Dd $Mdocdate: June 7 2025 $
114.Dt OPENSSL 1 114.Dt OPENSSL 1
115.Os 115.Os
116.Sh NAME 116.Sh NAME
@@ -1091,7 +1091,7 @@ The encryption algorithm to use.
1091128-, 192-, or 256-bit AES, 128-, 192-, or 256-bit CAMELLIA, 1091128-, 192-, or 256-bit AES, 128-, 192-, or 256-bit CAMELLIA,
1092DES (56 bits), triple DES (168 bits), 1092DES (56 bits), triple DES (168 bits),
1093or 40-, 64-, or 128-bit RC2, respectively; 1093or 40-, 64-, or 128-bit RC2, respectively;
1094if not specified, triple DES is 1094if not specified, 256-bit AES is
1095used. 1095used.
1096Only used with 1096Only used with
1097.Fl encrypt 1097.Fl encrypt
@@ -2973,9 +2973,6 @@ command processes private keys
2973(both encrypted and unencrypted) 2973(both encrypted and unencrypted)
2974in PKCS#8 format 2974in PKCS#8 format
2975with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms. 2975with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms.
2976The default encryption is only 56 bits;
2977keys encrypted using PKCS#5 v2.0 algorithms and high iteration counts
2978are more secure.
2979.Pp 2976.Pp
2980The options are as follows: 2977The options are as follows:
2981.Bl -tag -width Ds 2978.Bl -tag -width Ds
@@ -3021,16 +3018,12 @@ which allow strong encryption algorithms like triple DES or 128-bit RC2.
3021.El 3018.El
3022.It Fl v2 Ar alg 3019.It Fl v2 Ar alg
3023Use PKCS#5 v2.0 algorithms. 3020Use PKCS#5 v2.0 algorithms.
3024Supports algorithms such as 168-bit triple DES or 128-bit RC2, 3021These are block ciphers used in CBC mode.
3025however not many implementations support PKCS#5 v2.0 yet 3022The default is AES-256-CBC.
3026(if using private keys with 3023With the exception of AES, the choices available in RFC 8018
3027.Nm openssl 3024are considered decrepit.
3028this doesn't matter). 3025They can be enabled with des, des3, and rc2
3029.Pp 3026(rc5 is no longer supported).
3030.Ar alg
3031is the encryption algorithm to use;
3032valid values include des, des3, and rc2.
3033It is recommended that des3 is used.
3034.El 3027.El
3035.Tg pkcs12 3028.Tg pkcs12
3036.Sh PKCS12 3029.Sh PKCS12
@@ -5105,7 +5098,7 @@ The remaining options are as follows:
5105The encryption algorithm to use. 5098The encryption algorithm to use.
5106128-, 192-, or 256-bit AES, DES (56 bits), triple DES (168 bits), 5099128-, 192-, or 256-bit AES, DES (56 bits), triple DES (168 bits),
5107or 40-, 64-, or 128-bit RC2, respectively; 5100or 40-, 64-, or 128-bit RC2, respectively;
5108if not specified, 40-bit RC2 is 5101if not specified, 256-bit AES is
5109used. 5102used.
5110Only used with 5103Only used with
5111.Fl encrypt . 5104.Fl encrypt .
diff --git a/src/usr.bin/openssl/openssl.c b/src/usr.bin/openssl/openssl.c
index 75a0e4d266..a1ef139009 100644
--- a/src/usr.bin/openssl/openssl.c
+++ b/src/usr.bin/openssl/openssl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: openssl.c,v 1.39 2025/01/02 13:10:03 tb Exp $ */ 1/* $OpenBSD: openssl.c,v 1.40 2025/05/25 04:54:41 joshua Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -235,9 +235,6 @@ FUNCTION functions[] = {
235 { FUNC_TYPE_MD, "sm3", dgst_main }, 235 { FUNC_TYPE_MD, "sm3", dgst_main },
236 { FUNC_TYPE_MD, "sm3WithRSAEncryption", dgst_main }, 236 { FUNC_TYPE_MD, "sm3WithRSAEncryption", dgst_main },
237#endif 237#endif
238#ifndef OPENSSL_NO_WHIRLPOOL
239 { FUNC_TYPE_MD, "whirlpool", dgst_main },
240#endif
241 238
242 /* Ciphers. */ 239 /* Ciphers. */
243 { FUNC_TYPE_CIPHER, "base64", enc_main }, 240 { FUNC_TYPE_CIPHER, "base64", enc_main },
diff --git a/src/usr.bin/openssl/pkcs12.c b/src/usr.bin/openssl/pkcs12.c
index 1407a96e03..efd6d59163 100644
--- a/src/usr.bin/openssl/pkcs12.c
+++ b/src/usr.bin/openssl/pkcs12.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pkcs12.c,v 1.29 2024/12/26 14:10:48 tb Exp $ */ 1/* $OpenBSD: pkcs12.c,v 1.30 2025/06/07 08:33:58 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -152,7 +152,8 @@ pkcs12_opt_passarg(char *arg)
152 return (0); 152 return (0);
153} 153}
154 154
155static const EVP_CIPHER *get_cipher_by_name(char *name) 155static const EVP_CIPHER *
156get_cipher_by_name(char *name)
156{ 157{
157 if (name == NULL || strcmp(name, "") == 0) 158 if (name == NULL || strcmp(name, "") == 0)
158 return (NULL); 159 return (NULL);
diff --git a/src/usr.bin/openssl/pkcs8.c b/src/usr.bin/openssl/pkcs8.c
index 10fad7aed1..5d7c52f865 100644
--- a/src/usr.bin/openssl/pkcs8.c
+++ b/src/usr.bin/openssl/pkcs8.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pkcs8.c,v 1.18 2025/01/02 12:31:44 tb Exp $ */ 1/* $OpenBSD: pkcs8.c,v 1.19 2025/05/24 02:35:25 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999-2004. 3 * project 1999-2004.
4 */ 4 */
@@ -224,8 +224,8 @@ pkcs8_main(int argc, char **argv)
224 BIO_printf(bio_err, "Error getting passwords\n"); 224 BIO_printf(bio_err, "Error getting passwords\n");
225 goto end; 225 goto end;
226 } 226 }
227 if ((cfg.pbe_nid == -1) && !cfg.cipher) 227 if (cfg.pbe_nid == -1 && cfg.cipher == NULL)
228 cfg.pbe_nid = NID_pbeWithMD5AndDES_CBC; 228 cfg.cipher = EVP_aes_256_cbc();
229 229
230 if (cfg.infile) { 230 if (cfg.infile) {
231 if (!(in = BIO_new_file(cfg.infile, "rb"))) { 231 if (!(in = BIO_new_file(cfg.infile, "rb"))) {
diff --git a/src/usr.bin/openssl/smime.c b/src/usr.bin/openssl/smime.c
index 46bfa08679..f9d7049ff9 100644
--- a/src/usr.bin/openssl/smime.c
+++ b/src/usr.bin/openssl/smime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: smime.c,v 1.20 2023/04/14 15:27:13 tb Exp $ */ 1/* $OpenBSD: smime.c,v 1.21 2025/06/07 08:28:49 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -271,7 +271,7 @@ static const struct option smime_options[] = {
271 }, 271 },
272 { 272 {
273 .name = "aes256", 273 .name = "aes256",
274 .desc = "Encrypt PEM output with CBC AES", 274 .desc = "Encrypt PEM output with CBC AES (default)",
275 .type = OPTION_ARGV_FUNC, 275 .type = OPTION_ARGV_FUNC,
276 .opt.argvfunc = smime_opt_cipher, 276 .opt.argvfunc = smime_opt_cipher,
277 }, 277 },
@@ -313,7 +313,7 @@ static const struct option smime_options[] = {
313#ifndef OPENSSL_NO_RC2 313#ifndef OPENSSL_NO_RC2
314 { 314 {
315 .name = "rc2-40", 315 .name = "rc2-40",
316 .desc = "Encrypt with RC2-40 (default)", 316 .desc = "Encrypt with RC2-40",
317 .type = OPTION_ARGV_FUNC, 317 .type = OPTION_ARGV_FUNC,
318 .opt.argvfunc = smime_opt_cipher, 318 .opt.argvfunc = smime_opt_cipher,
319 }, 319 },
@@ -825,14 +825,8 @@ smime_main(int argc, char **argv)
825 } 825 }
826 826
827 if (cfg.operation == SMIME_ENCRYPT) { 827 if (cfg.operation == SMIME_ENCRYPT) {
828 if (cfg.cipher == NULL) { 828 if (cfg.cipher == NULL)
829#ifndef OPENSSL_NO_RC2 829 cfg.cipher = EVP_aes_256_cbc();
830 cfg.cipher = EVP_rc2_40_cbc();
831#else
832 BIO_printf(bio_err, "No cipher selected\n");
833 goto end;
834#endif
835 }
836 if ((encerts = sk_X509_new_null()) == NULL) 830 if ((encerts = sk_X509_new_null()) == NULL)
837 goto end; 831 goto end;
838 while (*args != NULL) { 832 while (*args != NULL) {
diff --git a/src/usr.bin/openssl/speed.c b/src/usr.bin/openssl/speed.c
index 9d03c6516e..3e9b4faa9d 100644
--- a/src/usr.bin/openssl/speed.c
+++ b/src/usr.bin/openssl/speed.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: speed.c,v 1.41 2025/01/02 13:37:43 tb Exp $ */ 1/* $OpenBSD: speed.c,v 1.46 2025/05/25 05:05:30 joshua Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -142,9 +142,6 @@
142#ifndef OPENSSL_NO_SHA 142#ifndef OPENSSL_NO_SHA
143#include <openssl/sha.h> 143#include <openssl/sha.h>
144#endif 144#endif
145#ifndef OPENSSL_NO_WHIRLPOOL
146#include <openssl/whrlpool.h>
147#endif
148 145
149#define BUFSIZE (1024*8+64) 146#define BUFSIZE (1024*8+64)
150volatile sig_atomic_t run; 147volatile sig_atomic_t run;
@@ -152,7 +149,6 @@ volatile sig_atomic_t run;
152static int mr = 0; 149static int mr = 0;
153static int usertime = 1; 150static int usertime = 1;
154 151
155static double Time_F(int s);
156static void print_message(const char *s, long num, int length); 152static void print_message(const char *s, long num, int length);
157static void 153static void
158pkey_print_message(const char *str, const char *str2, 154pkey_print_message(const char *str, const char *str2,
@@ -160,7 +156,7 @@ pkey_print_message(const char *str, const char *str2,
160static void print_result(int alg, int run_no, int count, double time_used); 156static void print_result(int alg, int run_no, int count, double time_used);
161static int do_multi(int multi); 157static int do_multi(int multi);
162 158
163#define ALGOR_NUM 32 159#define ALGOR_NUM 31
164#define SIZE_NUM 5 160#define SIZE_NUM 5
165#define RSA_NUM 4 161#define RSA_NUM 4
166#define DSA_NUM 3 162#define DSA_NUM 3
@@ -174,7 +170,7 @@ static const char *names[ALGOR_NUM] = {
174 "rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc", 170 "rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc",
175 "aes-128 cbc", "aes-192 cbc", "aes-256 cbc", 171 "aes-128 cbc", "aes-192 cbc", "aes-256 cbc",
176 "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc", 172 "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc",
177 "evp", "sha256", "sha512", "whirlpool", 173 "evp", "sha256", "sha512",
178 "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash", 174 "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash",
179 "aes-128 gcm", "aes-256 gcm", "chacha20 poly1305", 175 "aes-128 gcm", "aes-256 gcm", "chacha20 poly1305",
180}; 176};
@@ -895,6 +891,22 @@ static const unsigned char test4096[] = {
895 0xaf, 0xf8, 0x2a, 0x91, 0x9d, 0x50, 0x44, 0x21, 0x17, 891 0xaf, 0xf8, 0x2a, 0x91, 0x9d, 0x50, 0x44, 0x21, 0x17,
896}; 892};
897 893
894static const unsigned char key16[] = {
895 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
896 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
897};
898static const unsigned char key24[] = {
899 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
900 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
901 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
902};
903static const unsigned char key32[] = {
904 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
905 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
906 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
907 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56,
908};
909
898static void 910static void
899sig_done(int sig) 911sig_done(int sig)
900{ 912{
@@ -904,16 +916,14 @@ sig_done(int sig)
904#define START TM_RESET 916#define START TM_RESET
905#define STOP TM_GET 917#define STOP TM_GET
906 918
907
908static double 919static double
909Time_F(int s) 920time_f(int s)
910{ 921{
911 if (usertime) 922 if (usertime)
912 return app_timer_user(s); 923 return app_timer_user(s);
913 else
914 return app_timer_real(s);
915}
916 924
925 return app_timer_real(s);
926}
917 927
918static const int KDF1_SHA1_len = 20; 928static const int KDF1_SHA1_len = 20;
919static void * 929static void *
@@ -942,28 +952,7 @@ speed_main(int argc, char **argv)
942 long rsa_count; 952 long rsa_count;
943 unsigned rsa_num; 953 unsigned rsa_num;
944 unsigned char md[EVP_MAX_MD_SIZE]; 954 unsigned char md[EVP_MAX_MD_SIZE];
945#ifndef OPENSSL_NO_MD4 955
946 unsigned char md4[MD4_DIGEST_LENGTH];
947#endif
948#ifndef OPENSSL_NO_MD5
949 unsigned char md5[MD5_DIGEST_LENGTH];
950 unsigned char hmac[MD5_DIGEST_LENGTH];
951#endif
952#ifndef OPENSSL_NO_SHA
953 unsigned char sha[SHA_DIGEST_LENGTH];
954#ifndef OPENSSL_NO_SHA256
955 unsigned char sha256[SHA256_DIGEST_LENGTH];
956#endif
957#ifndef OPENSSL_NO_SHA512
958 unsigned char sha512[SHA512_DIGEST_LENGTH];
959#endif
960#endif
961#ifndef OPENSSL_NO_WHIRLPOOL
962 unsigned char whirlpool[WHIRLPOOL_DIGEST_LENGTH];
963#endif
964#ifndef OPENSSL_NO_RIPEMD
965 unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
966#endif
967#ifndef OPENSSL_NO_RC4 956#ifndef OPENSSL_NO_RC4
968 RC4_KEY rc4_ks; 957 RC4_KEY rc4_ks;
969#endif 958#endif
@@ -979,38 +968,8 @@ speed_main(int argc, char **argv)
979#ifndef OPENSSL_NO_CAST 968#ifndef OPENSSL_NO_CAST
980 CAST_KEY cast_ks; 969 CAST_KEY cast_ks;
981#endif 970#endif
982 static const unsigned char key16[16] =
983 {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
984 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12};
985#ifndef OPENSSL_NO_AES
986 static const unsigned char key24[24] =
987 {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
988 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
989 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
990 static const unsigned char key32[32] =
991 {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
992 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
993 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
994 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56};
995#endif
996#ifndef OPENSSL_NO_CAMELLIA
997 static const unsigned char ckey24[24] =
998 {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
999 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
1000 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
1001 static const unsigned char ckey32[32] =
1002 {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
1003 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
1004 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
1005 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56};
1006#endif
1007#ifndef OPENSSL_NO_AES
1008#define MAX_BLOCK_SIZE 128
1009#else
1010#define MAX_BLOCK_SIZE 64
1011#endif
1012 unsigned char DES_iv[8]; 971 unsigned char DES_iv[8];
1013 unsigned char iv[2 * MAX_BLOCK_SIZE / 8]; 972 unsigned char iv[2 * 16];
1014#ifndef OPENSSL_NO_DES 973#ifndef OPENSSL_NO_DES
1015 static DES_cblock key = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0}; 974 static DES_cblock key = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
1016 static DES_cblock key2 = {0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12}; 975 static DES_cblock key2 = {0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12};
@@ -1049,14 +1008,13 @@ speed_main(int argc, char **argv)
1049#define D_EVP 21 1008#define D_EVP 21
1050#define D_SHA256 22 1009#define D_SHA256 22
1051#define D_SHA512 23 1010#define D_SHA512 23
1052#define D_WHIRLPOOL 24 1011#define D_IGE_128_AES 24
1053#define D_IGE_128_AES 25 1012#define D_IGE_192_AES 25
1054#define D_IGE_192_AES 26 1013#define D_IGE_256_AES 26
1055#define D_IGE_256_AES 27 1014#define D_GHASH 27
1056#define D_GHASH 28 1015#define D_AES_128_GCM 28
1057#define D_AES_128_GCM 29 1016#define D_AES_256_GCM 29
1058#define D_AES_256_GCM 30 1017#define D_CHACHA20_POLY1305 30
1059#define D_CHACHA20_POLY1305 31
1060 double d = 0.0; 1018 double d = 0.0;
1061 long c[ALGOR_NUM][SIZE_NUM]; 1019 long c[ALGOR_NUM][SIZE_NUM];
1062#define R_DSA_512 0 1020#define R_DSA_512 0
@@ -1275,11 +1233,6 @@ speed_main(int argc, char **argv)
1275 else 1233 else
1276#endif 1234#endif
1277#endif 1235#endif
1278#ifndef OPENSSL_NO_WHIRLPOOL
1279 if (strcmp(*argv, "whirlpool") == 0)
1280 doit[D_WHIRLPOOL] = 1;
1281 else
1282#endif
1283#ifndef OPENSSL_NO_RIPEMD 1236#ifndef OPENSSL_NO_RIPEMD
1284 if (strcmp(*argv, "ripemd") == 0) 1237 if (strcmp(*argv, "ripemd") == 0)
1285 doit[D_RMD160] = 1; 1238 doit[D_RMD160] = 1;
@@ -1462,16 +1415,12 @@ speed_main(int argc, char **argv)
1462#ifndef OPENSSL_NO_SHA512 1415#ifndef OPENSSL_NO_SHA512
1463 BIO_printf(bio_err, "sha512 "); 1416 BIO_printf(bio_err, "sha512 ");
1464#endif 1417#endif
1465#ifndef OPENSSL_NO_WHIRLPOOL
1466 BIO_printf(bio_err, "whirlpool");
1467#endif
1468#ifndef OPENSSL_NO_RIPEMD160 1418#ifndef OPENSSL_NO_RIPEMD160
1469 BIO_printf(bio_err, "rmd160"); 1419 BIO_printf(bio_err, "rmd160");
1470#endif 1420#endif
1471#if !defined(OPENSSL_NO_MD2) || \ 1421#if !defined(OPENSSL_NO_MD2) || \
1472 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \ 1422 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
1473 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) || \ 1423 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
1474 !defined(OPENSSL_NO_WHIRLPOOL)
1475 BIO_printf(bio_err, "\n"); 1424 BIO_printf(bio_err, "\n");
1476#endif 1425#endif
1477 1426
@@ -1602,8 +1551,8 @@ speed_main(int argc, char **argv)
1602#endif 1551#endif
1603#ifndef OPENSSL_NO_CAMELLIA 1552#ifndef OPENSSL_NO_CAMELLIA
1604 Camellia_set_key(key16, 128, &camellia_ks1); 1553 Camellia_set_key(key16, 128, &camellia_ks1);
1605 Camellia_set_key(ckey24, 192, &camellia_ks2); 1554 Camellia_set_key(key24, 192, &camellia_ks2);
1606 Camellia_set_key(ckey32, 256, &camellia_ks3); 1555 Camellia_set_key(key32, 256, &camellia_ks3);
1607#endif 1556#endif
1608#ifndef OPENSSL_NO_IDEA 1557#ifndef OPENSSL_NO_IDEA
1609 idea_set_encrypt_key(key16, &idea_ks); 1558 idea_set_encrypt_key(key16, &idea_ks);
@@ -1634,10 +1583,10 @@ speed_main(int argc, char **argv)
1634 if (doit[D_MD4]) { 1583 if (doit[D_MD4]) {
1635 for (j = 0; j < SIZE_NUM; j++) { 1584 for (j = 0; j < SIZE_NUM; j++) {
1636 print_message(names[D_MD4], c[D_MD4][j], lengths[j]); 1585 print_message(names[D_MD4], c[D_MD4][j], lengths[j]);
1637 Time_F(START); 1586 time_f(START);
1638 for (count = 0, run = 1; COND(c[D_MD4][j]); count++) 1587 for (count = 0, run = 1; COND(c[D_MD4][j]); count++)
1639 EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md4[0]), NULL, EVP_md4(), NULL); 1588 EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_md4(), NULL);
1640 d = Time_F(STOP); 1589 d = time_f(STOP);
1641 print_result(D_MD4, j, count, d); 1590 print_result(D_MD4, j, count, d);
1642 } 1591 }
1643 } 1592 }
@@ -1647,10 +1596,10 @@ speed_main(int argc, char **argv)
1647 if (doit[D_MD5]) { 1596 if (doit[D_MD5]) {
1648 for (j = 0; j < SIZE_NUM; j++) { 1597 for (j = 0; j < SIZE_NUM; j++) {
1649 print_message(names[D_MD5], c[D_MD5][j], lengths[j]); 1598 print_message(names[D_MD5], c[D_MD5][j], lengths[j]);
1650 Time_F(START); 1599 time_f(START);
1651 for (count = 0, run = 1; COND(c[D_MD5][j]); count++) 1600 for (count = 0, run = 1; COND(c[D_MD5][j]); count++)
1652 EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md5[0]), NULL, EVP_get_digestbyname("md5"), NULL); 1601 EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_get_digestbyname("md5"), NULL);
1653 d = Time_F(STOP); 1602 d = time_f(STOP);
1654 print_result(D_MD5, j, count, d); 1603 print_result(D_MD5, j, count, d);
1655 } 1604 }
1656 } 1605 }
@@ -1670,7 +1619,7 @@ speed_main(int argc, char **argv)
1670 1619
1671 for (j = 0; j < SIZE_NUM; j++) { 1620 for (j = 0; j < SIZE_NUM; j++) {
1672 print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]); 1621 print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]);
1673 Time_F(START); 1622 time_f(START);
1674 for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) { 1623 for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) {
1675 if (!HMAC_Init_ex(hctx, NULL, 0, NULL, NULL)) { 1624 if (!HMAC_Init_ex(hctx, NULL, 0, NULL, NULL)) {
1676 HMAC_CTX_free(hctx); 1625 HMAC_CTX_free(hctx);
@@ -1680,12 +1629,12 @@ speed_main(int argc, char **argv)
1680 HMAC_CTX_free(hctx); 1629 HMAC_CTX_free(hctx);
1681 goto end; 1630 goto end;
1682 } 1631 }
1683 if (!HMAC_Final(hctx, &(hmac[0]), NULL)) { 1632 if (!HMAC_Final(hctx, md, NULL)) {
1684 HMAC_CTX_free(hctx); 1633 HMAC_CTX_free(hctx);
1685 goto end; 1634 goto end;
1686 } 1635 }
1687 } 1636 }
1688 d = Time_F(STOP); 1637 d = time_f(STOP);
1689 print_result(D_HMAC, j, count, d); 1638 print_result(D_HMAC, j, count, d);
1690 } 1639 }
1691 HMAC_CTX_free(hctx); 1640 HMAC_CTX_free(hctx);
@@ -1695,10 +1644,10 @@ speed_main(int argc, char **argv)
1695 if (doit[D_SHA1]) { 1644 if (doit[D_SHA1]) {
1696 for (j = 0; j < SIZE_NUM; j++) { 1645 for (j = 0; j < SIZE_NUM; j++) {
1697 print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]); 1646 print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]);
1698 Time_F(START); 1647 time_f(START);
1699 for (count = 0, run = 1; COND(c[D_SHA1][j]); count++) 1648 for (count = 0, run = 1; COND(c[D_SHA1][j]); count++)
1700 EVP_Digest(buf, (unsigned long) lengths[j], &(sha[0]), NULL, EVP_sha1(), NULL); 1649 EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_sha1(), NULL);
1701 d = Time_F(STOP); 1650 d = time_f(STOP);
1702 print_result(D_SHA1, j, count, d); 1651 print_result(D_SHA1, j, count, d);
1703 } 1652 }
1704 } 1653 }
@@ -1706,10 +1655,10 @@ speed_main(int argc, char **argv)
1706 if (doit[D_SHA256]) { 1655 if (doit[D_SHA256]) {
1707 for (j = 0; j < SIZE_NUM; j++) { 1656 for (j = 0; j < SIZE_NUM; j++) {
1708 print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]); 1657 print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]);
1709 Time_F(START); 1658 time_f(START);
1710 for (count = 0, run = 1; COND(c[D_SHA256][j]); count++) 1659 for (count = 0, run = 1; COND(c[D_SHA256][j]); count++)
1711 SHA256(buf, lengths[j], sha256); 1660 SHA256(buf, lengths[j], md);
1712 d = Time_F(STOP); 1661 d = time_f(STOP);
1713 print_result(D_SHA256, j, count, d); 1662 print_result(D_SHA256, j, count, d);
1714 } 1663 }
1715 } 1664 }
@@ -1719,37 +1668,24 @@ speed_main(int argc, char **argv)
1719 if (doit[D_SHA512]) { 1668 if (doit[D_SHA512]) {
1720 for (j = 0; j < SIZE_NUM; j++) { 1669 for (j = 0; j < SIZE_NUM; j++) {
1721 print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]); 1670 print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]);
1722 Time_F(START); 1671 time_f(START);
1723 for (count = 0, run = 1; COND(c[D_SHA512][j]); count++) 1672 for (count = 0, run = 1; COND(c[D_SHA512][j]); count++)
1724 SHA512(buf, lengths[j], sha512); 1673 SHA512(buf, lengths[j], md);
1725 d = Time_F(STOP); 1674 d = time_f(STOP);
1726 print_result(D_SHA512, j, count, d); 1675 print_result(D_SHA512, j, count, d);
1727 } 1676 }
1728 } 1677 }
1729#endif 1678#endif
1730#endif 1679#endif
1731 1680
1732#ifndef OPENSSL_NO_WHIRLPOOL
1733 if (doit[D_WHIRLPOOL]) {
1734 for (j = 0; j < SIZE_NUM; j++) {
1735 print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], lengths[j]);
1736 Time_F(START);
1737 for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); count++)
1738 WHIRLPOOL(buf, lengths[j], whirlpool);
1739 d = Time_F(STOP);
1740 print_result(D_WHIRLPOOL, j, count, d);
1741 }
1742 }
1743#endif
1744
1745#ifndef OPENSSL_NO_RIPEMD 1681#ifndef OPENSSL_NO_RIPEMD
1746 if (doit[D_RMD160]) { 1682 if (doit[D_RMD160]) {
1747 for (j = 0; j < SIZE_NUM; j++) { 1683 for (j = 0; j < SIZE_NUM; j++) {
1748 print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]); 1684 print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]);
1749 Time_F(START); 1685 time_f(START);
1750 for (count = 0, run = 1; COND(c[D_RMD160][j]); count++) 1686 for (count = 0, run = 1; COND(c[D_RMD160][j]); count++)
1751 EVP_Digest(buf, (unsigned long) lengths[j], &(rmd160[0]), NULL, EVP_ripemd160(), NULL); 1687 EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_ripemd160(), NULL);
1752 d = Time_F(STOP); 1688 d = time_f(STOP);
1753 print_result(D_RMD160, j, count, d); 1689 print_result(D_RMD160, j, count, d);
1754 } 1690 }
1755 } 1691 }
@@ -1758,11 +1694,11 @@ speed_main(int argc, char **argv)
1758 if (doit[D_RC4]) { 1694 if (doit[D_RC4]) {
1759 for (j = 0; j < SIZE_NUM; j++) { 1695 for (j = 0; j < SIZE_NUM; j++) {
1760 print_message(names[D_RC4], c[D_RC4][j], lengths[j]); 1696 print_message(names[D_RC4], c[D_RC4][j], lengths[j]);
1761 Time_F(START); 1697 time_f(START);
1762 for (count = 0, run = 1; COND(c[D_RC4][j]); count++) 1698 for (count = 0, run = 1; COND(c[D_RC4][j]); count++)
1763 RC4(&rc4_ks, (unsigned int) lengths[j], 1699 RC4(&rc4_ks, (unsigned int) lengths[j],
1764 buf, buf); 1700 buf, buf);
1765 d = Time_F(STOP); 1701 d = time_f(STOP);
1766 print_result(D_RC4, j, count, d); 1702 print_result(D_RC4, j, count, d);
1767 } 1703 }
1768 } 1704 }
@@ -1771,23 +1707,23 @@ speed_main(int argc, char **argv)
1771 if (doit[D_CBC_DES]) { 1707 if (doit[D_CBC_DES]) {
1772 for (j = 0; j < SIZE_NUM; j++) { 1708 for (j = 0; j < SIZE_NUM; j++) {
1773 print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]); 1709 print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]);
1774 Time_F(START); 1710 time_f(START);
1775 for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++) 1711 for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++)
1776 DES_ncbc_encrypt(buf, buf, lengths[j], &sch, 1712 DES_ncbc_encrypt(buf, buf, lengths[j], &sch,
1777 &DES_iv, DES_ENCRYPT); 1713 &DES_iv, DES_ENCRYPT);
1778 d = Time_F(STOP); 1714 d = time_f(STOP);
1779 print_result(D_CBC_DES, j, count, d); 1715 print_result(D_CBC_DES, j, count, d);
1780 } 1716 }
1781 } 1717 }
1782 if (doit[D_EDE3_DES]) { 1718 if (doit[D_EDE3_DES]) {
1783 for (j = 0; j < SIZE_NUM; j++) { 1719 for (j = 0; j < SIZE_NUM; j++) {
1784 print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]); 1720 print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]);
1785 Time_F(START); 1721 time_f(START);
1786 for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++) 1722 for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++)
1787 DES_ede3_cbc_encrypt(buf, buf, lengths[j], 1723 DES_ede3_cbc_encrypt(buf, buf, lengths[j],
1788 &sch, &sch2, &sch3, 1724 &sch, &sch2, &sch3,
1789 &DES_iv, DES_ENCRYPT); 1725 &DES_iv, DES_ENCRYPT);
1790 d = Time_F(STOP); 1726 d = time_f(STOP);
1791 print_result(D_EDE3_DES, j, count, d); 1727 print_result(D_EDE3_DES, j, count, d);
1792 } 1728 }
1793 } 1729 }
@@ -1796,72 +1732,72 @@ speed_main(int argc, char **argv)
1796 if (doit[D_CBC_128_AES]) { 1732 if (doit[D_CBC_128_AES]) {
1797 for (j = 0; j < SIZE_NUM; j++) { 1733 for (j = 0; j < SIZE_NUM; j++) {
1798 print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j], lengths[j]); 1734 print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j], lengths[j]);
1799 Time_F(START); 1735 time_f(START);
1800 for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++) 1736 for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++)
1801 AES_cbc_encrypt(buf, buf, 1737 AES_cbc_encrypt(buf, buf,
1802 (unsigned long) lengths[j], &aes_ks1, 1738 (unsigned long) lengths[j], &aes_ks1,
1803 iv, AES_ENCRYPT); 1739 iv, AES_ENCRYPT);
1804 d = Time_F(STOP); 1740 d = time_f(STOP);
1805 print_result(D_CBC_128_AES, j, count, d); 1741 print_result(D_CBC_128_AES, j, count, d);
1806 } 1742 }
1807 } 1743 }
1808 if (doit[D_CBC_192_AES]) { 1744 if (doit[D_CBC_192_AES]) {
1809 for (j = 0; j < SIZE_NUM; j++) { 1745 for (j = 0; j < SIZE_NUM; j++) {
1810 print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j], lengths[j]); 1746 print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j], lengths[j]);
1811 Time_F(START); 1747 time_f(START);
1812 for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++) 1748 for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++)
1813 AES_cbc_encrypt(buf, buf, 1749 AES_cbc_encrypt(buf, buf,
1814 (unsigned long) lengths[j], &aes_ks2, 1750 (unsigned long) lengths[j], &aes_ks2,
1815 iv, AES_ENCRYPT); 1751 iv, AES_ENCRYPT);
1816 d = Time_F(STOP); 1752 d = time_f(STOP);
1817 print_result(D_CBC_192_AES, j, count, d); 1753 print_result(D_CBC_192_AES, j, count, d);
1818 } 1754 }
1819 } 1755 }
1820 if (doit[D_CBC_256_AES]) { 1756 if (doit[D_CBC_256_AES]) {
1821 for (j = 0; j < SIZE_NUM; j++) { 1757 for (j = 0; j < SIZE_NUM; j++) {
1822 print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j], lengths[j]); 1758 print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j], lengths[j]);
1823 Time_F(START); 1759 time_f(START);
1824 for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++) 1760 for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++)
1825 AES_cbc_encrypt(buf, buf, 1761 AES_cbc_encrypt(buf, buf,
1826 (unsigned long) lengths[j], &aes_ks3, 1762 (unsigned long) lengths[j], &aes_ks3,
1827 iv, AES_ENCRYPT); 1763 iv, AES_ENCRYPT);
1828 d = Time_F(STOP); 1764 d = time_f(STOP);
1829 print_result(D_CBC_256_AES, j, count, d); 1765 print_result(D_CBC_256_AES, j, count, d);
1830 } 1766 }
1831 } 1767 }
1832 if (doit[D_IGE_128_AES]) { 1768 if (doit[D_IGE_128_AES]) {
1833 for (j = 0; j < SIZE_NUM; j++) { 1769 for (j = 0; j < SIZE_NUM; j++) {
1834 print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j], lengths[j]); 1770 print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j], lengths[j]);
1835 Time_F(START); 1771 time_f(START);
1836 for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++) 1772 for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++)
1837 AES_ige_encrypt(buf, buf2, 1773 AES_ige_encrypt(buf, buf2,
1838 (unsigned long) lengths[j], &aes_ks1, 1774 (unsigned long) lengths[j], &aes_ks1,
1839 iv, AES_ENCRYPT); 1775 iv, AES_ENCRYPT);
1840 d = Time_F(STOP); 1776 d = time_f(STOP);
1841 print_result(D_IGE_128_AES, j, count, d); 1777 print_result(D_IGE_128_AES, j, count, d);
1842 } 1778 }
1843 } 1779 }
1844 if (doit[D_IGE_192_AES]) { 1780 if (doit[D_IGE_192_AES]) {
1845 for (j = 0; j < SIZE_NUM; j++) { 1781 for (j = 0; j < SIZE_NUM; j++) {
1846 print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j], lengths[j]); 1782 print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j], lengths[j]);
1847 Time_F(START); 1783 time_f(START);
1848 for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++) 1784 for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++)
1849 AES_ige_encrypt(buf, buf2, 1785 AES_ige_encrypt(buf, buf2,
1850 (unsigned long) lengths[j], &aes_ks2, 1786 (unsigned long) lengths[j], &aes_ks2,
1851 iv, AES_ENCRYPT); 1787 iv, AES_ENCRYPT);
1852 d = Time_F(STOP); 1788 d = time_f(STOP);
1853 print_result(D_IGE_192_AES, j, count, d); 1789 print_result(D_IGE_192_AES, j, count, d);
1854 } 1790 }
1855 } 1791 }
1856 if (doit[D_IGE_256_AES]) { 1792 if (doit[D_IGE_256_AES]) {
1857 for (j = 0; j < SIZE_NUM; j++) { 1793 for (j = 0; j < SIZE_NUM; j++) {
1858 print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j], lengths[j]); 1794 print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j], lengths[j]);
1859 Time_F(START); 1795 time_f(START);
1860 for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++) 1796 for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++)
1861 AES_ige_encrypt(buf, buf2, 1797 AES_ige_encrypt(buf, buf2,
1862 (unsigned long) lengths[j], &aes_ks3, 1798 (unsigned long) lengths[j], &aes_ks3,
1863 iv, AES_ENCRYPT); 1799 iv, AES_ENCRYPT);
1864 d = Time_F(STOP); 1800 d = time_f(STOP);
1865 print_result(D_IGE_256_AES, j, count, d); 1801 print_result(D_IGE_256_AES, j, count, d);
1866 } 1802 }
1867 } 1803 }
@@ -1871,10 +1807,10 @@ speed_main(int argc, char **argv)
1871 1807
1872 for (j = 0; j < SIZE_NUM; j++) { 1808 for (j = 0; j < SIZE_NUM; j++) {
1873 print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]); 1809 print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]);
1874 Time_F(START); 1810 time_f(START);
1875 for (count = 0, run = 1; COND(c[D_GHASH][j]); count++) 1811 for (count = 0, run = 1; COND(c[D_GHASH][j]); count++)
1876 CRYPTO_gcm128_aad(ctx, buf, lengths[j]); 1812 CRYPTO_gcm128_aad(ctx, buf, lengths[j]);
1877 d = Time_F(STOP); 1813 d = time_f(STOP);
1878 print_result(D_GHASH, j, count, d); 1814 print_result(D_GHASH, j, count, d);
1879 } 1815 }
1880 CRYPTO_gcm128_release(ctx); 1816 CRYPTO_gcm128_release(ctx);
@@ -1897,11 +1833,11 @@ speed_main(int argc, char **argv)
1897 1833
1898 for (j = 0; j < SIZE_NUM; j++) { 1834 for (j = 0; j < SIZE_NUM; j++) {
1899 print_message(names[D_AES_128_GCM],c[D_AES_128_GCM][j],lengths[j]); 1835 print_message(names[D_AES_128_GCM],c[D_AES_128_GCM][j],lengths[j]);
1900 Time_F(START); 1836 time_f(START);
1901 for (count = 0, run = 1; COND(c[D_AES_128_GCM][j]); count++) 1837 for (count = 0, run = 1; COND(c[D_AES_128_GCM][j]); count++)
1902 EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, 1838 EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce,
1903 nonce_len, buf, lengths[j], NULL, 0); 1839 nonce_len, buf, lengths[j], NULL, 0);
1904 d=Time_F(STOP); 1840 d = time_f(STOP);
1905 print_result(D_AES_128_GCM,j,count,d); 1841 print_result(D_AES_128_GCM,j,count,d);
1906 } 1842 }
1907 EVP_AEAD_CTX_free(ctx); 1843 EVP_AEAD_CTX_free(ctx);
@@ -1925,11 +1861,11 @@ speed_main(int argc, char **argv)
1925 1861
1926 for (j = 0; j < SIZE_NUM; j++) { 1862 for (j = 0; j < SIZE_NUM; j++) {
1927 print_message(names[D_AES_256_GCM],c[D_AES_256_GCM][j],lengths[j]); 1863 print_message(names[D_AES_256_GCM],c[D_AES_256_GCM][j],lengths[j]);
1928 Time_F(START); 1864 time_f(START);
1929 for (count = 0, run = 1; COND(c[D_AES_256_GCM][j]); count++) 1865 for (count = 0, run = 1; COND(c[D_AES_256_GCM][j]); count++)
1930 EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, 1866 EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce,
1931 nonce_len, buf, lengths[j], NULL, 0); 1867 nonce_len, buf, lengths[j], NULL, 0);
1932 d=Time_F(STOP); 1868 d = time_f(STOP);
1933 print_result(D_AES_256_GCM, j, count, d); 1869 print_result(D_AES_256_GCM, j, count, d);
1934 } 1870 }
1935 EVP_AEAD_CTX_free(ctx); 1871 EVP_AEAD_CTX_free(ctx);
@@ -1955,11 +1891,11 @@ speed_main(int argc, char **argv)
1955 for (j = 0; j < SIZE_NUM; j++) { 1891 for (j = 0; j < SIZE_NUM; j++) {
1956 print_message(names[D_CHACHA20_POLY1305], 1892 print_message(names[D_CHACHA20_POLY1305],
1957 c[D_CHACHA20_POLY1305][j], lengths[j]); 1893 c[D_CHACHA20_POLY1305][j], lengths[j]);
1958 Time_F(START); 1894 time_f(START);
1959 for (count = 0, run = 1; COND(c[D_CHACHA20_POLY1305][j]); count++) 1895 for (count = 0, run = 1; COND(c[D_CHACHA20_POLY1305][j]); count++)
1960 EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, 1896 EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce,
1961 nonce_len, buf, lengths[j], NULL, 0); 1897 nonce_len, buf, lengths[j], NULL, 0);
1962 d=Time_F(STOP); 1898 d = time_f(STOP);
1963 print_result(D_CHACHA20_POLY1305, j, count, d); 1899 print_result(D_CHACHA20_POLY1305, j, count, d);
1964 } 1900 }
1965 EVP_AEAD_CTX_free(ctx); 1901 EVP_AEAD_CTX_free(ctx);
@@ -1969,36 +1905,36 @@ speed_main(int argc, char **argv)
1969 if (doit[D_CBC_128_CML]) { 1905 if (doit[D_CBC_128_CML]) {
1970 for (j = 0; j < SIZE_NUM; j++) { 1906 for (j = 0; j < SIZE_NUM; j++) {
1971 print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j], lengths[j]); 1907 print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j], lengths[j]);
1972 Time_F(START); 1908 time_f(START);
1973 for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++) 1909 for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++)
1974 Camellia_cbc_encrypt(buf, buf, 1910 Camellia_cbc_encrypt(buf, buf,
1975 (unsigned long) lengths[j], &camellia_ks1, 1911 (unsigned long) lengths[j], &camellia_ks1,
1976 iv, CAMELLIA_ENCRYPT); 1912 iv, CAMELLIA_ENCRYPT);
1977 d = Time_F(STOP); 1913 d = time_f(STOP);
1978 print_result(D_CBC_128_CML, j, count, d); 1914 print_result(D_CBC_128_CML, j, count, d);
1979 } 1915 }
1980 } 1916 }
1981 if (doit[D_CBC_192_CML]) { 1917 if (doit[D_CBC_192_CML]) {
1982 for (j = 0; j < SIZE_NUM; j++) { 1918 for (j = 0; j < SIZE_NUM; j++) {
1983 print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j], lengths[j]); 1919 print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j], lengths[j]);
1984 Time_F(START); 1920 time_f(START);
1985 for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++) 1921 for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++)
1986 Camellia_cbc_encrypt(buf, buf, 1922 Camellia_cbc_encrypt(buf, buf,
1987 (unsigned long) lengths[j], &camellia_ks2, 1923 (unsigned long) lengths[j], &camellia_ks2,
1988 iv, CAMELLIA_ENCRYPT); 1924 iv, CAMELLIA_ENCRYPT);
1989 d = Time_F(STOP); 1925 d = time_f(STOP);
1990 print_result(D_CBC_192_CML, j, count, d); 1926 print_result(D_CBC_192_CML, j, count, d);
1991 } 1927 }
1992 } 1928 }
1993 if (doit[D_CBC_256_CML]) { 1929 if (doit[D_CBC_256_CML]) {
1994 for (j = 0; j < SIZE_NUM; j++) { 1930 for (j = 0; j < SIZE_NUM; j++) {
1995 print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j], lengths[j]); 1931 print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j], lengths[j]);
1996 Time_F(START); 1932 time_f(START);
1997 for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++) 1933 for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++)
1998 Camellia_cbc_encrypt(buf, buf, 1934 Camellia_cbc_encrypt(buf, buf,
1999 (unsigned long) lengths[j], &camellia_ks3, 1935 (unsigned long) lengths[j], &camellia_ks3,
2000 iv, CAMELLIA_ENCRYPT); 1936 iv, CAMELLIA_ENCRYPT);
2001 d = Time_F(STOP); 1937 d = time_f(STOP);
2002 print_result(D_CBC_256_CML, j, count, d); 1938 print_result(D_CBC_256_CML, j, count, d);
2003 } 1939 }
2004 } 1940 }
@@ -2007,12 +1943,12 @@ speed_main(int argc, char **argv)
2007 if (doit[D_CBC_IDEA]) { 1943 if (doit[D_CBC_IDEA]) {
2008 for (j = 0; j < SIZE_NUM; j++) { 1944 for (j = 0; j < SIZE_NUM; j++) {
2009 print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]); 1945 print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]);
2010 Time_F(START); 1946 time_f(START);
2011 for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++) 1947 for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++)
2012 idea_cbc_encrypt(buf, buf, 1948 idea_cbc_encrypt(buf, buf,
2013 (unsigned long) lengths[j], &idea_ks, 1949 (unsigned long) lengths[j], &idea_ks,
2014 iv, IDEA_ENCRYPT); 1950 iv, IDEA_ENCRYPT);
2015 d = Time_F(STOP); 1951 d = time_f(STOP);
2016 print_result(D_CBC_IDEA, j, count, d); 1952 print_result(D_CBC_IDEA, j, count, d);
2017 } 1953 }
2018 } 1954 }
@@ -2021,12 +1957,12 @@ speed_main(int argc, char **argv)
2021 if (doit[D_CBC_RC2]) { 1957 if (doit[D_CBC_RC2]) {
2022 for (j = 0; j < SIZE_NUM; j++) { 1958 for (j = 0; j < SIZE_NUM; j++) {
2023 print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]); 1959 print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]);
2024 Time_F(START); 1960 time_f(START);
2025 for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++) 1961 for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++)
2026 RC2_cbc_encrypt(buf, buf, 1962 RC2_cbc_encrypt(buf, buf,
2027 (unsigned long) lengths[j], &rc2_ks, 1963 (unsigned long) lengths[j], &rc2_ks,
2028 iv, RC2_ENCRYPT); 1964 iv, RC2_ENCRYPT);
2029 d = Time_F(STOP); 1965 d = time_f(STOP);
2030 print_result(D_CBC_RC2, j, count, d); 1966 print_result(D_CBC_RC2, j, count, d);
2031 } 1967 }
2032 } 1968 }
@@ -2035,12 +1971,12 @@ speed_main(int argc, char **argv)
2035 if (doit[D_CBC_BF]) { 1971 if (doit[D_CBC_BF]) {
2036 for (j = 0; j < SIZE_NUM; j++) { 1972 for (j = 0; j < SIZE_NUM; j++) {
2037 print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]); 1973 print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]);
2038 Time_F(START); 1974 time_f(START);
2039 for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++) 1975 for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++)
2040 BF_cbc_encrypt(buf, buf, 1976 BF_cbc_encrypt(buf, buf,
2041 (unsigned long) lengths[j], &bf_ks, 1977 (unsigned long) lengths[j], &bf_ks,
2042 iv, BF_ENCRYPT); 1978 iv, BF_ENCRYPT);
2043 d = Time_F(STOP); 1979 d = time_f(STOP);
2044 print_result(D_CBC_BF, j, count, d); 1980 print_result(D_CBC_BF, j, count, d);
2045 } 1981 }
2046 } 1982 }
@@ -2049,12 +1985,12 @@ speed_main(int argc, char **argv)
2049 if (doit[D_CBC_CAST]) { 1985 if (doit[D_CBC_CAST]) {
2050 for (j = 0; j < SIZE_NUM; j++) { 1986 for (j = 0; j < SIZE_NUM; j++) {
2051 print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]); 1987 print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]);
2052 Time_F(START); 1988 time_f(START);
2053 for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++) 1989 for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++)
2054 CAST_cbc_encrypt(buf, buf, 1990 CAST_cbc_encrypt(buf, buf,
2055 (unsigned long) lengths[j], &cast_ks, 1991 (unsigned long) lengths[j], &cast_ks,
2056 iv, CAST_ENCRYPT); 1992 iv, CAST_ENCRYPT);
2057 d = Time_F(STOP); 1993 d = time_f(STOP);
2058 print_result(D_CBC_CAST, j, count, d); 1994 print_result(D_CBC_CAST, j, count, d);
2059 } 1995 }
2060 } 1996 }
@@ -2087,7 +2023,7 @@ speed_main(int argc, char **argv)
2087 EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv); 2023 EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv);
2088 EVP_CIPHER_CTX_set_padding(ctx, 0); 2024 EVP_CIPHER_CTX_set_padding(ctx, 0);
2089 2025
2090 Time_F(START); 2026 time_f(START);
2091 if (decrypt) 2027 if (decrypt)
2092 for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) 2028 for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
2093 EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]); 2029 EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]);
@@ -2098,7 +2034,7 @@ speed_main(int argc, char **argv)
2098 EVP_DecryptFinal_ex(ctx, buf, &outl); 2034 EVP_DecryptFinal_ex(ctx, buf, &outl);
2099 else 2035 else
2100 EVP_EncryptFinal_ex(ctx, buf, &outl); 2036 EVP_EncryptFinal_ex(ctx, buf, &outl);
2101 d = Time_F(STOP); 2037 d = time_f(STOP);
2102 EVP_CIPHER_CTX_free(ctx); 2038 EVP_CIPHER_CTX_free(ctx);
2103 } 2039 }
2104 if (evp_md) { 2040 if (evp_md) {
@@ -2106,11 +2042,11 @@ speed_main(int argc, char **argv)
2106 print_message(names[D_EVP], save_count, 2042 print_message(names[D_EVP], save_count,
2107 lengths[j]); 2043 lengths[j]);
2108 2044
2109 Time_F(START); 2045 time_f(START);
2110 for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) 2046 for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
2111 EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL); 2047 EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL);
2112 2048
2113 d = Time_F(STOP); 2049 d = time_f(STOP);
2114 } 2050 }
2115 print_result(D_EVP, j, count, d); 2051 print_result(D_EVP, j, count, d);
2116 } 2052 }
@@ -2130,7 +2066,7 @@ speed_main(int argc, char **argv)
2130 rsa_c[j][0], rsa_bits[j], 2066 rsa_c[j][0], rsa_bits[j],
2131 RSA_SECONDS); 2067 RSA_SECONDS);
2132/* RSA_blinding_on(rsa_key[j],NULL); */ 2068/* RSA_blinding_on(rsa_key[j],NULL); */
2133 Time_F(START); 2069 time_f(START);
2134 for (count = 0, run = 1; COND(rsa_c[j][0]); count++) { 2070 for (count = 0, run = 1; COND(rsa_c[j][0]); count++) {
2135 ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, 2071 ret = RSA_sign(NID_md5_sha1, buf, 36, buf2,
2136 &rsa_num, rsa_key[j]); 2072 &rsa_num, rsa_key[j]);
@@ -2142,7 +2078,7 @@ speed_main(int argc, char **argv)
2142 break; 2078 break;
2143 } 2079 }
2144 } 2080 }
2145 d = Time_F(STOP); 2081 d = time_f(STOP);
2146 BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n" 2082 BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n"
2147 : "%ld %d bit private RSA in %.2fs\n", 2083 : "%ld %d bit private RSA in %.2fs\n",
2148 count, rsa_bits[j], d); 2084 count, rsa_bits[j], d);
@@ -2159,7 +2095,7 @@ speed_main(int argc, char **argv)
2159 pkey_print_message("public", "rsa", 2095 pkey_print_message("public", "rsa",
2160 rsa_c[j][1], rsa_bits[j], 2096 rsa_c[j][1], rsa_bits[j],
2161 RSA_SECONDS); 2097 RSA_SECONDS);
2162 Time_F(START); 2098 time_f(START);
2163 for (count = 0, run = 1; COND(rsa_c[j][1]); count++) { 2099 for (count = 0, run = 1; COND(rsa_c[j][1]); count++) {
2164 ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, 2100 ret = RSA_verify(NID_md5_sha1, buf, 36, buf2,
2165 rsa_num, rsa_key[j]); 2101 rsa_num, rsa_key[j]);
@@ -2171,7 +2107,7 @@ speed_main(int argc, char **argv)
2171 break; 2107 break;
2172 } 2108 }
2173 } 2109 }
2174 d = Time_F(STOP); 2110 d = time_f(STOP);
2175 BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n" 2111 BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n"
2176 : "%ld %d bit public RSA in %.2fs\n", 2112 : "%ld %d bit public RSA in %.2fs\n",
2177 count, rsa_bits[j], d); 2113 count, rsa_bits[j], d);
@@ -2204,7 +2140,7 @@ speed_main(int argc, char **argv)
2204 pkey_print_message("sign", "dsa", 2140 pkey_print_message("sign", "dsa",
2205 dsa_c[j][0], dsa_bits[j], 2141 dsa_c[j][0], dsa_bits[j],
2206 DSA_SECONDS); 2142 DSA_SECONDS);
2207 Time_F(START); 2143 time_f(START);
2208 for (count = 0, run = 1; COND(dsa_c[j][0]); count++) { 2144 for (count = 0, run = 1; COND(dsa_c[j][0]); count++) {
2209 ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, 2145 ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2,
2210 &kk, dsa_key[j]); 2146 &kk, dsa_key[j]);
@@ -2216,7 +2152,7 @@ speed_main(int argc, char **argv)
2216 break; 2152 break;
2217 } 2153 }
2218 } 2154 }
2219 d = Time_F(STOP); 2155 d = time_f(STOP);
2220 BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n" 2156 BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n"
2221 : "%ld %d bit DSA signs in %.2fs\n", 2157 : "%ld %d bit DSA signs in %.2fs\n",
2222 count, dsa_bits[j], d); 2158 count, dsa_bits[j], d);
@@ -2234,7 +2170,7 @@ speed_main(int argc, char **argv)
2234 pkey_print_message("verify", "dsa", 2170 pkey_print_message("verify", "dsa",
2235 dsa_c[j][1], dsa_bits[j], 2171 dsa_c[j][1], dsa_bits[j],
2236 DSA_SECONDS); 2172 DSA_SECONDS);
2237 Time_F(START); 2173 time_f(START);
2238 for (count = 0, run = 1; COND(dsa_c[j][1]); count++) { 2174 for (count = 0, run = 1; COND(dsa_c[j][1]); count++) {
2239 ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, 2175 ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2,
2240 kk, dsa_key[j]); 2176 kk, dsa_key[j]);
@@ -2246,7 +2182,7 @@ speed_main(int argc, char **argv)
2246 break; 2182 break;
2247 } 2183 }
2248 } 2184 }
2249 d = Time_F(STOP); 2185 d = time_f(STOP);
2250 BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n" 2186 BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n"
2251 : "%ld %d bit DSA verify in %.2fs\n", 2187 : "%ld %d bit DSA verify in %.2fs\n",
2252 count, dsa_bits[j], d); 2188 count, dsa_bits[j], d);
@@ -2287,7 +2223,7 @@ speed_main(int argc, char **argv)
2287 test_curves_bits[j], 2223 test_curves_bits[j],
2288 ECDSA_SECONDS); 2224 ECDSA_SECONDS);
2289 2225
2290 Time_F(START); 2226 time_f(START);
2291 for (count = 0, run = 1; COND(ecdsa_c[j][0]); 2227 for (count = 0, run = 1; COND(ecdsa_c[j][0]);
2292 count++) { 2228 count++) {
2293 ret = ECDSA_sign(0, buf, 20, 2229 ret = ECDSA_sign(0, buf, 20,
@@ -2300,7 +2236,7 @@ speed_main(int argc, char **argv)
2300 break; 2236 break;
2301 } 2237 }
2302 } 2238 }
2303 d = Time_F(STOP); 2239 d = time_f(STOP);
2304 2240
2305 BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" : 2241 BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
2306 "%ld %d bit ECDSA signs in %.2fs \n", 2242 "%ld %d bit ECDSA signs in %.2fs \n",
@@ -2321,7 +2257,7 @@ speed_main(int argc, char **argv)
2321 ecdsa_c[j][1], 2257 ecdsa_c[j][1],
2322 test_curves_bits[j], 2258 test_curves_bits[j],
2323 ECDSA_SECONDS); 2259 ECDSA_SECONDS);
2324 Time_F(START); 2260 time_f(START);
2325 for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) { 2261 for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) {
2326 ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]); 2262 ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
2327 if (ret != 1) { 2263 if (ret != 1) {
@@ -2331,7 +2267,7 @@ speed_main(int argc, char **argv)
2331 break; 2267 break;
2332 } 2268 }
2333 } 2269 }
2334 d = Time_F(STOP); 2270 d = time_f(STOP);
2335 BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n" 2271 BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n"
2336 : "%ld %d bit ECDSA verify in %.2fs\n", 2272 : "%ld %d bit ECDSA verify in %.2fs\n",
2337 count, test_curves_bits[j], d); 2273 count, test_curves_bits[j], d);
@@ -2408,7 +2344,7 @@ speed_main(int argc, char **argv)
2408 ecdh_c[j][0], 2344 ecdh_c[j][0],
2409 test_curves_bits[j], 2345 test_curves_bits[j],
2410 ECDH_SECONDS); 2346 ECDH_SECONDS);
2411 Time_F(START); 2347 time_f(START);
2412 for (count = 0, run = 1; 2348 for (count = 0, run = 1;
2413 COND(ecdh_c[j][0]); count++) { 2349 COND(ecdh_c[j][0]); count++) {
2414 ECDH_compute_key(secret_a, 2350 ECDH_compute_key(secret_a,
@@ -2416,7 +2352,7 @@ speed_main(int argc, char **argv)
2416 EC_KEY_get0_public_key(ecdh_b[j]), 2352 EC_KEY_get0_public_key(ecdh_b[j]),
2417 ecdh_a[j], kdf); 2353 ecdh_a[j], kdf);
2418 } 2354 }
2419 d = Time_F(STOP); 2355 d = time_f(STOP);
2420 BIO_printf(bio_err, mr 2356 BIO_printf(bio_err, mr
2421 ? "+R7:%ld:%d:%.2f\n" 2357 ? "+R7:%ld:%d:%.2f\n"
2422 : "%ld %d-bit ECDH ops in %.2fs\n", 2358 : "%ld %d-bit ECDH ops in %.2fs\n",