From 5c606ad29f8e27097e83589dd76dd151ab573df1 Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Thu, 25 Oct 2018 14:56:28 +0300 Subject: [PATCH] update libressl to 2.8.2 --- bin/nc/nc.1 | 234 ++-- bin/nc/netcat.c | 90 +- bin/nc/socks.c | 19 +- bin/openssl/apps.c | 5 +- bin/openssl/apps.h | 10 +- bin/openssl/apps_posix.c | 8 +- bin/openssl/openssl.1 | 297 ++--- bin/openssl/pkcs8.c | 71 +- bin/openssl/s_apps.h | 4 +- bin/openssl/s_cb.c | 5 +- bin/openssl/s_socket.c | 4 +- bin/openssl/s_time.c | 313 ++--- bin/openssl/speed.c | 6 +- lib/libcrypto/Symbols.list | 19 +- lib/libcrypto/aes/aes_x86core.c | 5 +- lib/libcrypto/asn1/a_bitstr.c | 58 +- lib/libcrypto/asn1/a_digest.c | 9 +- lib/libcrypto/asn1/a_enum.c | 8 +- lib/libcrypto/asn1/a_object.c | 8 +- lib/libcrypto/asn1/a_strex.c | 21 +- lib/libcrypto/asn1/a_time_tm.c | 10 +- lib/libcrypto/asn1/a_type.c | 6 +- lib/libcrypto/asn1/ameth_lib.c | 56 +- lib/libcrypto/asn1/asn1.h | 87 +- lib/libcrypto/asn1/asn1_err.c | 3 +- lib/libcrypto/asn1/asn1_gen.c | 6 +- lib/libcrypto/asn1/asn1_lib.c | 4 +- lib/libcrypto/asn1/asn1_locl.h | 4 +- lib/libcrypto/asn1/asn_pack.c | 4 +- lib/libcrypto/asn1/bio_asn1.c | 6 +- lib/libcrypto/asn1/d2i_pr.c | 8 +- lib/libcrypto/asn1/evp_asn1.c | 6 +- lib/libcrypto/asn1/f_enum.c | 4 +- lib/libcrypto/asn1/f_int.c | 7 +- lib/libcrypto/asn1/f_string.c | 4 +- lib/libcrypto/asn1/n_pkey.c | 4 +- lib/libcrypto/asn1/p8_pkey.c | 79 +- lib/libcrypto/asn1/t_bitst.c | 6 +- lib/libcrypto/asn1/t_x509.c | 11 +- lib/libcrypto/asn1/tasn_dec.c | 65 +- lib/libcrypto/asn1/tasn_fre.c | 7 +- lib/libcrypto/asn1/tasn_prn.c | 12 +- lib/libcrypto/asn1/x_algor.c | 6 +- lib/libcrypto/asn1/x_crl.c | 34 +- lib/libcrypto/asn1/x_x509a.c | 10 +- lib/libcrypto/bio/bf_buff.c | 6 +- lib/libcrypto/bio/bf_nbio.c | 6 +- lib/libcrypto/bio/bf_null.c | 6 +- lib/libcrypto/bio/bio.h | 56 +- lib/libcrypto/bio/bio_lib.c | 6 +- lib/libcrypto/bio/bio_meth.c | 18 +- lib/libcrypto/bio/bss_acpt.c | 8 +- lib/libcrypto/bio/bss_bio.c | 6 +- lib/libcrypto/bio/bss_conn.c | 8 +- lib/libcrypto/bio/bss_dgram.c | 6 +- lib/libcrypto/bio/bss_fd.c | 6 +- lib/libcrypto/bio/bss_file.c | 6 +- lib/libcrypto/bio/bss_log.c | 6 +- lib/libcrypto/bio/bss_mem.c | 10 +- lib/libcrypto/bio/bss_null.c | 6 +- lib/libcrypto/bio/bss_sock.c | 6 +- lib/libcrypto/bn/bn_add.c | 224 +--- lib/libcrypto/bn/bn_lcl.h | 5 +- lib/libcrypto/bn/bn_lib.c | 61 +- lib/libcrypto/cert.pem | 49 +- lib/libcrypto/compat/include/unistd.h | 19 + lib/libcrypto/crypto.h | 12 +- lib/libcrypto/dh/dh_ameth.c | 14 +- lib/libcrypto/dh/dh_key.c | 4 +- lib/libcrypto/dh/dh_lib.c | 16 +- lib/libcrypto/dsa/dsa_ameth.c | 14 +- lib/libcrypto/dsa/dsa_asn1.c | 7 +- lib/libcrypto/dsa/dsa_lib.c | 16 +- lib/libcrypto/dsa/dsa_ossl.c | 160 ++- lib/libcrypto/dsa/dsa_sign.c | 13 +- lib/libcrypto/dso/dso_lib.c | 8 +- lib/libcrypto/ec/ec.h | 4 +- lib/libcrypto/ec/ec2_mult.c | 25 +- lib/libcrypto/ec/ec2_oct.c | 8 +- lib/libcrypto/ec/ec2_smpl.c | 30 +- lib/libcrypto/ec/ec_ameth.c | 28 +- lib/libcrypto/ec/ec_asn1.c | 33 +- lib/libcrypto/ec/ec_check.c | 4 +- lib/libcrypto/ec/ec_curve.c | 4 +- lib/libcrypto/ec/ec_key.c | 8 +- lib/libcrypto/ec/ec_lcl.h | 17 +- lib/libcrypto/ec/ec_lib.c | 101 +- lib/libcrypto/ec/ec_mult.c | 8 +- lib/libcrypto/ec/eck_prn.c | 4 +- lib/libcrypto/ec/ecp_mont.c | 9 +- lib/libcrypto/ec/ecp_nist.c | 11 +- lib/libcrypto/ec/ecp_nistp224.c | 8 +- lib/libcrypto/ec/ecp_nistp256.c | 8 +- lib/libcrypto/ec/ecp_nistp521.c | 8 +- lib/libcrypto/ec/ecp_nistz256.c | 8 +- lib/libcrypto/ec/ecp_oct.c | 8 +- lib/libcrypto/ec/ecp_smpl.c | 274 +++- lib/libcrypto/ecdh/ech_key.c | 6 +- lib/libcrypto/ecdh/ech_lib.c | 13 +- lib/libcrypto/ecdsa/ecs_lib.c | 13 +- lib/libcrypto/ecdsa/ecs_ossl.c | 288 +++-- lib/libcrypto/engine/eng_aesni.c | 12 +- lib/libcrypto/engine/eng_cnf.c | 5 +- lib/libcrypto/engine/eng_init.c | 8 +- lib/libcrypto/engine/eng_lib.c | 8 +- lib/libcrypto/engine/eng_list.c | 8 +- lib/libcrypto/engine/eng_openssl.c | 6 +- lib/libcrypto/engine/eng_padlock.c | 21 +- lib/libcrypto/err/err.c | 5 +- lib/libcrypto/evp/bio_b64.c | 11 +- lib/libcrypto/evp/bio_enc.c | 35 +- lib/libcrypto/evp/bio_md.c | 6 +- lib/libcrypto/evp/digest.c | 16 +- lib/libcrypto/evp/encode.c | 14 +- lib/libcrypto/evp/evp.h | 30 +- lib/libcrypto/evp/evp_enc.c | 7 +- lib/libcrypto/evp/evp_key.c | 14 +- lib/libcrypto/evp/evp_lib.c | 46 +- lib/libcrypto/evp/evp_pkey.c | 39 +- lib/libcrypto/evp/m_md5_sha1.c | 13 +- lib/libcrypto/evp/m_sigver.c | 4 +- lib/libcrypto/evp/p_lib.c | 26 +- lib/libcrypto/evp/pmeth_lib.c | 12 +- lib/libcrypto/gost/gostr341001_ameth.c | 22 +- lib/libcrypto/hkdf/hkdf.c | 1 + lib/libcrypto/hkdf/hkdf.h | 1 + lib/libcrypto/malloc-wrapper.c | 15 +- lib/libcrypto/man/ASN1_INTEGER_get.3 | 238 ++++ lib/libcrypto/man/ASN1_OBJECT_new.3 | 6 +- lib/libcrypto/man/ASN1_STRING_length.3 | 30 +- lib/libcrypto/man/ASN1_STRING_new.3 | 24 +- lib/libcrypto/man/ASN1_STRING_print_ex.3 | 12 +- lib/libcrypto/man/ASN1_TIME_set.3 | 19 +- lib/libcrypto/man/ASN1_TYPE_get.3 | 24 +- lib/libcrypto/man/ASN1_generate_nconf.3 | 8 +- lib/libcrypto/man/ASN1_item_d2i.3 | 6 +- lib/libcrypto/man/BF_set_key.3 | 14 +- lib/libcrypto/man/BIO_ctrl.3 | 9 +- lib/libcrypto/man/BIO_f_base64.3 | 8 +- lib/libcrypto/man/BIO_f_buffer.3 | 19 +- lib/libcrypto/man/BIO_f_cipher.3 | 12 +- lib/libcrypto/man/BIO_f_md.3 | 12 +- lib/libcrypto/man/BIO_f_null.3 | 8 +- lib/libcrypto/man/BIO_find_type.3 | 11 +- lib/libcrypto/man/BIO_get_ex_new_index.3 | 7 +- lib/libcrypto/man/BIO_meth_new.3 | 20 +- lib/libcrypto/man/BIO_new.3 | 15 +- lib/libcrypto/man/BIO_push.3 | 9 +- lib/libcrypto/man/BIO_read.3 | 6 +- lib/libcrypto/man/BIO_s_accept.3 | 13 +- lib/libcrypto/man/BIO_s_bio.3 | 6 +- lib/libcrypto/man/BIO_s_connect.3 | 10 +- lib/libcrypto/man/BIO_s_fd.3 | 16 +- lib/libcrypto/man/BIO_s_file.3 | 20 +- lib/libcrypto/man/BIO_s_mem.3 | 22 +- lib/libcrypto/man/BIO_s_null.3 | 8 +- lib/libcrypto/man/BIO_s_socket.3 | 11 +- lib/libcrypto/man/BIO_set_callback.3 | 19 +- lib/libcrypto/man/BIO_should_retry.3 | 18 +- lib/libcrypto/man/BN_CTX_new.3 | 6 +- lib/libcrypto/man/BN_add.3 | 53 +- lib/libcrypto/man/BN_add_word.3 | 11 +- lib/libcrypto/man/BN_bn2bin.3 | 9 +- lib/libcrypto/man/BN_cmp.3 | 8 +- lib/libcrypto/man/BN_copy.3 | 9 +- lib/libcrypto/man/BN_generate_prime.3 | 6 +- lib/libcrypto/man/BN_mod_inverse.3 | 14 +- lib/libcrypto/man/BN_mod_mul_montgomery.3 | 6 +- lib/libcrypto/man/BN_mod_mul_reciprocal.3 | 6 +- lib/libcrypto/man/BN_new.3 | 12 +- lib/libcrypto/man/BN_num_bytes.3 | 12 +- lib/libcrypto/man/BN_rand.3 | 6 +- lib/libcrypto/man/BN_set_bit.3 | 6 +- lib/libcrypto/man/BN_set_flags.3 | 59 +- lib/libcrypto/man/BN_zero.3 | 16 +- lib/libcrypto/man/BUF_MEM_new.3 | 8 +- lib/libcrypto/man/CRYPTO_get_mem_functions.3 | 32 +- lib/libcrypto/man/CRYPTO_set_ex_data.3 | 70 +- lib/libcrypto/man/CRYPTO_set_locking_callback.3 | 10 +- lib/libcrypto/man/DES_set_key.3 | 39 +- lib/libcrypto/man/DH_generate_key.3 | 6 +- lib/libcrypto/man/DH_generate_parameters.3 | 6 +- lib/libcrypto/man/DH_new.3 | 31 +- lib/libcrypto/man/DH_set_method.3 | 99 +- lib/libcrypto/man/DH_size.3 | 6 +- lib/libcrypto/man/DSA_generate_key.3 | 6 +- lib/libcrypto/man/DSA_generate_parameters.3 | 6 +- lib/libcrypto/man/DSA_new.3 | 32 +- lib/libcrypto/man/DSA_set_method.3 | 96 +- lib/libcrypto/man/DSA_sign.3 | 8 +- lib/libcrypto/man/DSA_size.3 | 6 +- lib/libcrypto/man/EC_POINT_add.3 | 26 +- lib/libcrypto/man/EC_POINT_new.3 | 18 +- lib/libcrypto/man/ENGINE_add.3 | 243 ++++ lib/libcrypto/man/ENGINE_ctrl.3 | 470 +++++++ lib/libcrypto/man/ENGINE_get_default_RSA.3 | 160 +++ lib/libcrypto/man/ENGINE_init.3 | 134 ++ lib/libcrypto/man/ENGINE_new.3 | 189 +++ lib/libcrypto/man/ENGINE_register_RSA.3 | 142 ++ lib/libcrypto/man/ENGINE_register_all_RSA.3 | 123 ++ lib/libcrypto/man/ENGINE_set_RSA.3 | 325 +++++ lib/libcrypto/man/ENGINE_set_default.3 | 185 +++ lib/libcrypto/man/ENGINE_set_flags.3 | 92 ++ lib/libcrypto/man/ENGINE_unregister_RSA.3 | 119 ++ lib/libcrypto/man/ERR_GET_LIB.3 | 6 +- lib/libcrypto/man/ERR_clear_error.3 | 6 +- lib/libcrypto/man/ERR_error_string.3 | 6 +- lib/libcrypto/man/ERR_get_error.3 | 14 +- lib/libcrypto/man/ERR_load_crypto_strings.3 | 15 +- lib/libcrypto/man/ERR_load_strings.3 | 6 +- lib/libcrypto/man/ERR_print_errors.3 | 9 +- lib/libcrypto/man/ERR_put_error.3 | 8 +- lib/libcrypto/man/ERR_remove_state.3 | 6 +- lib/libcrypto/man/EVP_BytesToKey.3 | 6 +- lib/libcrypto/man/EVP_DigestInit.3 | 32 +- lib/libcrypto/man/EVP_DigestVerifyInit.3 | 6 +- lib/libcrypto/man/EVP_EncodeInit.3 | 6 +- lib/libcrypto/man/EVP_EncryptInit.3 | 117 +- lib/libcrypto/man/EVP_OpenInit.3 | 6 +- lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 | 17 +- lib/libcrypto/man/EVP_PKEY_asn1_new.3 | 8 +- lib/libcrypto/man/EVP_PKEY_cmp.3 | 6 +- lib/libcrypto/man/EVP_PKEY_new.3 | 6 +- lib/libcrypto/man/EVP_PKEY_set1_RSA.3 | 13 +- lib/libcrypto/man/EVP_SealInit.3 | 6 +- lib/libcrypto/man/EVP_SignInit.3 | 33 +- lib/libcrypto/man/EVP_VerifyInit.3 | 14 +- lib/libcrypto/man/MD5.3 | 6 +- lib/libcrypto/man/Makefile | 15 +- lib/libcrypto/man/OBJ_nid2obj.3 | 11 +- lib/libcrypto/man/OCSP_CRLID_new.3 | 8 +- lib/libcrypto/man/OCSP_SERVICELOC_new.3 | 6 +- lib/libcrypto/man/OCSP_cert_to_id.3 | 14 +- lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3 | 9 +- lib/libcrypto/man/OPENSSL_config.3 | 12 +- lib/libcrypto/man/OPENSSL_malloc.3 | 6 +- lib/libcrypto/man/OPENSSL_sk_new.3 | 33 +- lib/libcrypto/man/OpenSSL_add_all_algorithms.3 | 6 +- lib/libcrypto/man/PEM_read.3 | 28 +- lib/libcrypto/man/PEM_read_bio_PrivateKey.3 | 65 +- lib/libcrypto/man/PKCS12_create.3 | 8 +- lib/libcrypto/man/PKCS7_new.3 | 6 +- lib/libcrypto/man/RAND_add.3 | 6 +- lib/libcrypto/man/RAND_bytes.3 | 6 +- lib/libcrypto/man/RAND_load_file.3 | 6 +- lib/libcrypto/man/RC4.3 | 6 +- lib/libcrypto/man/RSA_generate_key.3 | 6 +- lib/libcrypto/man/RSA_meth_new.3 | 44 +- lib/libcrypto/man/RSA_new.3 | 34 +- lib/libcrypto/man/RSA_print.3 | 19 +- lib/libcrypto/man/RSA_private_encrypt.3 | 9 +- lib/libcrypto/man/RSA_public_encrypt.3 | 9 +- lib/libcrypto/man/RSA_set_method.3 | 157 +-- lib/libcrypto/man/RSA_sign.3 | 9 +- lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3 | 6 +- lib/libcrypto/man/RSA_size.3 | 6 +- lib/libcrypto/man/SHA1.3 | 6 +- lib/libcrypto/man/UI_create_method.3 | 6 +- lib/libcrypto/man/X25519.3 | 199 +-- lib/libcrypto/man/X509_ALGOR_dup.3 | 11 +- lib/libcrypto/man/X509_ATTRIBUTE_new.3 | 6 +- lib/libcrypto/man/X509_CINF_new.3 | 6 +- lib/libcrypto/man/X509_CRL_new.3 | 10 +- lib/libcrypto/man/X509_EXTENSION_set_object.3 | 24 +- lib/libcrypto/man/X509_LOOKUP_hash_dir.3 | 6 +- lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 | 23 +- lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 | 14 +- lib/libcrypto/man/X509_NAME_get_index_by_NID.3 | 19 +- lib/libcrypto/man/X509_NAME_new.3 | 11 +- lib/libcrypto/man/X509_NAME_print_ex.3 | 14 +- lib/libcrypto/man/X509_OBJECT_get0_X509.3 | 32 +- lib/libcrypto/man/X509_PUBKEY_new.3 | 15 +- lib/libcrypto/man/X509_REQ_new.3 | 16 +- lib/libcrypto/man/X509_REVOKED_new.3 | 6 +- lib/libcrypto/man/X509_SIG_new.3 | 6 +- lib/libcrypto/man/X509_STORE_CTX_get_error.3 | 6 +- lib/libcrypto/man/X509_STORE_CTX_new.3 | 6 +- lib/libcrypto/man/X509_STORE_load_locations.3 | 10 +- lib/libcrypto/man/X509_STORE_new.3 | 6 +- lib/libcrypto/man/X509_STORE_set1_param.3 | 24 +- lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 | 6 +- lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 | 67 +- lib/libcrypto/man/X509_check_private_key.3 | 10 +- lib/libcrypto/man/X509_cmp_time.3 | 6 +- lib/libcrypto/man/X509_digest.3 | 6 +- lib/libcrypto/man/X509_get_pubkey.3 | 10 +- lib/libcrypto/man/X509_get_serialNumber.3 | 6 +- lib/libcrypto/man/X509_get_subject_name.3 | 17 +- lib/libcrypto/man/X509_get_version.3 | 6 +- lib/libcrypto/man/X509_new.3 | 6 +- lib/libcrypto/man/X509_sign.3 | 21 +- lib/libcrypto/man/X509_verify_cert.3 | 6 +- lib/libcrypto/man/X509v3_get_ext_by_NID.3 | 33 +- lib/libcrypto/man/d2i_ASN1_OBJECT.3 | 8 +- lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 | 12 +- lib/libcrypto/man/d2i_DHparams.3 | 6 +- lib/libcrypto/man/d2i_DSAPublicKey.3 | 55 +- lib/libcrypto/man/d2i_ECPKParameters.3 | 6 +- lib/libcrypto/man/d2i_PKCS7.3 | 6 +- lib/libcrypto/man/d2i_PrivateKey.3 | 6 +- lib/libcrypto/man/d2i_RSAPublicKey.3 | 23 +- lib/libcrypto/man/d2i_X509.3 | 13 +- lib/libcrypto/man/d2i_X509_ALGOR.3 | 6 +- lib/libcrypto/man/d2i_X509_ATTRIBUTE.3 | 6 +- lib/libcrypto/man/d2i_X509_CRL.3 | 13 +- lib/libcrypto/man/d2i_X509_EXTENSION.3 | 6 +- lib/libcrypto/man/d2i_X509_NAME.3 | 13 +- lib/libcrypto/man/d2i_X509_REQ.3 | 13 +- lib/libcrypto/man/d2i_X509_SIG.3 | 6 +- lib/libcrypto/man/des_read_pw.3 | 13 +- lib/libcrypto/man/engine.3 | 1424 --------------------- lib/libcrypto/man/evp.3 | 15 +- lib/libcrypto/man/lh_new.3 | 18 +- lib/libcrypto/man/lh_stats.3 | 16 +- lib/libcrypto/man/x509v3.cnf.5 | 6 +- lib/libcrypto/mem_dbg.c | 14 +- lib/libcrypto/modes/modes.h | 10 +- lib/libcrypto/objects/obj_dat.c | 14 +- lib/libcrypto/objects/obj_lib.c | 4 +- lib/libcrypto/objects/objects.README | 6 +- lib/libcrypto/ocsp/ocsp.h | 31 +- lib/libcrypto/ocsp/ocsp_ext.c | 16 +- lib/libcrypto/ocsp/ocsp_ht.c | 6 +- lib/libcrypto/ocsp/ocsp_lib.c | 15 +- lib/libcrypto/opensslv.h | 6 +- lib/libcrypto/pem/pem.h | 14 +- lib/libcrypto/pem/pem_lib.c | 15 +- lib/libcrypto/pem/pem_sign.c | 10 +- lib/libcrypto/pem/pvkfmt.c | 24 +- lib/libcrypto/pkcs12/p12_add.c | 6 +- lib/libcrypto/pkcs12/p12_attr.c | 14 +- lib/libcrypto/pkcs12/p12_crt.c | 8 +- lib/libcrypto/pkcs12/p12_decr.c | 11 +- lib/libcrypto/pkcs12/p12_npas.c | 20 +- lib/libcrypto/pkcs12/p12_p8d.c | 4 +- lib/libcrypto/pkcs12/p12_utl.c | 4 +- lib/libcrypto/pkcs12/pkcs12.h | 32 +- lib/libcrypto/rsa/rsa.h | 4 +- lib/libcrypto/rsa/rsa_ameth.c | 4 +- lib/libcrypto/rsa/rsa_lib.c | 19 +- lib/libcrypto/rsa/rsa_meth.c | 20 +- lib/libcrypto/rsa/rsa_oaep.c | 24 +- lib/libcrypto/rsa/rsa_pmeth.c | 4 +- lib/libcrypto/rsa/rsa_pss.c | 4 +- lib/libcrypto/rsa/rsa_saos.c | 4 +- lib/libcrypto/rsa/rsa_sign.c | 269 ++-- lib/libcrypto/shlib_version | 2 +- lib/libcrypto/stack/stack.c | 3 +- lib/libcrypto/ts/ts.h | 13 +- lib/libcrypto/ts/ts_conf.c | 5 +- lib/libcrypto/ts/ts_req_utils.c | 6 +- lib/libcrypto/ts/ts_rsp_sign.c | 6 +- lib/libcrypto/ts/ts_rsp_utils.c | 4 +- lib/libcrypto/ui/ui.h | 16 +- lib/libcrypto/ui/ui_lib.c | 16 +- lib/libcrypto/x509/by_dir.c | 6 +- lib/libcrypto/x509/vpm_int.h | 3 +- lib/libcrypto/x509/x509.h | 223 ++-- lib/libcrypto/x509/x509_att.c | 10 +- lib/libcrypto/x509/x509_cmp.c | 21 +- lib/libcrypto/x509/x509_ext.c | 39 +- lib/libcrypto/x509/x509_lu.c | 18 +- lib/libcrypto/x509/x509_obj.c | 4 +- lib/libcrypto/x509/x509_req.c | 5 +- lib/libcrypto/x509/x509_set.c | 14 +- lib/libcrypto/x509/x509_trs.c | 10 +- lib/libcrypto/x509/x509_v3.c | 14 +- lib/libcrypto/x509/x509_vfy.c | 23 +- lib/libcrypto/x509/x509_vfy.h | 29 +- lib/libcrypto/x509/x509_vpm.c | 69 +- lib/libcrypto/x509/x509name.c | 46 +- lib/libcrypto/x509/x509rset.c | 14 +- lib/libcrypto/x509/x509type.c | 23 +- lib/libcrypto/x509v3/v3_alt.c | 15 +- lib/libcrypto/x509v3/v3_conf.c | 85 +- lib/libcrypto/x509v3/v3_enum.c | 4 +- lib/libcrypto/x509v3/v3_info.c | 4 +- lib/libcrypto/x509v3/v3_lib.c | 4 +- lib/libcrypto/x509v3/v3_prn.c | 6 +- lib/libcrypto/x509v3/v3_purp.c | 16 +- lib/libcrypto/x509v3/v3_skey.c | 7 +- lib/libcrypto/x509v3/v3_sxnet.c | 12 +- lib/libcrypto/x509v3/v3_utl.c | 16 +- lib/libcrypto/x509v3/x509v3.h | 97 +- lib/libssl/bio_ssl.c | 10 +- lib/libssl/bs_cbb.c | 11 +- lib/libssl/bytestring.h | 8 +- lib/libssl/d1_both.c | 71 +- lib/libssl/d1_clnt.c | 7 +- lib/libssl/d1_meth.c | 7 +- lib/libssl/d1_pkt.c | 23 +- lib/libssl/d1_srvr.c | 11 +- lib/libssl/dtls1.h | 6 +- lib/libssl/man/BIO_f_ssl.3 | 18 +- lib/libssl/man/DTLSv1_listen.3 | 6 +- lib/libssl/man/PEM_read_SSL_SESSION.3 | 15 +- lib/libssl/man/SSL_CIPHER_get_name.3 | 14 +- lib/libssl/man/SSL_CTX_add_session.3 | 6 +- lib/libssl/man/SSL_CTX_ctrl.3 | 6 +- lib/libssl/man/SSL_CTX_flush_sessions.3 | 6 +- lib/libssl/man/SSL_CTX_free.3 | 6 +- lib/libssl/man/SSL_CTX_get_verify_mode.3 | 6 +- lib/libssl/man/SSL_CTX_load_verify_locations.3 | 6 +- lib/libssl/man/SSL_CTX_new.3 | 9 +- lib/libssl/man/SSL_CTX_sess_number.3 | 9 +- lib/libssl/man/SSL_CTX_sess_set_get_cb.3 | 32 +- lib/libssl/man/SSL_CTX_sessions.3 | 8 +- lib/libssl/man/SSL_CTX_set_cert_store.3 | 6 +- lib/libssl/man/SSL_CTX_set_cert_verify_callback.3 | 6 +- lib/libssl/man/SSL_CTX_set_cipher_list.3 | 305 ++++- lib/libssl/man/SSL_CTX_set_client_CA_list.3 | 6 +- lib/libssl/man/SSL_CTX_set_client_cert_cb.3 | 6 +- lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 | 42 +- lib/libssl/man/SSL_CTX_set_info_callback.3 | 7 +- lib/libssl/man/SSL_CTX_set_options.3 | 16 +- lib/libssl/man/SSL_CTX_set_quiet_shutdown.3 | 7 +- lib/libssl/man/SSL_CTX_set_read_ahead.3 | 6 +- lib/libssl/man/SSL_CTX_set_session_cache_mode.3 | 6 +- lib/libssl/man/SSL_CTX_set_ssl_version.3 | 6 +- lib/libssl/man/SSL_CTX_set_timeout.3 | 6 +- lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3 | 8 +- lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 | 6 +- lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3 | 6 +- lib/libssl/man/SSL_CTX_set_verify.3 | 11 +- lib/libssl/man/SSL_CTX_use_certificate.3 | 39 +- lib/libssl/man/SSL_SESSION_free.3 | 6 +- lib/libssl/man/SSL_SESSION_get_time.3 | 9 +- lib/libssl/man/SSL_SESSION_new.3 | 6 +- lib/libssl/man/SSL_SESSION_print.3 | 9 +- lib/libssl/man/SSL_accept.3 | 6 +- lib/libssl/man/SSL_alert_type_string.3 | 7 +- lib/libssl/man/SSL_clear.3 | 6 +- lib/libssl/man/SSL_connect.3 | 6 +- lib/libssl/man/SSL_copy_session_id.3 | 19 +- lib/libssl/man/SSL_do_handshake.3 | 6 +- lib/libssl/man/SSL_dup.3 | 6 +- lib/libssl/man/SSL_dup_CA_list.3 | 8 +- lib/libssl/man/SSL_free.3 | 6 +- lib/libssl/man/SSL_get_SSL_CTX.3 | 6 +- lib/libssl/man/SSL_get_certificate.3 | 11 +- lib/libssl/man/SSL_get_ciphers.3 | 11 +- lib/libssl/man/SSL_get_client_CA_list.3 | 6 +- lib/libssl/man/SSL_get_current_cipher.3 | 16 +- lib/libssl/man/SSL_get_default_timeout.3 | 6 +- lib/libssl/man/SSL_get_error.3 | 8 +- lib/libssl/man/SSL_get_ex_new_index.3 | 10 +- lib/libssl/man/SSL_get_fd.3 | 6 +- lib/libssl/man/SSL_get_peer_cert_chain.3 | 6 +- lib/libssl/man/SSL_get_peer_certificate.3 | 6 +- lib/libssl/man/SSL_get_rbio.3 | 6 +- lib/libssl/man/SSL_get_session.3 | 6 +- lib/libssl/man/SSL_get_shared_ciphers.3 | 6 +- lib/libssl/man/SSL_get_state.3 | 19 +- lib/libssl/man/SSL_get_verify_result.3 | 6 +- lib/libssl/man/SSL_get_version.3 | 6 +- lib/libssl/man/SSL_library_init.3 | 6 +- lib/libssl/man/SSL_load_client_CA_file.3 | 6 +- lib/libssl/man/SSL_new.3 | 6 +- lib/libssl/man/SSL_pending.3 | 6 +- lib/libssl/man/SSL_read.3 | 9 +- lib/libssl/man/SSL_renegotiate.3 | 6 +- lib/libssl/man/SSL_rstate_string.3 | 6 +- lib/libssl/man/SSL_session_reused.3 | 6 +- lib/libssl/man/SSL_set_bio.3 | 6 +- lib/libssl/man/SSL_set_connect_state.3 | 6 +- lib/libssl/man/SSL_set_fd.3 | 12 +- lib/libssl/man/SSL_set_session.3 | 6 +- lib/libssl/man/SSL_set_shutdown.3 | 6 +- lib/libssl/man/SSL_set_verify_result.3 | 6 +- lib/libssl/man/SSL_shutdown.3 | 6 +- lib/libssl/man/SSL_state_string.3 | 6 +- lib/libssl/man/SSL_want.3 | 14 +- lib/libssl/man/SSL_write.3 | 6 +- lib/libssl/man/d2i_SSL_SESSION.3 | 38 +- lib/libssl/s3_cbc.c | 8 +- lib/libssl/s3_lib.c | 169 +-- lib/libssl/shlib_version | 2 +- lib/libssl/ssl.h | 28 +- lib/libssl/ssl3.h | 6 +- lib/libssl/ssl_asn1.c | 69 +- lib/libssl/ssl_both.c | 6 +- lib/libssl/ssl_cert.c | 4 +- lib/libssl/ssl_ciph.c | 132 +- lib/libssl/ssl_clnt.c | 322 ++--- lib/libssl/ssl_init.c | 1 + lib/libssl/ssl_lib.c | 120 +- lib/libssl/ssl_locl.h | 66 +- lib/libssl/ssl_pkt.c | 11 +- lib/libssl/ssl_rsa.c | 24 +- lib/libssl/ssl_sess.c | 28 +- lib/libssl/ssl_srvr.c | 938 ++++++-------- lib/libssl/ssl_tlsext.c | 10 +- lib/libssl/t1_clnt.c | 22 +- lib/libssl/t1_enc.c | 98 +- lib/libssl/t1_hash.c | 10 +- lib/libssl/t1_lib.c | 104 +- lib/libssl/t1_meth.c | 22 +- lib/libssl/t1_srvr.c | 22 +- lib/libtls/man/tls_accept_socket.3 | 6 +- lib/libtls/man/tls_conn_version.3 | 8 +- lib/libtls/man/tls_connect.3 | 12 +- lib/libtls/man/tls_init.3 | 8 +- lib/libtls/man/tls_load_file.3 | 6 +- lib/libtls/man/tls_ocsp_process_response.3 | 63 +- lib/libtls/shlib_version | 2 +- lib/libtls/tls.c | 5 +- lib/libtls/tls_config.c | 2 +- lib/libtls/tls_internal.h | 3 +- lib/libtls/tls_keypair.c | 37 +- usr/src/pkg/manifests/library-libressl.inc | 49 +- 510 files changed, 8683 insertions(+), 7094 deletions(-) create mode 100644 lib/libcrypto/man/ASN1_INTEGER_get.3 create mode 100644 lib/libcrypto/man/ENGINE_add.3 create mode 100644 lib/libcrypto/man/ENGINE_ctrl.3 create mode 100644 lib/libcrypto/man/ENGINE_get_default_RSA.3 create mode 100644 lib/libcrypto/man/ENGINE_init.3 create mode 100644 lib/libcrypto/man/ENGINE_new.3 create mode 100644 lib/libcrypto/man/ENGINE_register_RSA.3 create mode 100644 lib/libcrypto/man/ENGINE_register_all_RSA.3 create mode 100644 lib/libcrypto/man/ENGINE_set_RSA.3 create mode 100644 lib/libcrypto/man/ENGINE_set_default.3 create mode 100644 lib/libcrypto/man/ENGINE_set_flags.3 create mode 100644 lib/libcrypto/man/ENGINE_unregister_RSA.3 rewrite lib/libcrypto/man/X25519.3 (97%) delete mode 100644 lib/libcrypto/man/engine.3 diff --git a/bin/nc/nc.1 b/bin/nc/nc.1 index e10d385a14..2c84a0972f 100644 --- a/bin/nc/nc.1 +++ b/bin/nc/nc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.88 2017/11/28 16:59:10 jsing Exp $ +.\" $OpenBSD: nc.1,v 1.91 2018/09/25 20:05:07 jmc Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: November 28 2017 $ +.Dd $Mdocdate: September 25 2018 $ .Dt NC 1 .Os .Sh NAME @@ -96,27 +96,31 @@ and much, much more The options are as follows: .Bl -tag -width Ds .It Fl 4 -Forces -.Nm -to use IPv4 addresses only. +Use IPv4 addresses only. .It Fl 6 -Forces -.Nm -to use IPv6 addresses only. +Use IPv6 addresses only. .It Fl C Ar certfile -Specifies the filename from which the public key part of the TLS -certificate is loaded, in PEM format. -May only be used with TLS. +Load the public key part of the TLS peer certificate from +.Ar certfile , +in PEM format. +Requires +.Fl c . .It Fl c -If using a TCP socket to connect or listen, use TLS. -Illegal if not using TCP sockets. +Use TLS to connect or listen. +Cannot be used together with any of the options +.Fl FuU . .It Fl D Enable debugging on the socket. .It Fl d Do not attempt to read from stdin. .It Fl e Ar name -Specify the name that must be present in the peer certificate when using TLS. -Illegal if not using TLS. +Only accept the TLS peer certificate if it contains the +.Ar name . +Requires +.Fl c . +If not specified, +.Ar destination +is used. .It Fl F Pass the first connected socket using .Xr sendmsg 2 @@ -132,47 +136,49 @@ using the .Xr ssh_config 5 .Cm ProxyUseFdpass option). +Cannot be used with +.Fl c +or +.Fl U . .It Fl H Ar hash -Specifies the required hash string of the peer certificate when using TLS. -The string format required is that used by -.Xr tls_peer_cert_hash 3 . -Illegal if not using TLS, and may not be used with -T noverify. +Only accept the TLS peer certificate if its hash returned from +.Xr tls_peer_cert_hash 3 +matches +.Ar hash . +Requires +.Fl c +and cannot be used with +.Fl T Cm noverify . .It Fl h -Prints out +Print out the .Nm -help. +help text and exit. .It Fl I Ar length -Specifies the size of the TCP receive buffer. +Specify the size of the TCP receive buffer. .It Fl i Ar interval -Specifies a delay time interval between lines of text sent and received. +Sleep for +.Ar interval +seconds between lines of text sent and received. Also causes a delay time between connections to multiple ports. .It Fl K Ar keyfile -Specifies the filename from which the private key -is loaded in PEM format. -May only be used with TLS. +Load the TLS private key from +.Ar keyfile , +in PEM format. +Requires +.Fl c . .It Fl k -Forces -.Nm -to stay listening for another connection after its current connection -is completed. -It is an error to use this option without the -.Fl l -option. +When a connection is completed, listen for another one. +Requires +.Fl l . When used together with the .Fl u option, the server socket is not connected and it can receive UDP datagrams from multiple hosts. .It Fl l -Used to specify that -.Nm -should listen for an incoming connection rather than initiate a +Listen for an incoming connection rather than initiating a connection to a remote host. -It is an error to use this option in conjunction with the -.Fl p , -.Fl s , -or -.Fl z -options. +Cannot be used together with any of the options +.Fl psxz . Additionally, any timeouts specified with the .Fl w option are ignored. @@ -189,97 +195,111 @@ Some servers require this to finish their work. Do not do any DNS or service lookups on any specified addresses, hostnames or ports. .It Fl O Ar length -Specifies the size of the TCP send buffer. +Specify the size of the TCP send buffer. .It Fl o Ar staplefile -Specifies the filename from which to load data to be stapled -during the TLS handshake. -The file is expected to contain an OCSP response from an OCSP server in +During the TLS handshake, load data to be stapled from +.Ar staplefile , +which is expected to contain an OCSP response from an OCSP server in DER format. -May only be used with TLS and when a certificate is being used. +Requires +.Fl c +and +.Fl C . .It Fl P Ar proxy_username Specifies a username to present to a proxy server that requires authentication. If no username is specified then authentication will not be attempted. Proxy authentication is only supported for HTTP CONNECT proxies at present. .It Fl p Ar source_port -Specifies the source port +Specify the source port .Nm should use, subject to privilege restrictions and availability. -It is an error to use this option in conjunction with the -.Fl l -option. +Cannot be used together with +.Fl l . .It Fl R Ar CAfile -Specifies the filename from which the root CA bundle for certificate -verification is loaded, in PEM format. -Illegal if not using TLS. -The default is +Load the root CA bundle for TLS certificate verification from +.Ar CAfile , +in PEM format, instead of .Pa /etc/ssl/cert.pem . +Requires +.Fl c . .It Fl r -Specifies that source and/or destination ports should be chosen randomly +Choose source and/or destination ports randomly instead of sequentially within a range or in the order that the system assigns them. .It Fl S -Enables the RFC 2385 TCP MD5 signature option. +Enable the RFC 2385 TCP MD5 signature option. .It Fl s Ar source -Specifies the IP of the interface which is used to send the packets. +Send packets from the interface with the +.Ar source +IP address. For .Ux Ns -domain datagram sockets, specifies the local temporary socket file to create and use so that datagrams can be received. -It is an error to use this option in conjunction with the +Cannot be used together with .Fl l -option. +or +.Fl x . .It Fl T Ar keyword -Change IPv4 TOS value or TLS options. -For TLS options +Change the IPv4 TOS/IPv6 traffic class value or the TLS options. +.Pp +For TLS options, .Ar keyword may be one of: -.Ar noverify , +.Cm noverify , which disables certificate verification; -.Ar noname , +.Cm noname , which disables certificate name checking; -.Ar clientcert , +.Cm clientcert , which requires a client certificate on incoming connections; or -.Ar muststaple , +.Cm muststaple , which requires the peer to provide a valid stapled OCSP response with the handshake. -The following TLS options specify a value in the form of a key=value pair: -.Ar ciphers , +The following TLS options specify a value in the form of a +.Ar key Ns = Ns Ar value +pair: +.Cm ciphers , which allows the supported TLS ciphers to be specified (see .Xr tls_config_set_ciphers 3 for further details); -.Ar protocols , +.Cm protocols , which allows the supported TLS protocols to be specified (see .Xr tls_config_parse_protocols 3 for further details). -It is illegal to specify TLS options if not using TLS. +Specifying TLS options requires +.Fl c . .Pp -For IPv4 TOS value +For the IPv4 TOS/IPv6 traffic class value, .Ar keyword may be one of -.Ar critical , -.Ar inetcontrol , -.Ar lowdelay , -.Ar netcontrol , -.Ar throughput , -.Ar reliability , +.Cm critical , +.Cm inetcontrol , +.Cm lowdelay , +.Cm netcontrol , +.Cm throughput , +.Cm reliability , or one of the DiffServ Code Points: -.Ar ef , -.Ar af11 ... af43 , -.Ar cs0 ... cs7 ; +.Cm ef , +.Cm af11 No ... Cm af43 , +.Cm cs0 No ... Cm cs7 ; or a number in either hex or decimal. .It Fl t -Causes -.Nm -to send RFC 854 DON'T and WON'T responses to RFC 854 DO and WILL requests. +Send RFC 854 DON'T and WON'T responses to RFC 854 DO and WILL requests. This makes it possible to use .Nm to script telnet sessions. .It Fl U -Specifies to use +Use .Ux Ns -domain sockets. +Cannot be used together with any of the options +.Fl cFx . .It Fl u -Use UDP instead of the default option of TCP. +Use UDP instead of TCP. +Cannot be used together with +.Fl c +or +.Fl x . For .Ux Ns -domain sockets, use a datagram socket instead of a stream socket. @@ -293,9 +313,7 @@ flag is given. .It Fl V Ar rtable Set the routing table to be used. .It Fl v -Have -.Nm -give more verbose output. +Produce more verbose output. .It Fl W Ar recvlimit Terminate after receiving .Ar recvlimit @@ -315,22 +333,20 @@ will listen forever for a connection, with or without the flag. The default is no timeout. .It Fl X Ar proxy_protocol -Requests that -.Nm -should use the specified protocol when talking to the proxy server. +Use +.Ar proxy_protocol +when talking to the proxy server. Supported protocols are -.Dq 4 +.Cm 4 (SOCKS v.4), -.Dq 5 +.Cm 5 (SOCKS v.5) and -.Dq connect +.Cm connect (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used. .It Fl x Ar proxy_address Ns Op : Ns Ar port -Requests that -.Nm -should connect to +Connect to .Ar destination using a proxy at .Ar proxy_address @@ -343,17 +359,18 @@ for SOCKS, 3128 for HTTPS). An IPv6 address can be specified unambiguously by enclosing .Ar proxy_address in square brackets. +A proxy cannot be used with any of the options +.Fl lsuU . .It Fl Z Ar peercertfile -Specifies the filename in which the peer supplied certificates will be saved +Save the peer certificates to +.Ar peercertfile , in PEM format. -May only be used with TLS. +Requires +.Fl c . .It Fl z -Specifies that -.Nm -should just scan for listening daemons, without sending any data to them. -It is an error to use this option in conjunction with the -.Fl l -option. +Only scan for listening daemons, without sending any data to them. +Cannot be used together with +.Fl l . .El .Pp .Ar destination @@ -375,7 +392,8 @@ option is given). .Pp .Ar port can be a specified as a numeric port number, or as a service name. -Ports may be specified in a range of the form nn-mm. +Ports may be specified in a range of the form +.Ar nn Ns - Ns Ar mm . In general, a destination port must be specified, unless the @@ -548,8 +566,8 @@ if the proxy requires it: .Xr cat 1 , .Xr ssh 1 .Sh AUTHORS -Original implementation by *Hobbit* -.Aq Mt hobbit@avian.org . +Original implementation by +.An *Hobbit* Aq Mt hobbit@avian.org . .br Rewritten with IPv6 support by .An Eric Jackson Aq Mt ericj@monkey.org . diff --git a/bin/nc/netcat.c b/bin/nc/netcat.c index 51c846ba05..45e4dbcdce 100644 --- a/bin/nc/netcat.c +++ b/bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.190 2018/03/19 16:35:29 jsing Exp $ */ +/* $OpenBSD: netcat.c,v 1.195 2018/10/04 17:04:50 bluhm Exp $ */ /* * Copyright (c) 2001 Eric Jackson * Copyright (c) 2015 Bob Beck. All rights reserved. @@ -126,7 +126,7 @@ void atelnet(int, unsigned char *, unsigned int); int strtoport(char *portstr, int udp); void build_ports(char *); void help(void) __attribute__((noreturn)); -int local_listen(char *, char *, struct addrinfo); +int local_listen(const char *, const char *, struct addrinfo); void readwrite(int, struct tls *); void fdpass(int nfd) __attribute__((noreturn)); int remote_connect(const char *, const char *, struct addrinfo); @@ -359,13 +359,51 @@ main(int argc, char *argv[]) err(1, "setrtable"); #endif + /* Cruft to make sure options are clean, and used properly. */ + if (argv[0] && !argv[1] && family == AF_UNIX) { + host = argv[0]; + uport = NULL; + } else if (argv[0] && !argv[1]) { + if (!lflag) + usage(1); + uport = argv[0]; + host = NULL; + } else if (argv[0] && argv[1]) { + host = argv[0]; + uport = argv[1]; + } else + usage(1); + + if (usetls) { + if (Cflag && unveil(Cflag, "r") == -1) + err(1, "unveil"); + if (unveil(Rflag, "r") == -1) + err(1, "unveil"); + if (Kflag && unveil(Kflag, "r") == -1) + err(1, "unveil"); + if (oflag && unveil(oflag, "r") == -1) + err(1, "unveil"); + } else { + if (family == AF_UNIX) { + if (unveil(host, "rwc") == -1) + err(1, "unveil"); + if (uflag && !lflag) { + if (unveil(sflag ? sflag : "/tmp", "rwc") == -1) + err(1, "unveil"); + } + } else { + if (unveil("/", "") == -1) + err(1, "unveil"); + } + } + if (family == AF_UNIX) { if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1) err(1, "pledge"); } else if (Fflag && Pflag) { if (pledge("stdio inet dns sendfd tty", NULL) == -1) err(1, "pledge"); - } else if (Fflag) { + } else if (Fflag) { if (pledge("stdio inet dns sendfd", NULL) == -1) err(1, "pledge"); } else if (Pflag && usetls) { @@ -380,21 +418,6 @@ main(int argc, char *argv[]) } else if (pledge("stdio inet dns", NULL) == -1) err(1, "pledge"); - /* Cruft to make sure options are clean, and used properly. */ - if (argv[0] && !argv[1] && family == AF_UNIX) { - host = argv[0]; - uport = NULL; - } else if (argv[0] && !argv[1]) { - if (!lflag) - usage(1); - uport = argv[0]; - host = NULL; - } else if (argv[0] && argv[1]) { - host = argv[0]; - uport = argv[1]; - } else - usage(1); - if (lflag && sflag) errx(1, "cannot use -s and -l"); if (lflag && pflag) @@ -530,8 +553,6 @@ main(int argc, char *argv[]) err(1, "pledge"); } if (lflag) { - struct tls *tls_cctx = NULL; - int connfd; ret = 0; if (family == AF_UNIX) { @@ -551,8 +572,11 @@ main(int argc, char *argv[]) } /* Allow only one connection at a time, but stay alive. */ for (;;) { - if (family != AF_UNIX) + if (family != AF_UNIX) { + if (s != -1) + close(s); s = local_listen(host, uport, hints); + } if (s < 0) err(1, NULL); if (uflag && kflag) { @@ -587,6 +611,9 @@ main(int argc, char *argv[]) readwrite(s, NULL); } else { + struct tls *tls_cctx = NULL; + int connfd; + len = sizeof(cliaddr); connfd = accept4(s, (struct sockaddr *)&cliaddr, &len, SOCK_NONBLOCK); @@ -602,16 +629,12 @@ main(int argc, char *argv[]) readwrite(connfd, tls_cctx); if (!usetls) readwrite(connfd, NULL); - if (tls_cctx) { + if (tls_cctx) timeout_tls(s, tls_cctx, tls_close); - tls_free(tls_cctx); - tls_cctx = NULL; - } close(connfd); + tls_free(tls_cctx); } - if (family != AF_UNIX) - close(s); - else if (uflag) { + if (family == AF_UNIX && uflag) { if (connect(s, NULL, 0) < 0) err(1, "connect"); } @@ -643,6 +666,8 @@ main(int argc, char *argv[]) for (s = -1, i = 0; portlist[i] != NULL; i++) { if (s != -1) close(s); + tls_free(tls_ctx); + tls_ctx = NULL; if (usetls) { if ((tls_ctx = tls_client()) == NULL) @@ -693,18 +718,15 @@ main(int argc, char *argv[]) tls_setup_client(tls_ctx, s, host); if (!zflag) readwrite(s, tls_ctx); - if (tls_ctx) { + if (tls_ctx) timeout_tls(s, tls_ctx, tls_close); - tls_free(tls_ctx); - tls_ctx = NULL; - } } } } if (s != -1) close(s); - + tls_free(tls_ctx); tls_config_free(tls_cfg); return ret; @@ -985,7 +1007,7 @@ timeout_connect(int s, const struct sockaddr *name, socklen_t namelen) * address. Returns -1 on failure. */ int -local_listen(char *host, char *port, struct addrinfo hints) +local_listen(const char *host, const char *port, struct addrinfo hints) { struct addrinfo *res, *res0; int s = -1, save_errno; diff --git a/bin/nc/socks.c b/bin/nc/socks.c index c9aa5178c5..5aa191d284 100644 --- a/bin/nc/socks.c +++ b/bin/nc/socks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: socks.c,v 1.24 2016/06/27 14:43:04 deraadt Exp $ */ +/* $OpenBSD: socks.c,v 1.25 2018/03/27 16:31:10 deraadt Exp $ */ /* * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. @@ -109,17 +109,16 @@ proxy_read_line(int fd, char *buf, size_t bufsz) return (off); } -static const char * -getproxypass(const char *proxyuser, const char *proxyhost) +static void +getproxypass(const char *proxyuser, const char *proxyhost, + char *pw, size_t pwlen) { char prompt[512]; - static char pw[256]; snprintf(prompt, sizeof(prompt), "Proxy password for %s@%s: ", proxyuser, proxyhost); - if (readpassphrase(prompt, pw, sizeof(pw), RPP_REQUIRE_TTY) == NULL) + if (readpassphrase(prompt, pw, pwlen, RPP_REQUIRE_TTY) == NULL) errx(1, "Unable to read proxy passphrase"); - return (pw); } /* @@ -188,7 +187,6 @@ socks_connect(const char *host, const char *port, struct sockaddr_in *in4 = (struct sockaddr_in *)&addr; struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&addr; in_port_t serverport; - const char *proxypass = NULL; if (proxyport == NULL) proxyport = (socksv == -1) ? HTTP_PROXY_PORT : SOCKS_PORT; @@ -345,11 +343,14 @@ socks_connect(const char *host, const char *port, err(1, "write failed (%zu/%d)", cnt, r); if (authretry > 1) { + char proxypass[256]; char resp[1024]; - proxypass = getproxypass(proxyuser, proxyhost); + getproxypass(proxyuser, proxyhost, + proxypass, sizeof proxypass); r = snprintf(buf, sizeof(buf), "%s:%s", proxyuser, proxypass); + explicit_bzero(proxypass, sizeof proxypass); if (r == -1 || (size_t)r >= sizeof(buf) || b64_ntop(buf, strlen(buf), resp, sizeof(resp)) == -1) @@ -361,6 +362,8 @@ socks_connect(const char *host, const char *port, r = strlen(buf); if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) err(1, "write failed (%zu/%d)", cnt, r); + explicit_bzero(proxypass, sizeof proxypass); + explicit_bzero(buf, sizeof buf); } /* Terminate headers */ diff --git a/bin/openssl/apps.c b/bin/openssl/apps.c index 90baf65a9f..3febc15d2b 100644 --- a/bin/openssl/apps.c +++ b/bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.47 2018/02/07 08:57:25 jsing Exp $ */ +/* $OpenBSD: apps.c,v 1.49 2018/08/16 16:56:51 tb Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -2065,7 +2065,8 @@ policies_print(BIO *out, X509_STORE_CTX *ctx) nodes_print(out, "Authority", X509_policy_tree_get0_policies(tree)); nodes_print(out, "User", X509_policy_tree_get0_user_policies(tree)); - BIO_free(out); + if (free_out) + BIO_free(out); } /* diff --git a/bin/openssl/apps.h b/bin/openssl/apps.h index d02169b8aa..cfc6036ccf 100644 --- a/bin/openssl/apps.h +++ b/bin/openssl/apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.h,v 1.20 2017/12/05 15:02:06 jca Exp $ */ +/* $OpenBSD: apps.h,v 1.21 2018/07/13 18:36:56 cheloha Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -277,10 +277,10 @@ unsigned char *next_protos_parse(unsigned short *outlen, const char *in); int app_isdir(const char *); -#define TM_START 0 -#define TM_STOP 1 -double app_timer_real(int stop); -double app_timer_user(int stop); +#define TM_RESET 0 +#define TM_GET 1 +double app_timer_real(int); +double app_timer_user(int); #define OPENSSL_NO_SSL_INTERN diff --git a/bin/openssl/apps_posix.c b/bin/openssl/apps_posix.c index 502919c0a2..cdcf821366 100644 --- a/bin/openssl/apps_posix.c +++ b/bin/openssl/apps_posix.c @@ -124,13 +124,13 @@ #include "apps.h" double -app_timer_real(int stop) +app_timer_real(int get) { static struct timespec start; struct timespec elapsed, now; clock_gettime(CLOCK_MONOTONIC, &now); - if (stop) { + if (get) { timespecsub(&now, &start, &elapsed); return elapsed.tv_sec + elapsed.tv_nsec / 1000000000.0; } @@ -139,14 +139,14 @@ app_timer_real(int stop) } double -app_timer_user(int stop) +app_timer_user(int get) { static struct timeval start; struct timeval elapsed; struct rusage now; getrusage(RUSAGE_SELF, &now); - if (stop) { + if (get) { timersub(&now.ru_utime, &start, &elapsed); return elapsed.tv_sec + elapsed.tv_usec / 1000000.0; } diff --git a/bin/openssl/openssl.1 b/bin/openssl/openssl.1 index ce01e06a84..6bd2ee7d5f 100644 --- a/bin/openssl/openssl.1 +++ b/bin/openssl/openssl.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: openssl.1,v 1.89 2018/03/22 19:24:18 jmc Exp $ +.\" $OpenBSD: openssl.1,v 1.94 2018/08/24 20:12:24 tb Exp $ .\" ==================================================================== .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. .\" @@ -110,9 +110,7 @@ .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" -.\" OPENSSL -.\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: August 24 2018 $ .Dt OPENSSL 1 .Os .Sh NAME @@ -120,7 +118,7 @@ .Nd OpenSSL command line tool .Sh SYNOPSIS .Nm -.Cm command +.Ar command .Op Ar command_opts .Op Ar command_args .Pp @@ -302,6 +300,7 @@ into a nested structure. .Op Fl batch .Op Fl cert Ar file .Op Fl config Ar file +.Op Fl create_serial .Op Fl crl_CA_compromise Ar time .Op Fl crl_compromise Ar time .Op Fl crl_hold Ar instruction @@ -316,11 +315,12 @@ into a nested structure. .Op Fl gencrl .Op Fl in Ar file .Op Fl infiles -.Op Fl key Ar keyfile +.Op Fl key Ar password .Op Fl keyfile Ar arg -.Op Fl keyform Ar pem +.Op Fl keyform Cm pem | der .Op Fl md Ar arg .Op Fl msie_hack +.Op Fl multivalue\-rdn .Op Fl name Ar section .Op Fl noemailDN .Op Fl notext @@ -330,12 +330,14 @@ into a nested structure. .Op Fl policy Ar arg .Op Fl preserveDN .Op Fl revoke Ar file +.Op Fl selfsign .Op Fl spkac Ar file .Op Fl ss_cert Ar file .Op Fl startdate Ar date .Op Fl status Ar serial .Op Fl subj Ar arg .Op Fl updatedb +.Op Fl utf8 .Op Fl verbose .nr nS 0 .Pp @@ -356,6 +358,10 @@ and all certificates will be certified automatically. The CA certificate file. .It Fl config Ar file Specify an alternative configuration file. +.It Fl create_serial +If reading the serial from the text file as specified in the +configuration fails, create a new random serial to be used as the +next serial number. .It Fl days Ar arg The number of days to certify the certificate for. .It Fl enddate Ar date @@ -373,6 +379,9 @@ If no extension section is present, a V1 certificate is created. If the extension section is present .Pq even if it is empty , then a V3 certificate is created. +See the +.Xr x509v3.cnf 5 +manual page for details of the extension section format. .It Fl extfile Ar file An additional configuration .Ar file @@ -387,14 +396,18 @@ containing a single certificate request to be signed by the CA. .It Fl infiles If present, this should be the last option; all subsequent arguments are assumed to be the names of files containing certificate requests. -.It Fl key Ar keyfile -The password used to encrypt the private key. +.It Fl key Ar password +The +.Fa password +used to encrypt the private key. Since on some systems the command line arguments are visible, this option should be used with caution. .It Fl keyfile Ar file The private key to sign requests with. -.It Fl keyform Ar pem +.It Fl keyform Cm pem | der Private key file format. +The default is +.Cm pem . .It Fl md Ar alg The message digest to use. Possible values include @@ -413,6 +426,16 @@ its use is strongly discouraged. The newer control .Qq Xenroll does not need this option. +.It Fl multivalue\-rdn +This option causes the +.Fl subj +argument to be interpreted with full support for multivalued RDNs, +for example +.Qq "/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe" . +If +.Fl multivalue\-rdn +is not used, the UID value is set to +.Qq "123456+CN=John Doe" . .It Fl name Ar section Specifies the configuration file .Ar section @@ -437,7 +460,10 @@ Don't output the text form of a certificate to the output file. .It Fl out Ar file The output file to output certificates to. The default is standard output. -The certificate details will also be printed out to this file. +The certificate details will also be printed out to this file in +PEM format, except that +.Fl spkac +outputs DER format. .It Fl outdir Ar directory The .Ar directory @@ -474,6 +500,27 @@ This is largely for compatibility with the older IE enrollment control which would only accept certificates if their DNs matched the order of the request. This is not needed for Xenroll. +.It Fl selfsign +Indicates the issued certificates are to be signed with the key the +certificate requests were signed with, given with +.Fl keyfile . +Certificate requests signed with a different key are ignored. +If +.Fl gencrl , +.Fl spkac , +or +.Fl ss_cert +are given, +.Fl selfsign +is ignored. +.Pp +A consequence of using +.Fl selfsign +is that the self-signed certificate appears among the entries in +the certificate database (see the configuration option +.Cm database ) +and uses the same serial number counter as all other certificates +signed with the self-signed certificate. .It Fl spkac Ar file A file containing a single Netscape signed public key and challenge, and additional field values to be signed by the CA. @@ -494,11 +541,23 @@ A single self-signed certificate to be signed by the CA. Set the start date. The format of the date is [YY]YYMMDDHHMMSSZ, with all four year digits required for dates from 2050 onwards. -.It Fl status Ar serial -Show the status of the certificate with serial number -.Ar serial . -.It Fl updatedb -Update database for expired certificates. +.It Fl subj Ar arg +Supersedes the subject name given in the request. +The +.Ar arg +must be formatted as +.Sm off +.Pf / Ar type0 Ns = Ar value0 Ns / Ar type 1 Ns = Ar value 1 Ns / +.Ar type2 Ns = Ar ... ; +.Sm on +characters may be escaped by +.Sq \e +.Pq backslash , +no spaces are skipped. +.It Fl utf8 +Interpret field values read from a terminal or obtained from a +configuration file as UTF-8 strings. +By default, they are interpreted as ASCII. .It Fl verbose Print extra details about the operations being performed. .El @@ -549,6 +608,9 @@ if the CRL extension section is present then a V2 CRL is created. The CRL extensions specified are CRL extensions and not CRL entry extensions. It should be noted that some software can't handle V2 CRLs. +See the +.Xr x509v3.cnf 5 +manual page for details of the extension section format. .It Fl crlhours Ar num The number of hours before the next CRL is due. .It Fl gencrl @@ -557,16 +619,11 @@ Generate a CRL based on information in the index file. A .Ar file containing a certificate to revoke. -.It Fl subj Ar arg -Supersedes the subject name given in the request. -The -.Ar arg -must be formatted as -.Ar /type0=value0/type1=value1/type2=... ; -characters may be escaped by -.Sq \e -.Pq backslash , -no spaces are skipped. +.It Fl status Ar serial +Show the status of the certificate with serial number +.Ar serial . +.It Fl updatedb +Update the database index to purge expired certificates. .El .Pp Many of the options can be set in the @@ -625,7 +682,7 @@ extension with CA:TRUE and the value is set to .Cm copyall and the user does not spot -this when the certificate is displayed, then this will hand the requestor +this when the certificate is displayed, then this will hand the requester a valid CA certificate. .Pp This situation can be avoided by setting @@ -780,170 +837,34 @@ The same as .Sh CIPHERS .Nm openssl ciphers .Op Fl hVv -.Op Fl tls1 -.Op Ar cipherlist +.Op Ar control .Pp The .Nm ciphers -command converts -.Nm openssl -cipher lists into ordered SSL cipher preference lists. -It can be used as a way to determine the appropriate cipher list. +command converts the +.Ar control +string from the format documented in +.Xr SSL_CTX_set_cipher_list 3 +into an ordered SSL cipher suite preference list. +If no +.Ar control +string is specified, the +.Cm DEFAULT +list is printed. .Pp The options are as follows: .Bl -tag -width Ds .It Fl h , \&? Print a brief usage message. -.It Fl tls1 -Only include TLS v1 ciphers. .It Fl V Verbose. -List ciphers with a complete description of protocol version, -key exchange, authentication, encryption and mac algorithms, -any key size restrictions, -and cipher suite codes (hex format). +List ciphers with cipher suite code in hex format, +cipher name, and a complete description of protocol version, +key exchange, authentication, encryption, and mac algorithms. .It Fl v Like .Fl V , but without cipher suite codes. -.It Ar cipherlist -A cipher list to convert to a cipher preference list. -If it is not included, the default cipher list will be used. -.Pp -The cipher list consists of one or more cipher strings -separated by colons. -Commas or spaces are also acceptable separators, but colons are normally used. -.Pp -The actual cipher string can take several different forms: -.Pp -It can consist of a single cipher suite, such as RC4-SHA. -.Pp -It can represent a list of cipher suites containing a certain algorithm, -or cipher suites of a certain type. -For example SHA1 represents all cipher suites using the digest algorithm SHA1. -.Pp -Lists of cipher suites can be combined in a single cipher string using the -.Sq + -character -(logical AND operation). -For example, SHA1+DES represents all cipher suites -containing the SHA1 and DES algorithms. -.Pp -Each cipher string can be optionally preceded by the characters -.Sq \&! , -.Sq - , -or -.Sq + . -If -.Sq !\& -is used, then the ciphers are permanently deleted from the list. -The ciphers deleted can never reappear in the list even if they are -explicitly stated. -If -.Sq - -is used, then the ciphers are deleted from the list, but some or -all of the ciphers can be added again by later options. -If -.Sq + -is used, then the ciphers are moved to the end of the list. -This option doesn't add any new ciphers, it just moves matching existing ones. -.Pp -If none of these characters is present, the string is just interpreted -as a list of ciphers to be appended to the current preference list. -If the list includes any ciphers already present, they will be ignored; -that is, they will not be moved to the end of the list. -.Pp -Additionally, the cipher string -.Cm @STRENGTH -can be used at any point to sort the current cipher list in order of -encryption algorithm key length. -.El -.Pp -The following is a list of all permitted cipher strings and their meanings. -.Bl -tag -width "XXXX" -.It Cm DEFAULT -The default cipher list. -This is determined at compile time and is currently -.Cm ALL:!aNULL:!eNULL:!SSLv2 . -This must be the first cipher string specified. -.It Cm COMPLEMENTOFDEFAULT -The ciphers included in -.Cm ALL , -but not enabled by default. -Currently this is -.Cm ADH . -Note that this rule does not cover -.Cm eNULL , -which is not included by -.Cm ALL -(use -.Cm COMPLEMENTOFALL -if necessary). -.It Cm ALL -All cipher suites except the -.Cm eNULL -ciphers, which must be explicitly enabled. -.It Cm COMPLEMENTOFALL -The cipher suites not enabled by -.Cm ALL , -currently being -.Cm eNULL . -.It Cm HIGH -.Qq High -encryption cipher suites. -This currently means those with key lengths larger than 128 bits. -.It Cm MEDIUM -.Qq Medium -encryption cipher suites, currently those using 128-bit encryption. -.It Cm LOW -.Qq Low -encryption cipher suites, currently those using 64- or 56-bit encryption -algorithms. -.It Cm eNULL , NULL -The -.Qq NULL -ciphers; that is, those offering no encryption. -Because these offer no encryption at all and are a security risk, -they are disabled unless explicitly included. -.It Cm aNULL -The cipher suites offering no authentication. -This is currently the anonymous DH algorithms. -These cipher suites are vulnerable to a -.Qq man in the middle -attack, so their use is normally discouraged. -.It Cm kRSA , RSA -Cipher suites using RSA key exchange. -.It Cm kEDH -Cipher suites using ephemeral DH key agreement. -.It Cm aRSA -Cipher suites using RSA authentication, i.e. the certificates carry RSA keys. -.It Cm aDSS , DSS -Cipher suites using DSS authentication, i.e. the certificates carry DSS keys. -.It Cm TLSv1 -TLS v1.0 cipher suites. -.It Cm DH -Cipher suites using DH, including anonymous DH. -.It Cm ADH -Anonymous DH cipher suites. -.It Cm AES -Cipher suites using AES. -.It Cm 3DES -Cipher suites using triple DES. -.It Cm DES -Cipher suites using DES -.Pq not triple DES . -.It Cm RC4 -Cipher suites using RC4. -.It Cm CAMELLIA -Cipher suites using Camellia. -.It Cm CHACHA20 -Cipher suites using ChaCha20. -.It Cm IDEA -Cipher suites using IDEA. -.It Cm MD5 -Cipher suites using MD5. -.It Cm SHA1 , SHA -Cipher suites using SHA1. .El .Sh CRL .nr nS 1 @@ -2405,13 +2326,10 @@ Print certificate details in full rather than just subject and issuer names. .Sh PKCS8 .nr nS 1 .Nm "openssl pkcs8" -.Op Fl embed .Op Fl in Ar file .Op Fl inform Cm der | pem .Op Fl nocrypt .Op Fl noiter -.Op Fl nooct -.Op Fl nsdb .Op Fl out Ar file .Op Fl outform Cm der | pem .Op Fl passin Ar arg @@ -2433,13 +2351,6 @@ are more secure. .Pp The options are as follows: .Bl -tag -width Ds -.It Fl embed -Generate DSA keys in a broken format. -The DSA parameters are embedded inside the PrivateKey structure. -In this form the OCTET STRING contains an ASN.1 SEQUENCE consisting of -two structures: -a SEQUENCE containing the parameters and an ASN.1 INTEGER containing -the private key. .It Fl in Ar file The input file to read from, or standard input if not specified. @@ -2455,16 +2366,6 @@ Use an iteration count of 1. See the .Sx PKCS12 section below for a detailed explanation of this option. -.It Fl nooct -Generate RSA private keys in a broken format that some software uses. -Specifically the private key should be enclosed in an OCTET STRING, -but some software just includes the structure itself without the -surrounding OCTET STRING. -.It Fl nsdb -Generate DSA keys in a broken format compatible with Netscape -private key databases. -The PrivateKey contains a SEQUENCE -consisting of the public and private keys, respectively. .It Fl out Ar file The output file to write to, or standard output if none is specified. @@ -6054,6 +5955,8 @@ certificates. .Sh SEE ALSO .Xr acme-client 1 , .Xr nc 1 , +.Xr openssl.cnf 5 , +.Xr x509v3.cnf 5 , .Xr ssl 8 , .Xr starttls 8 .Sh STANDARDS diff --git a/bin/openssl/pkcs8.c b/bin/openssl/pkcs8.c index a0dac88772..7938bf8b09 100644 --- a/bin/openssl/pkcs8.c +++ b/bin/openssl/pkcs8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs8.c,v 1.11 2018/02/07 05:47:55 jsing Exp $ */ +/* $OpenBSD: pkcs8.c,v 1.13 2018/08/24 22:56:45 jmc Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999-2004. */ @@ -75,7 +75,6 @@ static struct { int nocrypt; char *outfile; int outformat; - int p8_broken; char *passargin; char *passargout; int pbe_nid; @@ -106,13 +105,6 @@ pkcs8_opt_v2(char *arg) static struct option pkcs8_options[] = { { - .name = "embed", - .desc = "Generate DSA keys in a broken format", - .type = OPTION_VALUE, - .value = PKCS8_EMBEDDED_PARAM, - .opt.value = &pkcs8_config.p8_broken, - }, - { .name = "in", .argname = "file", .desc = "Input file (default stdin)", @@ -121,8 +113,8 @@ static struct option pkcs8_options[] = { }, { .name = "inform", - .argname = "format", - .desc = "Input format (DER or PEM (default))", + .argname = "der | pem", + .desc = "Input format (default PEM)", .type = OPTION_ARG_FORMAT, .opt.value = &pkcs8_config.informat, }, @@ -140,20 +132,6 @@ static struct option pkcs8_options[] = { .opt.value = &pkcs8_config.iter, }, { - .name = "nooct", - .desc = "Generate RSA keys in a broken format (no octet)", - .type = OPTION_VALUE, - .value = PKCS8_NO_OCTET, - .opt.value = &pkcs8_config.p8_broken, - }, - { - .name = "nsdb", - .desc = "Generate DSA keys in the broken Netscape DB format", - .type = OPTION_VALUE, - .value = PKCS8_NS_DB, - .opt.value = &pkcs8_config.p8_broken, - }, - { .name = "out", .argname = "file", .desc = "Output file (default stdout)", @@ -162,8 +140,8 @@ static struct option pkcs8_options[] = { }, { .name = "outform", - .argname = "format", - .desc = "Output format (DER or PEM (default))", + .argname = "der | pem", + .desc = "Output format (default PEM)", .type = OPTION_ARG_FORMAT, .opt.value = &pkcs8_config.outformat, }, @@ -208,11 +186,10 @@ static struct option pkcs8_options[] = { static void pkcs8_usage() { - fprintf(stderr, "usage: pkcs8 [-embed] [-in file] " - "[-inform fmt] [-nocrypt]\n" - " [-noiter] [-nooct] [-nsdb] [-out file] [-outform fmt] " - "[-passin src]\n" - " [-passout src] [-topk8] [-v1 alg] [-v2 alg]\n\n"); + fprintf(stderr, "usage: pkcs8 [-in file] [inform der | pem] " + "[-nocrypt] [-noiter]\n" + " [-out file] [-outform der | pem] [-passin arg]\n" + " [-passout arg] [-topk8] [-v1 alg] [-v2 alg]\n\n"); options_usage(pkcs8_options); } @@ -238,7 +215,6 @@ pkcs8_main(int argc, char **argv) pkcs8_config.iter = PKCS12_DEFAULT_ITER; pkcs8_config.informat = FORMAT_PEM; pkcs8_config.outformat = FORMAT_PEM; - pkcs8_config.p8_broken = PKCS8_OK; pkcs8_config.pbe_nid = -1; if (options_parse(argc, argv, pkcs8_options, NULL, NULL) != 0) { @@ -278,8 +254,7 @@ pkcs8_main(int argc, char **argv) pkcs8_config.informat, 1, passin, "key"); if (!pkey) goto end; - if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, - pkcs8_config.p8_broken))) { + if (!(p8inf = EVP_PKEY2PKCS8(pkey))) { BIO_printf(bio_err, "Error converting key\n"); ERR_print_errors(bio_err); goto end; @@ -369,32 +344,6 @@ pkcs8_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (p8inf->broken) { - BIO_printf(bio_err, "Warning: broken key encoding: "); - switch (p8inf->broken) { - case PKCS8_NO_OCTET: - BIO_printf(bio_err, "No Octet String in PrivateKey\n"); - break; - - case PKCS8_EMBEDDED_PARAM: - BIO_printf(bio_err, - "DSA parameters included in PrivateKey\n"); - break; - - case PKCS8_NS_DB: - BIO_printf(bio_err, - "DSA public key include in PrivateKey\n"); - break; - - case PKCS8_NEG_PRIVKEY: - BIO_printf(bio_err, "DSA private key value is negative\n"); - break; - - default: - BIO_printf(bio_err, "Unknown broken type\n"); - break; - } - } if (pkcs8_config.outformat == FORMAT_PEM) PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, passout); diff --git a/bin/openssl/s_apps.h b/bin/openssl/s_apps.h index ecadff5c01..9ee0bb7dc1 100644 --- a/bin/openssl/s_apps.h +++ b/bin/openssl/s_apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: s_apps.h,v 1.4 2016/12/30 17:25:48 jsing Exp $ */ +/* $OpenBSD: s_apps.h,v 1.5 2018/04/25 07:12:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -147,5 +147,5 @@ void tlsext_cb(SSL *s, int client_server, int type, unsigned char *data, int generate_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len); -int verify_cookie_callback(SSL *ssl, unsigned char *cookie, +int verify_cookie_callback(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len); diff --git a/bin/openssl/s_cb.c b/bin/openssl/s_cb.c index b25118c030..835e99551b 100644 --- a/bin/openssl/s_cb.c +++ b/bin/openssl/s_cb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_cb.c,v 1.9 2018/01/15 11:02:07 inoguchi Exp $ */ +/* $OpenBSD: s_cb.c,v 1.10 2018/04/25 07:12:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -821,7 +821,8 @@ generate_cookie_callback(SSL * ssl, unsigned char *cookie, } int -verify_cookie_callback(SSL * ssl, unsigned char *cookie, unsigned int cookie_len) +verify_cookie_callback(SSL * ssl, const unsigned char *cookie, + unsigned int cookie_len) { unsigned char *buffer, result[EVP_MAX_MD_SIZE]; unsigned int length, resultlength; diff --git a/bin/openssl/s_socket.c b/bin/openssl/s_socket.c index d3aff1b3bb..62b32d3936 100644 --- a/bin/openssl/s_socket.c +++ b/bin/openssl/s_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_socket.c,v 1.9 2018/02/07 05:47:55 jsing Exp $ */ +/* $OpenBSD: s_socket.c,v 1.10 2018/08/19 20:07:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -276,11 +276,13 @@ do_accept(int acc_sock, int *sock, char **host) if (h2 == NULL) { BIO_printf(bio_err, "gethostbyname failure\n"); close(ret); + free(*host); return (0); } if (h2->h_addrtype != AF_INET) { BIO_printf(bio_err, "gethostbyname addr is not AF_INET\n"); close(ret); + free(*host); return (0); } } diff --git a/bin/openssl/s_time.c b/bin/openssl/s_time.c index ed89160b23..1506ca356a 100644 --- a/bin/openssl/s_time.c +++ b/bin/openssl/s_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_time.c,v 1.23 2018/02/07 05:47:55 jsing Exp $ */ +/* $OpenBSD: s_time.c,v 1.32 2018/09/17 15:37:35 cheloha Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -90,7 +90,9 @@ extern int verify_depth; static void s_time_usage(void); -static SSL *doConnection(SSL * scon); +static int run_test(SSL *); +static int benchmark(int); +static void print_tally_mark(SSL *); static SSL_CTX *tm_ctx = NULL; static const SSL_METHOD *s_time_meth = NULL; @@ -226,31 +228,13 @@ s_time_usage(void) } /*********************************************************************** - * TIME - time functions - */ -#define START 0 -#define STOP 1 - -static double -tm_Time_F(int op) -{ - return app_timer_user(op); -} - -/*********************************************************************** * MAIN - main processing area for client * real name depends on MONOLITH */ int s_time_main(int argc, char **argv) { - double totalTime = 0.0; - int nConn = 0; - SSL *scon = NULL; - time_t finishtime; int ret = 1; - char buf[1024 * 8]; - int ver; if (single_execution) { if (pledge("stdio rpath inet dns", NULL) == -1) { @@ -259,7 +243,7 @@ s_time_main(int argc, char **argv) } } - s_time_meth = SSLv23_client_method(); + s_time_meth = TLS_client_method(); verify_depth = 0; @@ -321,160 +305,24 @@ s_time_main(int argc, char **argv) /* goto end; */ } - if (!(s_time_config.perform & 1)) - goto next; - printf("Collecting connection statistics for %lld seconds\n", - (long long)s_time_config.maxtime); - /* Loop and time how long it takes to make connections */ - - bytes_read = 0; - finishtime = time(NULL) + s_time_config.maxtime; - tm_Time_F(START); - for (;;) { - if (finishtime < time(NULL)) - break; - if ((scon = doConnection(NULL)) == NULL) + if (s_time_config.perform & 1) { + printf("Collecting connection statistics for %lld seconds\n", + (long long)s_time_config.maxtime); + if (benchmark(0)) goto end; - - if (s_time_config.www_path != NULL) { - int i, retval = snprintf(buf, sizeof buf, - "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); - if ((size_t)retval >= sizeof buf) { - fprintf(stderr, "URL too long\n"); - goto end; - } - SSL_write(scon, buf, strlen(buf)); - while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) - bytes_read += i; - } - if (s_time_config.no_shutdown) - SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | - SSL_RECEIVED_SHUTDOWN); - else - SSL_shutdown(scon); - - nConn += 1; - if (SSL_session_reused(scon)) - ver = 'r'; - else { - ver = SSL_version(scon); - if (ver == TLS1_VERSION) - ver = 't'; - else if (ver == SSL3_VERSION) - ver = '3'; - else if (ver == SSL2_VERSION) - ver = '2'; - else - ver = '*'; - } - fputc(ver, stdout); - fflush(stdout); - - SSL_free(scon); - scon = NULL; } - totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ - - printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", - nConn, totalTime, ((double) nConn / totalTime), bytes_read); - printf("%d connections in %lld real seconds, %ld bytes read per connection\n", - nConn, - (long long)(time(NULL) - finishtime + s_time_config.maxtime), - bytes_read / nConn); - /* * Now loop and time connections using the same session id over and * over */ - - next: - if (!(s_time_config.perform & 2)) - goto end; - printf("\n\nNow timing with session id reuse.\n"); - - /* Get an SSL object so we can reuse the session id */ - if ((scon = doConnection(NULL)) == NULL) { - fprintf(stderr, "Unable to get connection\n"); - goto end; - } - if (s_time_config.www_path != NULL) { - int retval = snprintf(buf, sizeof buf, - "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); - if ((size_t)retval >= sizeof buf) { - fprintf(stderr, "URL too long\n"); + if (s_time_config.perform & 2) { + printf("\n\nNow timing with session id reuse.\n"); + if (benchmark(1)) goto end; - } - SSL_write(scon, buf, strlen(buf)); - while (SSL_read(scon, buf, sizeof(buf)) > 0); } - if (s_time_config.no_shutdown) - SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | - SSL_RECEIVED_SHUTDOWN); - else - SSL_shutdown(scon); - - nConn = 0; - totalTime = 0.0; - - finishtime = time(NULL) + s_time_config.maxtime; - - printf("starting\n"); - bytes_read = 0; - tm_Time_F(START); - - for (;;) { - if (finishtime < time(NULL)) - break; - if ((doConnection(scon)) == NULL) - goto end; - - if (s_time_config.www_path) { - int i, retval = snprintf(buf, sizeof buf, - "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); - if ((size_t)retval >= sizeof buf) { - fprintf(stderr, "URL too long\n"); - goto end; - } - SSL_write(scon, buf, strlen(buf)); - while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) - bytes_read += i; - } - if (s_time_config.no_shutdown) - SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | - SSL_RECEIVED_SHUTDOWN); - else - SSL_shutdown(scon); - - nConn += 1; - if (SSL_session_reused(scon)) - ver = 'r'; - else { - ver = SSL_version(scon); - if (ver == TLS1_VERSION) - ver = 't'; - else if (ver == SSL3_VERSION) - ver = '3'; - else if (ver == SSL2_VERSION) - ver = '2'; - else - ver = '*'; - } - fputc(ver, stdout); - fflush(stdout); - } - totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ - - printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read); - printf("%d connections in %lld real seconds, %ld bytes read per connection\n", - nConn, - (long long)(time(NULL) - finishtime + s_time_config.maxtime), - bytes_read / nConn); - ret = 0; end: - SSL_free(scon); - if (tm_ctx != NULL) { SSL_CTX_free(tm_ctx); tm_ctx = NULL; @@ -484,44 +332,32 @@ s_time_main(int argc, char **argv) } /*********************************************************************** - * doConnection - make a connection + * run_test - make a connection, get a file, and shut down the connection + * * Args: - * scon = earlier ssl connection for session id, or NULL + * scon = SSL connection * Returns: - * SSL * = the connection pointer. + * 1 on success, 0 on error */ -static SSL * -doConnection(SSL * scon) +static int +run_test(SSL *scon) { + char buf[1024 * 8]; struct pollfd pfd[1]; - SSL *serverCon; BIO *conn; long verify_error; - int i; + int i, retval; if ((conn = BIO_new(BIO_s_connect())) == NULL) - return (NULL); - -/* BIO_set_conn_port(conn,port);*/ + return 0; BIO_set_conn_hostname(conn, s_time_config.host); - - if (scon == NULL) - serverCon = SSL_new(tm_ctx); - else { - serverCon = scon; - SSL_set_connect_state(serverCon); - } - - SSL_set_bio(serverCon, conn, conn); - - /* ok, lets connect */ + SSL_set_connect_state(scon); + SSL_set_bio(scon, conn, conn); for (;;) { - i = SSL_connect(serverCon); + i = SSL_connect(scon); if (BIO_sock_should_retry(i)) { BIO_printf(bio_err, "DELAY\n"); - - i = SSL_get_fd(serverCon); - pfd[0].fd = i; + pfd[0].fd = SSL_get_fd(scon); pfd[0].events = POLLIN; poll(pfd, 1, -1); continue; @@ -530,15 +366,104 @@ doConnection(SSL * scon) } if (i <= 0) { BIO_printf(bio_err, "ERROR\n"); - verify_error = SSL_get_verify_result(serverCon); + verify_error = SSL_get_verify_result(scon); if (verify_error != X509_V_OK) BIO_printf(bio_err, "verify error:%s\n", X509_verify_cert_error_string(verify_error)); else ERR_print_errors(bio_err); - if (scon == NULL) - SSL_free(serverCon); - return NULL; + return 0; + } + if (s_time_config.www_path != NULL) { + retval = snprintf(buf, sizeof buf, + "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); + if (retval == -1 || retval >= sizeof buf) { + fprintf(stderr, "URL too long\n"); + return 0; + } + if (SSL_write(scon, buf, retval) != retval) + return 0; + while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) + bytes_read += i; + } + if (s_time_config.no_shutdown) + SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | + SSL_RECEIVED_SHUTDOWN); + else + SSL_shutdown(scon); + return 1; +} + +static void +print_tally_mark(SSL *scon) +{ + int ver; + + if (SSL_session_reused(scon)) + ver = 'r'; + else { + ver = SSL_version(scon); + if (ver == TLS1_VERSION) + ver = 't'; + else + ver = '*'; + } + fputc(ver, stdout); + fflush(stdout); +} + +static int +benchmark(int reuse_session) +{ + double elapsed, totalTime; + int nConn = 0; + SSL *scon = NULL; + int ret = 1; + + if (reuse_session) { + /* Get an SSL object so we can reuse the session id */ + if ((scon = SSL_new(tm_ctx)) == NULL) + goto end; + if (!run_test(scon)) { + fprintf(stderr, "Unable to get connection\n"); + goto end; + } + printf("starting\n"); } - return serverCon; + + nConn = 0; + bytes_read = 0; + + app_timer_real(TM_RESET); + app_timer_user(TM_RESET); + for (;;) { + elapsed = app_timer_real(TM_GET); + if (elapsed > s_time_config.maxtime) + break; + if (scon == NULL) { + if ((scon = SSL_new(tm_ctx)) == NULL) + goto end; + } + if (!run_test(scon)) + goto end; + nConn += 1; + print_tally_mark(scon); + if (!reuse_session) { + SSL_free(scon); + scon = NULL; + } + } + totalTime = app_timer_user(TM_GET); + + printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", + nConn, totalTime, ((double) nConn / totalTime), bytes_read); + printf("%d connections in %.0f real seconds, %ld bytes read per connection\n", + nConn, + elapsed, + bytes_read / nConn); + + ret = 0; + end: + SSL_free(scon); + return ret; } diff --git a/bin/openssl/speed.c b/bin/openssl/speed.c index a21f67b5cf..3d226a204e 100644 --- a/bin/openssl/speed.c +++ b/bin/openssl/speed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: speed.c,v 1.22 2018/02/07 05:47:55 jsing Exp $ */ +/* $OpenBSD: speed.c,v 1.23 2018/07/13 18:36:56 cheloha Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -195,8 +195,8 @@ sig_done(int sig) run = 0; } -#define START 0 -#define STOP 1 +#define START TM_RESET +#define STOP TM_GET static double diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index eb22f62278..7851c4c3a6 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -1258,9 +1258,11 @@ EVP_CIPHER_CTX_cleanup EVP_CIPHER_CTX_clear_flags EVP_CIPHER_CTX_copy EVP_CIPHER_CTX_ctrl +EVP_CIPHER_CTX_encrypting EVP_CIPHER_CTX_flags EVP_CIPHER_CTX_free EVP_CIPHER_CTX_get_app_data +EVP_CIPHER_CTX_get_iv EVP_CIPHER_CTX_init EVP_CIPHER_CTX_iv_length EVP_CIPHER_CTX_key_length @@ -1270,6 +1272,7 @@ EVP_CIPHER_CTX_rand_key EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_set_app_data EVP_CIPHER_CTX_set_flags +EVP_CIPHER_CTX_set_iv EVP_CIPHER_CTX_set_key_length EVP_CIPHER_CTX_set_padding EVP_CIPHER_CTX_test_flags @@ -1349,7 +1352,6 @@ EVP_PBE_cleanup EVP_PBE_find EVP_PKCS82PKEY EVP_PKEY2PKCS8 -EVP_PKEY2PKCS8_broken EVP_PKEY_CTX_ctrl EVP_PKEY_CTX_ctrl_str EVP_PKEY_CTX_dup @@ -2192,9 +2194,10 @@ PKCS8_PRIV_KEY_INFO_new PKCS8_add_keyusage PKCS8_decrypt PKCS8_encrypt +PKCS8_pkey_add1_attr_by_NID PKCS8_pkey_get0 +PKCS8_pkey_get0_attrs PKCS8_pkey_set0 -PKCS8_set_broken PKEY_USAGE_PERIOD_free PKEY_USAGE_PERIOD_it PKEY_USAGE_PERIOD_new @@ -2273,7 +2276,9 @@ RSA_get_ex_new_index RSA_get_method RSA_meth_dup RSA_meth_free +RSA_meth_get_finish RSA_meth_new +RSA_meth_set1_name RSA_meth_set_finish RSA_meth_set_priv_dec RSA_meth_set_priv_enc @@ -2671,14 +2676,19 @@ X509_CRL_get0_extensions X509_CRL_get0_lastUpdate X509_CRL_get0_nextUpdate X509_CRL_get0_signature +X509_CRL_get_REVOKED X509_CRL_get_ext X509_CRL_get_ext_by_NID X509_CRL_get_ext_by_OBJ X509_CRL_get_ext_by_critical X509_CRL_get_ext_count X509_CRL_get_ext_d2i +X509_CRL_get_issuer +X509_CRL_get_lastUpdate X509_CRL_get_meth_data +X509_CRL_get_nextUpdate X509_CRL_get_signature_nid +X509_CRL_get_version X509_CRL_it X509_CRL_match X509_CRL_new @@ -2818,6 +2828,8 @@ X509_REQ_get_extension_nids X509_REQ_get_extensions X509_REQ_get_pubkey X509_REQ_get_signature_nid +X509_REQ_get_subject_name +X509_REQ_get_version X509_REQ_it X509_REQ_new X509_REQ_print @@ -3008,9 +3020,12 @@ X509_get_ext_d2i X509_get_issuer_name X509_get_pubkey X509_get_pubkey_parameters +X509_get0_serialNumber X509_get_serialNumber X509_get_signature_nid +X509_get_signature_type X509_get_subject_name +X509_get_version X509_getm_notAfter X509_getm_notBefore X509_gmtime_adj diff --git a/lib/libcrypto/aes/aes_x86core.c b/lib/libcrypto/aes/aes_x86core.c index c604fa876f..d0d12dc3ae 100644 --- a/lib/libcrypto/aes/aes_x86core.c +++ b/lib/libcrypto/aes/aes_x86core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aes_x86core.c,v 1.8 2015/02/10 09:46:30 miod Exp $ */ +/* $OpenBSD: aes_x86core.c,v 1.9 2018/04/03 21:59:37 tb Exp $ */ /** * rijndael-alg-fst.c * @@ -465,7 +465,8 @@ static const u32 rcon[] = { * Expand the cipher key into the encryption key schedule. */ int -AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { +AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) +{ u32 *rk; int i = 0; u32 temp; diff --git a/lib/libcrypto/asn1/a_bitstr.c b/lib/libcrypto/asn1/a_bitstr.c index 9ba77d6958..11771bdd02 100644 --- a/lib/libcrypto/asn1/a_bitstr.c +++ b/lib/libcrypto/asn1/a_bitstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_bitstr.c,v 1.24 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: a_bitstr.c,v 1.28 2018/05/13 13:48:08 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -135,29 +135,34 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) int i; if (len < 1) { - i = ASN1_R_STRING_TOO_SHORT; + ASN1error(ASN1_R_STRING_TOO_SHORT); goto err; } - if ((a == NULL) || ((*a) == NULL)) { + if (a == NULL || *a == NULL) { if ((ret = ASN1_BIT_STRING_new()) == NULL) return (NULL); } else - ret = (*a); + ret = *a; p = *pp; i = *(p++); - /* We do this to preserve the settings. If we modify - * the settings, via the _set_bit function, we will recalculate - * on output */ - ret->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */ - ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|(i&0x07)); /* set */ - - if (len-- > 1) /* using one because of the bits left byte */ - { - s = malloc(len); - if (s == NULL) { - i = ERR_R_MALLOC_FAILURE; + if (i > 7) { + ASN1error(ASN1_R_INVALID_BIT_STRING_BITS_LEFT); + goto err; + } + + /* + * We do this to preserve the settings. If we modify the settings, + * via the _set_bit function, we will recalculate on output. + */ + ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear */ + ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | i); /* set */ + + /* using one because of the bits left byte */ + if (len-- > 1) { + if ((s = malloc(len)) == NULL) { + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } memcpy(s, p, len); @@ -166,24 +171,25 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) } else s = NULL; - ret->length = (int)len; free(ret->data); ret->data = s; + ret->length = (int)len; ret->type = V_ASN1_BIT_STRING; + if (a != NULL) - (*a) = ret; + *a = ret; + *pp = p; + return (ret); -err: - ASN1error(i); - if ((ret != NULL) && ((a == NULL) || (*a != ret))) + err: + if (a == NULL || *a != ret) ASN1_BIT_STRING_free(ret); + return (NULL); } -/* These next 2 functions from Goetz Babin-Ebell - */ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) { @@ -204,8 +210,7 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) if ((a->length < (w + 1)) || (a->data == NULL)) { if (!value) return(1); /* Don't need to set */ - c = OPENSSL_realloc_clean(a->data, a->length, w + 1); - if (c == NULL) { + if ((c = recallocarray(a->data, a->length, w + 1, 1)) == NULL) { ASN1error(ERR_R_MALLOC_FAILURE); return 0; } @@ -222,7 +227,7 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) } int -ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n) +ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n) { int w, v; @@ -240,7 +245,8 @@ ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n) * 'len' is the length of 'flags'. */ int -ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, unsigned char *flags, int flags_len) +ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, const unsigned char *flags, + int flags_len) { int i, ok; diff --git a/lib/libcrypto/asn1/a_digest.c b/lib/libcrypto/asn1/a_digest.c index 085a57d811..5b95adf115 100644 --- a/lib/libcrypto/asn1/a_digest.c +++ b/lib/libcrypto/asn1/a_digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_digest.c,v 1.15 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_digest.c,v 1.16 2018/04/06 09:19:36 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -77,8 +77,11 @@ ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn, if (!str) return (0); - if (!EVP_Digest(str, i, md, len, type, NULL)) - return 0; + if (!EVP_Digest(str, i, md, len, type, NULL)) { + free(str); + return (0); + } + free(str); return (1); } diff --git a/lib/libcrypto/asn1/a_enum.c b/lib/libcrypto/asn1/a_enum.c index 23875958bf..c7d3a9a0ac 100644 --- a/lib/libcrypto/asn1/a_enum.c +++ b/lib/libcrypto/asn1/a_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_enum.c,v 1.18 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: a_enum.c,v 1.19 2018/04/25 11:48:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -104,7 +104,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) } long -ASN1_ENUMERATED_get(ASN1_ENUMERATED *a) +ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a) { int neg = 0, i; long r = 0; @@ -134,7 +134,7 @@ ASN1_ENUMERATED_get(ASN1_ENUMERATED *a) } ASN1_ENUMERATED * -BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) +BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai) { ASN1_ENUMERATED *ret; int len, j; @@ -177,7 +177,7 @@ err: } BIGNUM * -ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn) +ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn) { BIGNUM *ret; diff --git a/lib/libcrypto/asn1/a_object.c b/lib/libcrypto/asn1/a_object.c index e10af97d36..16c3a1c0fd 100644 --- a/lib/libcrypto/asn1/a_object.c +++ b/lib/libcrypto/asn1/a_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_object.c,v 1.30 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: a_object.c,v 1.31 2018/04/25 11:48:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,7 +67,7 @@ #include int -i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) +i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp) { unsigned char *p; int objsize; @@ -213,13 +213,13 @@ err: } int -i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a) +i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a) { return OBJ_obj2txt(buf, buf_len, a, 0); } int -i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a) +i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a) { char *tmp = NULL; size_t tlen = 256; diff --git a/lib/libcrypto/asn1/a_strex.c b/lib/libcrypto/asn1/a_strex.c index f60a70d94d..4e3deccfda 100644 --- a/lib/libcrypto/asn1/a_strex.c +++ b/lib/libcrypto/asn1/a_strex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_strex.c,v 1.25 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: a_strex.c,v 1.28 2018/05/19 10:46:28 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -289,7 +289,7 @@ do_hex_dump(char_io *io_ch, void *arg, unsigned char *buf, int buflen) */ static int -do_dump(unsigned long lflags, char_io *io_ch, void *arg, ASN1_STRING *str) +do_dump(unsigned long lflags, char_io *io_ch, void *arg, const ASN1_STRING *str) { /* Placing the ASN1_STRING in a temp ASN1_TYPE allows * the DER encoding to readily obtained @@ -346,7 +346,8 @@ static const signed char tag2nbyte[] = { */ static int -do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, ASN1_STRING *str) +do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, + const ASN1_STRING *str) { int outlen, len; int type; @@ -439,7 +440,7 @@ do_indent(char_io *io_ch, void *arg, int indent) #define FN_WIDTH_SN 10 static int -do_name_ex(char_io *io_ch, void *arg, X509_NAME *n, int indent, +do_name_ex(char_io *io_ch, void *arg, const X509_NAME *n, int indent, unsigned long flags) { int i, prev = -1, orflags, cnt; @@ -581,7 +582,8 @@ do_name_ex(char_io *io_ch, void *arg, X509_NAME *n, int indent, /* Wrappers round the main functions */ int -X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags) +X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, + unsigned long flags) { if (flags == XN_FLAG_COMPAT) return X509_NAME_print(out, nm, indent); @@ -589,7 +591,8 @@ X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags) } int -X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags) +X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent, + unsigned long flags) { if (flags == XN_FLAG_COMPAT) { BIO *btmp; @@ -605,13 +608,13 @@ X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags) } int -ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags) +ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags) { return do_print_ex(send_bio_chars, out, flags, str); } int -ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags) +ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags) { return do_print_ex(send_fp_chars, fp, flags, str); } @@ -621,7 +624,7 @@ ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags) */ int -ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in) +ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in) { ASN1_STRING stmp, *str = &stmp; int mbflag, type, ret; diff --git a/lib/libcrypto/asn1/a_time_tm.c b/lib/libcrypto/asn1/a_time_tm.c index b13f7c767f..b6e22cbd27 100644 --- a/lib/libcrypto/asn1/a_time_tm.c +++ b/lib/libcrypto/asn1/a_time_tm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time_tm.c,v 1.14 2017/08/28 17:42:47 jsing Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.15 2018/04/25 11:48:21 tb Exp $ */ /* * Copyright (c) 2015 Bob Beck * @@ -337,7 +337,7 @@ ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec) } int -ASN1_TIME_check(ASN1_TIME *t) +ASN1_TIME_check(const ASN1_TIME *t) { if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME) return (0); @@ -345,7 +345,7 @@ ASN1_TIME_check(ASN1_TIME *t) } ASN1_GENERALIZEDTIME * -ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) +ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) { ASN1_GENERALIZEDTIME *tmp = NULL; struct tm tm; @@ -386,7 +386,7 @@ ASN1_TIME_set_string(ASN1_TIME *s, const char *str) */ int -ASN1_UTCTIME_check(ASN1_UTCTIME *d) +ASN1_UTCTIME_check(const ASN1_UTCTIME *d) { if (d->type != V_ASN1_UTCTIME) return (0); @@ -442,7 +442,7 @@ ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t2) */ int -ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) +ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) { if (d->type != V_ASN1_GENERALIZEDTIME) return (0); diff --git a/lib/libcrypto/asn1/a_type.c b/lib/libcrypto/asn1/a_type.c index ed1dec0671..11d38300d6 100644 --- a/lib/libcrypto/asn1/a_type.c +++ b/lib/libcrypto/asn1/a_type.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_type.c,v 1.19 2016/05/04 15:00:24 tedu Exp $ */ +/* $OpenBSD: a_type.c,v 1.20 2018/04/25 11:48:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include int -ASN1_TYPE_get(ASN1_TYPE *a) +ASN1_TYPE_get(const ASN1_TYPE *a) { if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL)) return (a->type); @@ -108,7 +108,7 @@ ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value) /* Returns 0 if they are equal, != 0 otherwise. */ int -ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b) +ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b) { int result = -1; diff --git a/lib/libcrypto/asn1/ameth_lib.c b/lib/libcrypto/asn1/ameth_lib.c index b27d72af45..505e986970 100644 --- a/lib/libcrypto/asn1/ameth_lib.c +++ b/lib/libcrypto/asn1/ameth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ameth_lib.c,v 1.16 2017/01/21 04:31:25 jsing Exp $ */ +/* $OpenBSD: ameth_lib.c,v 1.19 2018/08/24 20:22:15 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -299,7 +299,7 @@ EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags, } const EVP_PKEY_ASN1_METHOD* -EVP_PKEY_get0_asn1(EVP_PKEY *pkey) +EVP_PKEY_get0_asn1(const EVP_PKEY *pkey) { return pkey->ameth; } @@ -309,59 +309,26 @@ EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth; - ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD)); - if (!ameth) + if ((ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD))) == NULL) return NULL; ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; - if (info) { - ameth->info = strdup(info); - if (!ameth->info) + if (info != NULL) { + if ((ameth->info = strdup(info)) == NULL) goto err; - } else - ameth->info = NULL; + } - if (pem_str) { - ameth->pem_str = strdup(pem_str); - if (!ameth->pem_str) + if (pem_str != NULL) { + if ((ameth->pem_str = strdup(pem_str)) == NULL) goto err; - } else - ameth->pem_str = NULL; - - ameth->pub_decode = 0; - ameth->pub_encode = 0; - ameth->pub_cmp = 0; - ameth->pub_print = 0; - - ameth->priv_decode = 0; - ameth->priv_encode = 0; - ameth->priv_print = 0; - - ameth->old_priv_encode = 0; - ameth->old_priv_decode = 0; - - ameth->item_verify = 0; - ameth->item_sign = 0; - - ameth->pkey_size = 0; - ameth->pkey_bits = 0; - - ameth->param_decode = 0; - ameth->param_encode = 0; - ameth->param_missing = 0; - ameth->param_copy = 0; - ameth->param_cmp = 0; - ameth->param_print = 0; - - ameth->pkey_free = 0; - ameth->pkey_ctrl = 0; + } return ameth; -err: + err: EVP_PKEY_asn1_free(ameth); return NULL; } @@ -390,6 +357,7 @@ EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src) dst->param_copy = src->param_copy; dst->param_cmp = src->param_cmp; dst->param_print = src->param_print; + dst->sig_print = src->sig_print; dst->pkey_free = src->pkey_free; dst->pkey_ctrl = src->pkey_ctrl; @@ -428,7 +396,7 @@ EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, - int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf), + int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf), int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk), int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)) diff --git a/lib/libcrypto/asn1/asn1.h b/lib/libcrypto/asn1/asn1.h index 6fc4cd7527..e3bebe45a6 100644 --- a/lib/libcrypto/asn1/asn1.h +++ b/lib/libcrypto/asn1/asn1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1.h,v 1.44 2018/02/14 16:46:04 jsing Exp $ */ +/* $OpenBSD: asn1.h,v 1.49 2018/05/19 10:46:28 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -754,14 +754,14 @@ ASN1_TYPE *d2i_ASN1_TYPE(ASN1_TYPE **a, const unsigned char **in, long len); int i2d_ASN1_TYPE(ASN1_TYPE *a, unsigned char **out); extern const ASN1_ITEM ASN1_ANY_it; -int ASN1_TYPE_get(ASN1_TYPE *a); +int ASN1_TYPE_get(const ASN1_TYPE *a); void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); -int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b); +int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); -ASN1_OBJECT *ASN1_OBJECT_new(void ); +ASN1_OBJECT *ASN1_OBJECT_new(void); void ASN1_OBJECT_free(ASN1_OBJECT *a); -int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp); +int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp); ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long length); ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, @@ -775,7 +775,7 @@ ASN1_STRING *ASN1_STRING_new(void); void ASN1_STRING_free(ASN1_STRING *a); int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a); -ASN1_STRING *ASN1_STRING_type_new(int type ); +ASN1_STRING *ASN1_STRING_type_new(int type); int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); /* Since this is used to store all sorts of things, via macros, for now, make its data void * */ @@ -783,7 +783,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); int ASN1_STRING_length(const ASN1_STRING *x); void ASN1_STRING_length_set(ASN1_STRING *x, int n); -int ASN1_STRING_type(ASN1_STRING *x); +int ASN1_STRING_type(const ASN1_STRING *x); unsigned char *ASN1_STRING_data(ASN1_STRING *x); const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x); @@ -795,18 +795,18 @@ extern const ASN1_ITEM ASN1_BIT_STRING_it; int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long length); -int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length ); +int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); -int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); -int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, - unsigned char *flags, int flags_len); +int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n); +int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, + const unsigned char *flags, int flags_len); #ifndef OPENSSL_NO_BIO int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, BIT_STRING_BITNAME *tbl, int indent); #endif -int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); -int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, +int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl); +int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value, BIT_STRING_BITNAME *tbl); int i2d_ASN1_BOOLEAN(int a, unsigned char **pp); @@ -831,7 +831,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, const unsigned char ** int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **out); extern const ASN1_ITEM ASN1_ENUMERATED_it; -int ASN1_UTCTIME_check(ASN1_UTCTIME *a); +int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec); @@ -841,7 +841,7 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); #endif /* !LIBRESSL_INTERNAL */ -int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); +int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t); ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, @@ -943,8 +943,8 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); ASN1_TIME *ASN1_TIME_set_tm(ASN1_TIME *s, struct tm *tm); ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec); -int ASN1_TIME_check(ASN1_TIME *t); -ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, +int ASN1_TIME_check(const ASN1_TIME *t); +ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); @@ -955,15 +955,15 @@ STACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, void (*free_func)(OPENSSL_BLOCK), int ex_tag, int ex_class); #ifndef OPENSSL_NO_BIO -int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); +int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a); int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size); -int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); +int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a); int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size); -int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a); +int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a); int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size); -int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); +int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type); #endif -int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a); +int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a); int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, @@ -975,9 +975,9 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); -long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); -ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); -BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn); +long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a); +ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai); +BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn); /* General */ /* given a string, return the correct type, max is the maximum length */ @@ -1052,9 +1052,10 @@ int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x); CHECKED_PTR_OF(const type, x))) int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); -int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); +int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, + unsigned long flags); -int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); +int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); #ifndef OPENSSL_NO_BIO void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); @@ -1083,7 +1084,7 @@ int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a); int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); -int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); +int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags); int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, unsigned char *buf, int off); int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); @@ -1102,18 +1103,19 @@ extern const ASN1_ITEM NETSCAPE_X509_it; int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); -int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len); +int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, + int max_len); int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, int len); -int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data, - int max_len); +int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, + unsigned char *data, int max_len); STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len, d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK)); unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, - unsigned char **buf, int *len ); + unsigned char **buf, int *len); void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); -void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); +void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it); ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_OCTET_STRING **oct); @@ -1139,15 +1141,15 @@ void ASN1_STRING_TABLE_cleanup(void); /* Old API compatible functions */ ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); -ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, +ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); void ASN1_add_oid_module(void); -ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); -ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); +ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf); +ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf); /* ASN1 Print flags */ @@ -1174,18 +1176,18 @@ int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, const ASN1_ITEM *it, const ASN1_PCTX *pctx); ASN1_PCTX *ASN1_PCTX_new(void); void ASN1_PCTX_free(ASN1_PCTX *p); -unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p); +unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p); void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p); +unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p); void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p); +unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p); void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p); +unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p); void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p); +unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p); void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); -BIO_METHOD *BIO_f_asn1(void); +const BIO_METHOD *BIO_f_asn1(void); BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); @@ -1405,6 +1407,7 @@ void ERR_load_ASN1_strings(void); #define ASN1_R_MSTRING_NOT_UNIVERSAL 139 #define ASN1_R_MSTRING_WRONG_TAG 140 #define ASN1_R_NESTED_ASN1_STRING 197 +#define ASN1_R_NESTED_TOO_DEEP 219 #define ASN1_R_NON_HEX_CHARACTERS 141 #define ASN1_R_NOT_ASCII_FORMAT 190 #define ASN1_R_NOT_ENOUGH_DATA 142 diff --git a/lib/libcrypto/asn1/asn1_err.c b/lib/libcrypto/asn1/asn1_err.c index 0c827a9236..5cc355084f 100644 --- a/lib/libcrypto/asn1/asn1_err.c +++ b/lib/libcrypto/asn1/asn1_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_err.c,v 1.20 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: asn1_err.c,v 1.21 2018/03/29 02:29:24 inoguchi Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -150,6 +150,7 @@ static ERR_STRING_DATA ASN1_str_reasons[] = { {ERR_REASON(ASN1_R_MSTRING_NOT_UNIVERSAL), "mstring not universal"}, {ERR_REASON(ASN1_R_MSTRING_WRONG_TAG) , "mstring wrong tag"}, {ERR_REASON(ASN1_R_NESTED_ASN1_STRING) , "nested asn1 string"}, + {ERR_REASON(ASN1_R_NESTED_TOO_DEEP) , "nested too deep"}, {ERR_REASON(ASN1_R_NON_HEX_CHARACTERS) , "non hex characters"}, {ERR_REASON(ASN1_R_NOT_ASCII_FORMAT) , "not ascii format"}, {ERR_REASON(ASN1_R_NOT_ENOUGH_DATA) , "not enough data"}, diff --git a/lib/libcrypto/asn1/asn1_gen.c b/lib/libcrypto/asn1/asn1_gen.c index f84cc6136b..ad7802cb11 100644 --- a/lib/libcrypto/asn1/asn1_gen.c +++ b/lib/libcrypto/asn1/asn1_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_gen.c,v 1.16 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: asn1_gen.c,v 1.17 2018/04/25 11:48:21 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2002. */ @@ -121,7 +121,7 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype); static int asn1_str2tag(const char *tagstr, int len); ASN1_TYPE * -ASN1_generate_nconf(char *str, CONF *nconf) +ASN1_generate_nconf(const char *str, CONF *nconf) { X509V3_CTX cnf; @@ -133,7 +133,7 @@ ASN1_generate_nconf(char *str, CONF *nconf) } ASN1_TYPE * -ASN1_generate_v3(char *str, X509V3_CTX *cnf) +ASN1_generate_v3(const char *str, X509V3_CTX *cnf) { ASN1_TYPE *ret; tag_exp_arg asn1_tags; diff --git a/lib/libcrypto/asn1/asn1_lib.c b/lib/libcrypto/asn1/asn1_lib.c index 970102c213..ffd3ad6a46 100644 --- a/lib/libcrypto/asn1/asn1_lib.c +++ b/lib/libcrypto/asn1/asn1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_lib.c,v 1.40 2018/02/14 16:46:04 jsing Exp $ */ +/* $OpenBSD: asn1_lib.c,v 1.41 2018/04/25 11:48:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -474,7 +474,7 @@ ASN1_STRING_length_set(ASN1_STRING *x, int len) } int -ASN1_STRING_type(ASN1_STRING *x) +ASN1_STRING_type(const ASN1_STRING *x) { return (x->type); } diff --git a/lib/libcrypto/asn1/asn1_locl.h b/lib/libcrypto/asn1/asn1_locl.h index aa35f7b8fc..5ade6c7e3f 100644 --- a/lib/libcrypto/asn1/asn1_locl.h +++ b/lib/libcrypto/asn1/asn1_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_locl.h,v 1.10 2017/08/27 01:39:26 beck Exp $ */ +/* $OpenBSD: asn1_locl.h,v 1.11 2018/08/24 20:22:15 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -86,7 +86,7 @@ struct evp_pkey_asn1_method_st { int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); - int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf); + int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf); int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk); int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); diff --git a/lib/libcrypto/asn1/asn_pack.c b/lib/libcrypto/asn1/asn_pack.c index 09d150583a..1a5420e42b 100644 --- a/lib/libcrypto/asn1/asn_pack.c +++ b/lib/libcrypto/asn1/asn_pack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn_pack.c,v 1.16 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: asn_pack.c,v 1.17 2018/04/25 11:48:21 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -203,7 +203,7 @@ err: /* Extract an ASN1 object from an ASN1_STRING */ void * -ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it) +ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it) { const unsigned char *p; void *ret; diff --git a/lib/libcrypto/asn1/bio_asn1.c b/lib/libcrypto/asn1/bio_asn1.c index 02ad310639..93bcb33888 100644 --- a/lib/libcrypto/asn1/bio_asn1.c +++ b/lib/libcrypto/asn1/bio_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_asn1.c,v 1.12 2015/12/23 01:46:33 mmcc Exp $ */ +/* $OpenBSD: bio_asn1.c,v 1.13 2018/05/01 13:29:09 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -125,7 +125,7 @@ static int asn1_bio_setup_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx, asn1_ps_func *setup, asn1_bio_state_t ex_state, asn1_bio_state_t other_state); -static BIO_METHOD methods_asn1 = { +static const BIO_METHOD methods_asn1 = { .type = BIO_TYPE_ASN1, .name = "asn1", .bwrite = asn1_bio_write, @@ -138,7 +138,7 @@ static BIO_METHOD methods_asn1 = { .callback_ctrl = asn1_bio_callback_ctrl }; -BIO_METHOD * +const BIO_METHOD * BIO_f_asn1(void) { return (&methods_asn1); diff --git a/lib/libcrypto/asn1/d2i_pr.c b/lib/libcrypto/asn1/d2i_pr.c index 7a5880a8cd..a657a1f3cd 100644 --- a/lib/libcrypto/asn1/d2i_pr.c +++ b/lib/libcrypto/asn1/d2i_pr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d2i_pr.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: d2i_pr.c,v 1.16 2018/04/14 07:09:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -86,10 +86,8 @@ d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) } else { ret = *a; #ifndef OPENSSL_NO_ENGINE - if (ret->engine) { - ENGINE_finish(ret->engine); - ret->engine = NULL; - } + ENGINE_finish(ret->engine); + ret->engine = NULL; #endif } diff --git a/lib/libcrypto/asn1/evp_asn1.c b/lib/libcrypto/asn1/evp_asn1.c index 5f74da1546..ec63557770 100644 --- a/lib/libcrypto/asn1/evp_asn1.c +++ b/lib/libcrypto/asn1/evp_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_asn1.c,v 1.20 2017/11/28 16:51:21 jsing Exp $ */ +/* $OpenBSD: evp_asn1.c,v 1.21 2018/04/25 11:48:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -79,7 +79,7 @@ ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len) } int -ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len) +ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len) { int ret, num; unsigned char *p; @@ -162,7 +162,7 @@ ASN1_TYPE_set_int_octetstring(ASN1_TYPE *at, long num, unsigned char *data, } int -ASN1_TYPE_get_int_octetstring(ASN1_TYPE *at, long *num, unsigned char *data, +ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *at, long *num, unsigned char *data, int max_len) { ASN1_STRING *sp = at->value.sequence; diff --git a/lib/libcrypto/asn1/f_enum.c b/lib/libcrypto/asn1/f_enum.c index 64feb97dc4..cc4b7dfc91 100644 --- a/lib/libcrypto/asn1/f_enum.c +++ b/lib/libcrypto/asn1/f_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_enum.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: f_enum.c,v 1.16 2018/04/25 11:48:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,7 +65,7 @@ /* Based on a_int.c: equivalent ENUMERATED functions */ int -i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a) +i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a) { int i, n = 0; static const char h[] = "0123456789ABCDEF"; diff --git a/lib/libcrypto/asn1/f_int.c b/lib/libcrypto/asn1/f_int.c index 75168872b3..d03fafe87d 100644 --- a/lib/libcrypto/asn1/f_int.c +++ b/lib/libcrypto/asn1/f_int.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_int.c,v 1.18 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: f_int.c,v 1.20 2018/05/13 13:48:08 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include int -i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a) +i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a) { int i, n = 0; static const char h[] = "0123456789ABCDEF"; @@ -158,8 +158,7 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) } i /= 2; if (num + i > slen) { - sp = OPENSSL_realloc_clean(s, slen, num + i); - if (sp == NULL) { + if ((sp = recallocarray(s, slen, num + i, 1)) == NULL) { ASN1error(ERR_R_MALLOC_FAILURE); goto err; } diff --git a/lib/libcrypto/asn1/f_string.c b/lib/libcrypto/asn1/f_string.c index 138044e063..af17f43e1d 100644 --- a/lib/libcrypto/asn1/f_string.c +++ b/lib/libcrypto/asn1/f_string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_string.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: f_string.c,v 1.18 2018/04/25 11:48:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include int -i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type) +i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type) { int i, n = 0; static const char h[] = "0123456789ABCDEF"; diff --git a/lib/libcrypto/asn1/n_pkey.c b/lib/libcrypto/asn1/n_pkey.c index d2fabf6e87..6c7031677d 100644 --- a/lib/libcrypto/asn1/n_pkey.c +++ b/lib/libcrypto/asn1/n_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: n_pkey.c,v 1.31 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: n_pkey.c,v 1.32 2018/08/05 13:35:45 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -273,11 +273,11 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, goto err; } + enckey->enckey->digest->data = zz; if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { ASN1error(ERR_R_MALLOC_FAILURE); goto err; } - enckey->enckey->digest->data = zz; i2d_NETSCAPE_PKEY(pkey, &zz); /* Wipe the private key encoding */ diff --git a/lib/libcrypto/asn1/p8_pkey.c b/lib/libcrypto/asn1/p8_pkey.c index 71d579456a..d2f8e6b055 100644 --- a/lib/libcrypto/asn1/p8_pkey.c +++ b/lib/libcrypto/asn1/p8_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p8_pkey.c,v 1.17 2015/09/10 15:56:25 jsing Exp $ */ +/* $OpenBSD: p8_pkey.c,v 1.19 2018/08/24 20:17:33 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -69,11 +69,8 @@ pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) /* Since the structure must still be valid use ASN1_OP_FREE_PRE */ if (operation == ASN1_OP_FREE_PRE) { PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval; - if (key->pkey != NULL && - key->pkey->type == V_ASN1_OCTET_STRING && - key->pkey->value.octet_string != NULL) - explicit_bzero(key->pkey->value.octet_string->data, - key->pkey->value.octet_string->length); + if (key->pkey != NULL) + explicit_bzero(key->pkey->data, key->pkey->length); } return 1; } @@ -95,7 +92,7 @@ static const ASN1_TEMPLATE PKCS8_PRIV_KEY_INFO_seq_tt[] = { { .offset = offsetof(PKCS8_PRIV_KEY_INFO, pkey), .field_name = "pkey", - .item = &ASN1_ANY_it, + .item = &ASN1_OCTET_STRING_it, }, { .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, @@ -145,57 +142,45 @@ int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version, int ptype, void *pval, unsigned char *penc, int penclen) { - unsigned char **ppenc = NULL; - if (version >= 0) { if (!ASN1_INTEGER_set(priv->version, version)) return 0; } - if (penc) { - int pmtype; - ASN1_OCTET_STRING *oct; - oct = ASN1_OCTET_STRING_new(); - if (!oct) - return 0; - oct->data = penc; - ppenc = &oct->data; - oct->length = penclen; - if (priv->broken == PKCS8_NO_OCTET) - pmtype = V_ASN1_SEQUENCE; - else - pmtype = V_ASN1_OCTET_STRING; - ASN1_TYPE_set(priv->pkey, pmtype, oct); - } - if (!X509_ALGOR_set0(priv->pkeyalg, aobj, ptype, pval)) { - /* If call fails do not swallow 'enc' */ - if (ppenc) - *ppenc = NULL; + if (!X509_ALGOR_set0(priv->pkeyalg, aobj, ptype, pval)) return 0; - } + if (penc != NULL) + ASN1_STRING_set0(priv->pkey, penc, penclen); return 1; } int -PKCS8_pkey_get0(ASN1_OBJECT **ppkalg, const unsigned char **pk, int *ppklen, - X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8) +PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, const unsigned char **pk, + int *ppklen, const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8) { - if (ppkalg) + if (ppkalg != NULL) *ppkalg = p8->pkeyalg->algorithm; - if (p8->pkey->type == V_ASN1_OCTET_STRING) { - p8->broken = PKCS8_OK; - if (pk) { - *pk = p8->pkey->value.octet_string->data; - *ppklen = p8->pkey->value.octet_string->length; - } - } else if (p8->pkey->type == V_ASN1_SEQUENCE) { - p8->broken = PKCS8_NO_OCTET; - if (pk) { - *pk = p8->pkey->value.sequence->data; - *ppklen = p8->pkey->value.sequence->length; - } - } else - return 0; - if (pa) + if (pk != NULL) { + *pk = ASN1_STRING_data(p8->pkey); + *ppklen = ASN1_STRING_length(p8->pkey); + } + if (pa != NULL) *pa = p8->pkeyalg; return 1; } + +const STACK_OF(X509_ATTRIBUTE) * +PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8) +{ + return p8->attributes; +} + +int +PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type, + const unsigned char *bytes, int len) +{ + if (X509at_add1_attr_by_NID(&p8->attributes, nid, type, bytes, + len) != NULL) + return 1; + return 0; +} + diff --git a/lib/libcrypto/asn1/t_bitst.c b/lib/libcrypto/asn1/t_bitst.c index ea4138e0fb..51515b88e2 100644 --- a/lib/libcrypto/asn1/t_bitst.c +++ b/lib/libcrypto/asn1/t_bitst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_bitst.c,v 1.7 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: t_bitst.c,v 1.8 2018/04/25 11:48:21 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -83,7 +83,7 @@ ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, } int -ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, +ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value, BIT_STRING_BITNAME *tbl) { int bitnum; @@ -99,7 +99,7 @@ ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, } int -ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) +ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl) { BIT_STRING_BITNAME *bnam; diff --git a/lib/libcrypto/asn1/t_x509.c b/lib/libcrypto/asn1/t_x509.c index 3dfaaa40bc..e287a6cf6a 100644 --- a/lib/libcrypto/asn1/t_x509.c +++ b/lib/libcrypto/asn1/t_x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_x509.c,v 1.28 2017/04/03 15:52:59 beck Exp $ */ +/* $OpenBSD: t_x509.c,v 1.31 2018/05/18 18:23:24 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -246,7 +246,8 @@ err: return (ret); } -int X509_ocspid_print (BIO *bp, X509 *x) +int +X509_ocspid_print(BIO *bp, X509 *x) { unsigned char *der = NULL; unsigned char *dertmp; @@ -320,7 +321,7 @@ X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) } int -X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) +X509_signature_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig) { int sig_nid; if (BIO_puts(bp, " Signature Algorithm: ") <= 0) @@ -387,7 +388,7 @@ ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) } static const char *mon[12] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; @@ -489,7 +490,7 @@ err: } int -X509_NAME_print(BIO *bp, X509_NAME *name, int obase) +X509_NAME_print(BIO *bp, const X509_NAME *name, int obase) { char *s, *c, *b; int ret = 0, l, i; diff --git a/lib/libcrypto/asn1/tasn_dec.c b/lib/libcrypto/asn1/tasn_dec.c index 3f680c60fd..3a27b82288 100644 --- a/lib/libcrypto/asn1/tasn_dec.c +++ b/lib/libcrypto/asn1/tasn_dec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_dec.c,v 1.34 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: tasn_dec.c,v 1.36 2018/09/17 18:18:01 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -65,6 +65,12 @@ #include #include +/* Constructed types with a recursive definition (such as can be found in PKCS7) + * could eventually exceed the stack given malicious input with excessive + * recursion. Therefore we limit the stack depth. + */ +#define ASN1_MAX_CONSTRUCTED_NEST 30 + static int asn1_check_eoc(const unsigned char **in, long len); static int asn1_find_end(const unsigned char **in, long len, char inf); @@ -78,9 +84,9 @@ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, int expclass, char opt, ASN1_TLC *ctx); static int asn1_template_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, - long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx); + long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth); static int asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, - long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx); + long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth); static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx); @@ -142,7 +148,7 @@ ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ASN1_TLC c; asn1_tlc_clear_nc(&c); - return asn1_template_ex_d2i(pval, in, len, tt, 0, &c); + return asn1_template_ex_d2i(pval, in, len, tt, 0, &c, 0); } @@ -150,14 +156,15 @@ ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, * If 'opt' set and tag mismatch return -1 to handle OPTIONAL */ -int -ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) +static int +asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx, + int depth) { const ASN1_TEMPLATE *tt, *errtt = NULL; const ASN1_EXTERN_FUNCS *ef; const ASN1_AUX *aux = it->funcs; - ASN1_aux_cb *asn1_cb; + ASN1_aux_cb *asn1_cb = NULL; const unsigned char *p = NULL, *q; unsigned char oclass; char seq_eoc, seq_nolen, cst, isopt; @@ -176,8 +183,11 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, if (aux && aux->asn1_cb) asn1_cb = aux->asn1_cb; - else - asn1_cb = 0; + + if (++depth > ASN1_MAX_CONSTRUCTED_NEST) { + ASN1error(ASN1_R_NESTED_TOO_DEEP); + goto err; + } switch (it->itype) { case ASN1_ITYPE_PRIMITIVE: @@ -193,7 +203,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, goto err; } return asn1_template_ex_d2i(pval, in, len, - it->templates, opt, ctx); + it->templates, opt, ctx, depth); } return asn1_d2i_ex_primitive(pval, in, len, it, tag, aclass, opt, ctx); @@ -258,7 +268,8 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, /* We mark field as OPTIONAL so its absence * can be recognised. */ - ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx); + ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx, + depth); /* If field not present, try the next one */ if (ret == -1) continue; @@ -376,7 +387,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, * OPTIONAL */ ret = asn1_template_ex_d2i(pseqval, &p, len, - seqtt, isopt, ctx); + seqtt, isopt, ctx, depth); if (!ret) { errtt = seqtt; goto err; @@ -448,13 +459,20 @@ err: return 0; } +int +ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) +{ + return asn1_item_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx, 0); +} + /* Templates are handled with two separate functions. * One handles any EXPLICIT tag and the other handles the rest. */ static int asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, - const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx) + const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth) { int flags, aclass; int ret; @@ -489,7 +507,7 @@ asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, return 0; } /* We've found the field so it can't be OPTIONAL now */ - ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx); + ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx, depth); if (!ret) { ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; @@ -511,7 +529,8 @@ asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, } } } else - return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx); + return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx, + depth); *in = p; return 1; @@ -523,7 +542,7 @@ err: static int asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, - const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx) + const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth) { int flags, aclass; int ret; @@ -594,8 +613,8 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, break; } skfield = NULL; - if (!ASN1_item_ex_d2i(&skfield, &p, len, - tt->item, -1, 0, 0, ctx)) { + if (!asn1_item_ex_d2i(&skfield, &p, len, + tt->item, -1, 0, 0, ctx, depth)) { ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } @@ -612,8 +631,8 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, } } else if (flags & ASN1_TFLG_IMPTAG) { /* IMPLICIT tagging */ - ret = ASN1_item_ex_d2i(val, &p, len, - tt->item, tt->tag, aclass, opt, ctx); + ret = asn1_item_ex_d2i(val, &p, len, + tt->item, tt->tag, aclass, opt, ctx, depth); if (!ret) { ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; @@ -621,8 +640,8 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, return -1; } else { /* Nothing special */ - ret = ASN1_item_ex_d2i(val, &p, len, tt->item, - -1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx); + ret = asn1_item_ex_d2i(val, &p, len, tt->item, + -1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx, depth); if (!ret) { ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; diff --git a/lib/libcrypto/asn1/tasn_fre.c b/lib/libcrypto/asn1/tasn_fre.c index 9276034808..c05310ec28 100644 --- a/lib/libcrypto/asn1/tasn_fre.c +++ b/lib/libcrypto/asn1/tasn_fre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_fre.c,v 1.15 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: tasn_fre.c,v 1.16 2018/04/06 12:16:06 bluhm Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -88,7 +88,10 @@ asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) ASN1_aux_cb *asn1_cb = NULL; int i; - if (pval == NULL || *pval == NULL) + if (pval == NULL) + return; + /* For primitive types *pval may be something other than C pointer. */ + if (it->itype != ASN1_ITYPE_PRIMITIVE && *pval == NULL) return; if (aux != NULL && aux->asn1_cb != NULL) diff --git a/lib/libcrypto/asn1/tasn_prn.c b/lib/libcrypto/asn1/tasn_prn.c index 7cccd56a16..b8f7dd5294 100644 --- a/lib/libcrypto/asn1/tasn_prn.c +++ b/lib/libcrypto/asn1/tasn_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_prn.c,v 1.16 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: tasn_prn.c,v 1.17 2018/04/25 11:48:21 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -105,7 +105,7 @@ ASN1_PCTX_free(ASN1_PCTX *p) } unsigned long -ASN1_PCTX_get_flags(ASN1_PCTX *p) +ASN1_PCTX_get_flags(const ASN1_PCTX *p) { return p->flags; } @@ -117,7 +117,7 @@ ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags) } unsigned long -ASN1_PCTX_get_nm_flags(ASN1_PCTX *p) +ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p) { return p->nm_flags; } @@ -129,7 +129,7 @@ ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags) } unsigned long -ASN1_PCTX_get_cert_flags(ASN1_PCTX *p) +ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p) { return p->cert_flags; } @@ -141,7 +141,7 @@ ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags) } unsigned long -ASN1_PCTX_get_oid_flags(ASN1_PCTX *p) +ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p) { return p->oid_flags; } @@ -153,7 +153,7 @@ ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags) } unsigned long -ASN1_PCTX_get_str_flags(ASN1_PCTX *p) +ASN1_PCTX_get_str_flags(const ASN1_PCTX *p) { return p->str_flags; } diff --git a/lib/libcrypto/asn1/x_algor.c b/lib/libcrypto/asn1/x_algor.c index 27405a2bfb..2013de795d 100644 --- a/lib/libcrypto/asn1/x_algor.c +++ b/lib/libcrypto/asn1/x_algor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_algor.c,v 1.21 2015/07/24 15:09:52 jsing Exp $ */ +/* $OpenBSD: x_algor.c,v 1.22 2018/05/01 19:01:27 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -176,8 +176,8 @@ X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) } void -X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval, - X509_ALGOR *algor) +X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, const void **ppval, + const X509_ALGOR *algor) { if (paobj) *paobj = algor->algorithm; diff --git a/lib/libcrypto/asn1/x_crl.c b/lib/libcrypto/asn1/x_crl.c index e0e6cc8863..0837ec15be 100644 --- a/lib/libcrypto/asn1/x_crl.c +++ b/lib/libcrypto/asn1/x_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_crl.c,v 1.30 2018/03/17 14:33:20 jsing Exp $ */ +/* $OpenBSD: x_crl.c,v 1.33 2018/08/24 19:55:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -675,6 +675,8 @@ X509_CRL_METHOD_new(int (*crl_init)(X509_CRL *crl), void X509_CRL_METHOD_free(X509_CRL_METHOD *m) { + if (m == NULL) + return; if (!(m->flags & X509_CRL_METHOD_DYNAMIC)) return; free(m); @@ -704,18 +706,48 @@ X509_CRL_get0_extensions(const X509_CRL *crl) return crl->crl->extensions; } +long +X509_CRL_get_version(const X509_CRL *crl) +{ + return ASN1_INTEGER_get(crl->crl->version); +} + const ASN1_TIME * X509_CRL_get0_lastUpdate(const X509_CRL *crl) { return crl->crl->lastUpdate; } +ASN1_TIME * +X509_CRL_get_lastUpdate(X509_CRL *crl) +{ + return crl->crl->lastUpdate; +} + const ASN1_TIME * X509_CRL_get0_nextUpdate(const X509_CRL *crl) { return crl->crl->nextUpdate; } +ASN1_TIME * +X509_CRL_get_nextUpdate(X509_CRL *crl) +{ + return crl->crl->nextUpdate; +} + +X509_NAME * +X509_CRL_get_issuer(const X509_CRL *crl) +{ + return crl->crl->issuer; +} + +STACK_OF(X509_REVOKED) * +X509_CRL_get_REVOKED(X509_CRL *crl) +{ + return crl->crl->revoked; +} + void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, const X509_ALGOR **palg) diff --git a/lib/libcrypto/asn1/x_x509a.c b/lib/libcrypto/asn1/x_x509a.c index 29817915b6..b0d7150b93 100644 --- a/lib/libcrypto/asn1/x_x509a.c +++ b/lib/libcrypto/asn1/x_x509a.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_x509a.c,v 1.14 2015/02/14 15:28:39 miod Exp $ */ +/* $OpenBSD: x_x509a.c,v 1.15 2018/05/01 19:01:27 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -154,7 +154,7 @@ aux_get(X509 *x) } int -X509_alias_set1(X509 *x, unsigned char *name, int len) +X509_alias_set1(X509 *x, const unsigned char *name, int len) { X509_CERT_AUX *aux; if (!name) { @@ -172,7 +172,7 @@ X509_alias_set1(X509 *x, unsigned char *name, int len) } int -X509_keyid_set1(X509 *x, unsigned char *id, int len) +X509_keyid_set1(X509 *x, const unsigned char *id, int len) { X509_CERT_AUX *aux; if (!id) { @@ -210,7 +210,7 @@ X509_keyid_get0(X509 *x, int *len) } int -X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj) +X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj) { X509_CERT_AUX *aux; ASN1_OBJECT *objtmp; @@ -232,7 +232,7 @@ err: } int -X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj) +X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj) { X509_CERT_AUX *aux; ASN1_OBJECT *objtmp; diff --git a/lib/libcrypto/bio/bf_buff.c b/lib/libcrypto/bio/bf_buff.c index 30765b03ca..5b9ee35da8 100644 --- a/lib/libcrypto/bio/bf_buff.c +++ b/lib/libcrypto/bio/bf_buff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bf_buff.c,v 1.24 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bf_buff.c,v 1.25 2018/05/01 13:29:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,7 +73,7 @@ static int buffer_free(BIO *data); static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); #define DEFAULT_BUFFER_SIZE 4096 -static BIO_METHOD methods_buffer = { +static const BIO_METHOD methods_buffer = { .type = BIO_TYPE_BUFFER, .name = "buffer", .bwrite = buffer_write, @@ -86,7 +86,7 @@ static BIO_METHOD methods_buffer = { .callback_ctrl = buffer_callback_ctrl }; -BIO_METHOD * +const BIO_METHOD * BIO_f_buffer(void) { return (&methods_buffer); diff --git a/lib/libcrypto/bio/bf_nbio.c b/lib/libcrypto/bio/bf_nbio.c index 24e2e7e8b9..05fa9161fb 100644 --- a/lib/libcrypto/bio/bf_nbio.c +++ b/lib/libcrypto/bio/bf_nbio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bf_nbio.c,v 1.19 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: bf_nbio.c,v 1.20 2018/05/01 13:29:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -80,7 +80,7 @@ typedef struct nbio_test_st { int lwn; } NBIO_TEST; -static BIO_METHOD methods_nbiof = { +static const BIO_METHOD methods_nbiof = { .type = BIO_TYPE_NBIO_TEST, .name = "non-blocking IO test filter", .bwrite = nbiof_write, @@ -93,7 +93,7 @@ static BIO_METHOD methods_nbiof = { .callback_ctrl = nbiof_callback_ctrl }; -BIO_METHOD * +const BIO_METHOD * BIO_f_nbio_test(void) { return (&methods_nbiof); diff --git a/lib/libcrypto/bio/bf_null.c b/lib/libcrypto/bio/bf_null.c index 09d54b6b21..25abb8a574 100644 --- a/lib/libcrypto/bio/bf_null.c +++ b/lib/libcrypto/bio/bf_null.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bf_null.c,v 1.11 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: bf_null.c,v 1.12 2018/05/01 13:29:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,7 +73,7 @@ static int nullf_new(BIO *h); static int nullf_free(BIO *data); static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); -static BIO_METHOD methods_nullf = { +static const BIO_METHOD methods_nullf = { .type = BIO_TYPE_NULL_FILTER, .name = "NULL filter", .bwrite = nullf_write, @@ -86,7 +86,7 @@ static BIO_METHOD methods_nullf = { .callback_ctrl = nullf_callback_ctrl }; -BIO_METHOD * +const BIO_METHOD * BIO_f_null(void) { return (&methods_nullf); diff --git a/lib/libcrypto/bio/bio.h b/lib/libcrypto/bio/bio.h index d0e2f3550c..82463c6beb 100644 --- a/lib/libcrypto/bio/bio.h +++ b/lib/libcrypto/bio/bio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bio.h,v 1.40 2018/03/17 15:05:55 tb Exp $ */ +/* $OpenBSD: bio.h,v 1.45 2018/06/02 04:41:12 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -286,7 +286,7 @@ typedef struct bio_method_st { } BIO_METHOD; struct bio_st { - BIO_METHOD *method; + const BIO_METHOD *method; /* bio, mode, argp, argi, argl, ret */ long (*callback)(struct bio_st *, int, const char *, int, long, long); char *cb_arg; /* first argument for the callback */ @@ -337,22 +337,22 @@ typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg); /* BIO_METHOD accessors */ BIO_METHOD *BIO_meth_new(int type, const char *name); void BIO_meth_free(BIO_METHOD *biom); -int (*BIO_meth_get_write(BIO_METHOD *biom))(BIO *, const char *, int); +int (*BIO_meth_get_write(const BIO_METHOD *biom))(BIO *, const char *, int); int BIO_meth_set_write(BIO_METHOD *biom, int (*write)(BIO *, const char *, int)); -int (*BIO_meth_get_read(BIO_METHOD *biom))(BIO *, char *, int); +int (*BIO_meth_get_read(const BIO_METHOD *biom))(BIO *, char *, int); int BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int)); -int (*BIO_meth_get_puts(BIO_METHOD *biom))(BIO *, const char *); +int (*BIO_meth_get_puts(const BIO_METHOD *biom))(BIO *, const char *); int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *)); -int (*BIO_meth_get_gets(BIO_METHOD *biom))(BIO *, char *, int); +int (*BIO_meth_get_gets(const BIO_METHOD *biom))(BIO *, char *, int); int BIO_meth_set_gets(BIO_METHOD *biom, int (*gets)(BIO *, char *, int)); -long (*BIO_meth_get_ctrl(BIO_METHOD *biom))(BIO *, int, long, void *); +long (*BIO_meth_get_ctrl(const BIO_METHOD *biom))(BIO *, int, long, void *); int BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl)(BIO *, int, long, void *)); -int (*BIO_meth_get_create(BIO_METHOD *biom))(BIO *); +int (*BIO_meth_get_create(const BIO_METHOD *biom))(BIO *); int BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *)); -int (*BIO_meth_get_destroy(BIO_METHOD *biom))(BIO *); +int (*BIO_meth_get_destroy(const BIO_METHOD *biom))(BIO *); int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *)); -long (*BIO_meth_get_callback_ctrl(BIO_METHOD *biom))(BIO *, int, BIO_info_cb *); +long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, BIO_info_cb *); int BIO_meth_set_callback_ctrl(BIO_METHOD *biom, long (*callback_ctrl)(BIO *, int, BIO_info_cb *)); @@ -597,12 +597,12 @@ BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, asn1_ps_func **psuffix_free); int BIO_get_new_index(void); -BIO_METHOD *BIO_s_file(void ); +const BIO_METHOD *BIO_s_file(void); BIO *BIO_new_file(const char *filename, const char *mode); BIO *BIO_new_fp(FILE *stream, int close_flag); # define BIO_s_file_internal BIO_s_file -BIO * BIO_new(BIO_METHOD *type); -int BIO_set(BIO *a, BIO_METHOD *type); +BIO *BIO_new(const BIO_METHOD *type); +int BIO_set(BIO *a, const BIO_METHOD *type); int BIO_free(BIO *a); int BIO_up_ref(BIO *bio); void *BIO_get_data(BIO *a); @@ -641,20 +641,20 @@ int BIO_nwrite(BIO *bio, char **buf, int num); long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret); -BIO_METHOD *BIO_s_mem(void); -BIO *BIO_new_mem_buf(void *buf, int len); -BIO_METHOD *BIO_s_socket(void); -BIO_METHOD *BIO_s_connect(void); -BIO_METHOD *BIO_s_accept(void); -BIO_METHOD *BIO_s_fd(void); -BIO_METHOD *BIO_s_log(void); -BIO_METHOD *BIO_s_bio(void); -BIO_METHOD *BIO_s_null(void); -BIO_METHOD *BIO_f_null(void); -BIO_METHOD *BIO_f_buffer(void); -BIO_METHOD *BIO_f_nbio_test(void); +const BIO_METHOD *BIO_s_mem(void); +BIO *BIO_new_mem_buf(const void *buf, int len); +const BIO_METHOD *BIO_s_socket(void); +const BIO_METHOD *BIO_s_connect(void); +const BIO_METHOD *BIO_s_accept(void); +const BIO_METHOD *BIO_s_fd(void); +const BIO_METHOD *BIO_s_log(void); +const BIO_METHOD *BIO_s_bio(void); +const BIO_METHOD *BIO_s_null(void); +const BIO_METHOD *BIO_f_null(void); +const BIO_METHOD *BIO_f_buffer(void); +const BIO_METHOD *BIO_f_nbio_test(void); #ifndef OPENSSL_NO_DGRAM -BIO_METHOD *BIO_s_datagram(void); +const BIO_METHOD *BIO_s_datagram(void); #endif /* BIO_METHOD *BIO_f_ber(void); */ @@ -698,8 +698,8 @@ int BIO_set_tcp_ndelay(int sock, int turn_on); BIO *BIO_new_socket(int sock, int close_flag); BIO *BIO_new_dgram(int fd, int close_flag); BIO *BIO_new_fd(int fd, int close_flag); -BIO *BIO_new_connect(char *host_port); -BIO *BIO_new_accept(char *host_port); +BIO *BIO_new_connect(const char *host_port); +BIO *BIO_new_accept(const char *host_port); int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, diff --git a/lib/libcrypto/bio/bio_lib.c b/lib/libcrypto/bio/bio_lib.c index ddab542881..de039a7f5d 100644 --- a/lib/libcrypto/bio/bio_lib.c +++ b/lib/libcrypto/bio/bio_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_lib.c,v 1.27 2018/02/22 16:38:43 jsing Exp $ */ +/* $OpenBSD: bio_lib.c,v 1.28 2018/05/01 13:29:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -79,7 +79,7 @@ BIO_get_new_index(void) } BIO * -BIO_new(BIO_METHOD *method) +BIO_new(const BIO_METHOD *method) { BIO *ret = NULL; @@ -96,7 +96,7 @@ BIO_new(BIO_METHOD *method) } int -BIO_set(BIO *bio, BIO_METHOD *method) +BIO_set(BIO *bio, const BIO_METHOD *method) { bio->method = method; bio->callback = NULL; diff --git a/lib/libcrypto/bio/bio_meth.c b/lib/libcrypto/bio/bio_meth.c index c795c3f231..4327c010b1 100644 --- a/lib/libcrypto/bio/bio_meth.c +++ b/lib/libcrypto/bio/bio_meth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_meth.c,v 1.5 2018/02/20 18:51:35 tb Exp $ */ +/* $OpenBSD: bio_meth.c,v 1.6 2018/06/02 04:41:12 tb Exp $ */ /* * Copyright (c) 2018 Theo Buehler * @@ -40,7 +40,7 @@ BIO_meth_free(BIO_METHOD *biom) } int -(*BIO_meth_get_write(BIO_METHOD *biom))(BIO *, const char *, int) +(*BIO_meth_get_write(const BIO_METHOD *biom))(BIO *, const char *, int) { return biom->bwrite; } @@ -53,7 +53,7 @@ BIO_meth_set_write(BIO_METHOD *biom, int (*write)(BIO *, const char *, int)) } int -(*BIO_meth_get_read(BIO_METHOD *biom))(BIO *, char *, int) +(*BIO_meth_get_read(const BIO_METHOD *biom))(BIO *, char *, int) { return biom->bread; } @@ -66,7 +66,7 @@ BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int)) } int -(*BIO_meth_get_puts(BIO_METHOD *biom))(BIO *, const char *) +(*BIO_meth_get_puts(const BIO_METHOD *biom))(BIO *, const char *) { return biom->bputs; } @@ -79,7 +79,7 @@ BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *)) } int -(*BIO_meth_get_gets(BIO_METHOD *biom))(BIO *, char *, int) +(*BIO_meth_get_gets(const BIO_METHOD *biom))(BIO *, char *, int) { return biom->bgets; } @@ -92,7 +92,7 @@ BIO_meth_set_gets(BIO_METHOD *biom, int (*gets)(BIO *, char *, int)) } long -(*BIO_meth_get_ctrl(BIO_METHOD *biom))(BIO *, int, long, void *) +(*BIO_meth_get_ctrl(const BIO_METHOD *biom))(BIO *, int, long, void *) { return biom->ctrl; } @@ -105,7 +105,7 @@ BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl)(BIO *, int, long, void *)) } int -(*BIO_meth_get_create(BIO_METHOD *biom))(BIO *) +(*BIO_meth_get_create(const BIO_METHOD *biom))(BIO *) { return biom->create; } @@ -118,7 +118,7 @@ BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *)) } int -(*BIO_meth_get_destroy(BIO_METHOD *biom))(BIO *) +(*BIO_meth_get_destroy(const BIO_METHOD *biom))(BIO *) { return biom->destroy; } @@ -131,7 +131,7 @@ BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *)) } long -(*BIO_meth_get_callback_ctrl(BIO_METHOD *biom))(BIO *, int, BIO_info_cb *) +(*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, BIO_info_cb *) { return (long (*)(BIO *, int, BIO_info_cb *))biom->callback_ctrl; /* XXX */ diff --git a/lib/libcrypto/bio/bss_acpt.c b/lib/libcrypto/bio/bss_acpt.c index 20508a7d5e..c95ddde7bb 100644 --- a/lib/libcrypto/bio/bss_acpt.c +++ b/lib/libcrypto/bio/bss_acpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_acpt.c,v 1.27 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bss_acpt.c,v 1.29 2018/05/12 18:51:59 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -100,7 +100,7 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a); #define ACPT_S_GET_ACCEPT_SOCKET 2 #define ACPT_S_OK 3 -static BIO_METHOD methods_acceptp = { +static const BIO_METHOD methods_acceptp = { .type = BIO_TYPE_ACCEPT, .name = "socket accept", .bwrite = acpt_write, @@ -111,7 +111,7 @@ static BIO_METHOD methods_acceptp = { .destroy = acpt_free }; -BIO_METHOD * +const BIO_METHOD * BIO_s_accept(void) { return (&methods_acceptp); @@ -436,7 +436,7 @@ acpt_puts(BIO *bp, const char *str) } BIO * -BIO_new_accept(char *str) +BIO_new_accept(const char *str) { BIO *ret; diff --git a/lib/libcrypto/bio/bss_bio.c b/lib/libcrypto/bio/bss_bio.c index 20eb9a9829..74f86a51ee 100644 --- a/lib/libcrypto/bio/bss_bio.c +++ b/lib/libcrypto/bio/bss_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_bio.c,v 1.23 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bss_bio.c,v 1.24 2018/05/01 13:29:09 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * @@ -94,7 +94,7 @@ static int bio_puts(BIO *bio, const char *str); static int bio_make_pair(BIO *bio1, BIO *bio2); static void bio_destroy_pair(BIO *bio); -static BIO_METHOD methods_biop = { +static const BIO_METHOD methods_biop = { .type = BIO_TYPE_BIO, .name = "BIO pair", .bwrite = bio_write, @@ -105,7 +105,7 @@ static BIO_METHOD methods_biop = { .destroy = bio_free }; -BIO_METHOD * +const BIO_METHOD * BIO_s_bio(void) { return &methods_biop; diff --git a/lib/libcrypto/bio/bss_conn.c b/lib/libcrypto/bio/bss_conn.c index 555273882c..46a37b0608 100644 --- a/lib/libcrypto/bio/bss_conn.c +++ b/lib/libcrypto/bio/bss_conn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_conn.c,v 1.33 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bss_conn.c,v 1.35 2018/05/12 18:51:59 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -106,7 +106,7 @@ static void conn_close_socket(BIO *data); BIO_CONNECT *BIO_CONNECT_new(void); void BIO_CONNECT_free(BIO_CONNECT *a); -static BIO_METHOD methods_connectp = { +static const BIO_METHOD methods_connectp = { .type = BIO_TYPE_CONNECT, .name = "socket connect", .bwrite = conn_write, @@ -319,7 +319,7 @@ BIO_CONNECT_free(BIO_CONNECT *a) free(a); } -BIO_METHOD * +const BIO_METHOD * BIO_s_connect(void) { return (&methods_connectp); @@ -583,7 +583,7 @@ conn_puts(BIO *bp, const char *str) } BIO * -BIO_new_connect(char *str) +BIO_new_connect(const char *str) { BIO *ret; diff --git a/lib/libcrypto/bio/bss_dgram.c b/lib/libcrypto/bio/bss_dgram.c index a9657402ce..794b6d1b56 100644 --- a/lib/libcrypto/bio/bss_dgram.c +++ b/lib/libcrypto/bio/bss_dgram.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_dgram.c,v 1.41 2015/07/20 23:15:28 doug Exp $ */ +/* $OpenBSD: bss_dgram.c,v 1.42 2018/05/12 17:47:53 tb Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -86,7 +86,7 @@ static int dgram_clear(BIO *bio); static int BIO_dgram_should_retry(int s); -static BIO_METHOD methods_dgramp = { +static const BIO_METHOD methods_dgramp = { .type = BIO_TYPE_DGRAM, .name = "datagram socket", .bwrite = dgram_write, @@ -112,7 +112,7 @@ typedef struct bio_dgram_data_st { } bio_dgram_data; -BIO_METHOD * +const BIO_METHOD * BIO_s_datagram(void) { return (&methods_dgramp); diff --git a/lib/libcrypto/bio/bss_fd.c b/lib/libcrypto/bio/bss_fd.c index b21dbd92ed..bbe08efc4e 100644 --- a/lib/libcrypto/bio/bss_fd.c +++ b/lib/libcrypto/bio/bss_fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_fd.c,v 1.18 2015/02/12 03:54:07 jsing Exp $ */ +/* $OpenBSD: bss_fd.c,v 1.19 2018/05/01 13:29:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -74,7 +74,7 @@ static int fd_new(BIO *h); static int fd_free(BIO *data); int BIO_fd_should_retry(int s); -static BIO_METHOD methods_fdp = { +static const BIO_METHOD methods_fdp = { .type = BIO_TYPE_FD, .name = "file descriptor", .bwrite = fd_write, @@ -86,7 +86,7 @@ static BIO_METHOD methods_fdp = { .destroy = fd_free }; -BIO_METHOD * +const BIO_METHOD * BIO_s_fd(void) { return (&methods_fdp); diff --git a/lib/libcrypto/bio/bss_file.c b/lib/libcrypto/bio/bss_file.c index 01f4a3ff3b..fe937388b2 100644 --- a/lib/libcrypto/bio/bss_file.c +++ b/lib/libcrypto/bio/bss_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_file.c,v 1.32 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bss_file.c,v 1.33 2018/05/30 00:23:04 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -98,7 +98,7 @@ static long file_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int file_new(BIO *h); static int file_free(BIO *data); -static BIO_METHOD methods_filep = { +static const BIO_METHOD methods_filep = { .type = BIO_TYPE_FILE, .name = "FILE pointer", .bwrite = file_write, @@ -148,7 +148,7 @@ BIO_new_fp(FILE *stream, int close_flag) return (ret); } -BIO_METHOD * +const BIO_METHOD * BIO_s_file(void) { return (&methods_filep); diff --git a/lib/libcrypto/bio/bss_log.c b/lib/libcrypto/bio/bss_log.c index fcaa985aa0..7ef1312d79 100644 --- a/lib/libcrypto/bio/bss_log.c +++ b/lib/libcrypto/bio/bss_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_log.c,v 1.21 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: bss_log.c,v 1.22 2018/05/01 13:29:10 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * @@ -81,7 +81,7 @@ static void xopenlog(BIO* bp, char* name, int level); static void xsyslog(BIO* bp, int priority, const char* string); static void xcloselog(BIO* bp); -static BIO_METHOD methods_slg = { +static const BIO_METHOD methods_slg = { .type = BIO_TYPE_MEM, .name = "syslog", .bwrite = slg_write, @@ -91,7 +91,7 @@ static BIO_METHOD methods_slg = { .destroy = slg_free }; -BIO_METHOD * +const BIO_METHOD * BIO_s_log(void) { return (&methods_slg); diff --git a/lib/libcrypto/bio/bss_mem.c b/lib/libcrypto/bio/bss_mem.c index be491ca152..e76e1ad2e7 100644 --- a/lib/libcrypto/bio/bss_mem.c +++ b/lib/libcrypto/bio/bss_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_mem.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bss_mem.c,v 1.17 2018/05/12 18:51:59 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -72,7 +72,7 @@ static long mem_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int mem_new(BIO *h); static int mem_free(BIO *data); -static BIO_METHOD mem_method = { +static const BIO_METHOD mem_method = { .type = BIO_TYPE_MEM, .name = "memory buffer", .bwrite = mem_write, @@ -87,14 +87,14 @@ static BIO_METHOD mem_method = { /* bio->num is used to hold the value to return on 'empty', if it is * 0, should_retry is not set */ -BIO_METHOD * +const BIO_METHOD * BIO_s_mem(void) { return (&mem_method); } BIO * -BIO_new_mem_buf(void *buf, int len) +BIO_new_mem_buf(const void *buf, int len) { BIO *ret; BUF_MEM *b; @@ -108,7 +108,7 @@ BIO_new_mem_buf(void *buf, int len) if (!(ret = BIO_new(BIO_s_mem()))) return NULL; b = (BUF_MEM *)ret->ptr; - b->data = buf; + b->data = (void *)buf; /* Trust in the BIO_FLAGS_MEM_RDONLY flag. */ b->length = sz; b->max = sz; ret->flags |= BIO_FLAGS_MEM_RDONLY; diff --git a/lib/libcrypto/bio/bss_null.c b/lib/libcrypto/bio/bss_null.c index 42ee626b13..c6de844da5 100644 --- a/lib/libcrypto/bio/bss_null.c +++ b/lib/libcrypto/bio/bss_null.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_null.c,v 1.10 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: bss_null.c,v 1.11 2018/05/01 13:29:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,7 +70,7 @@ static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int null_new(BIO *h); static int null_free(BIO *data); -static BIO_METHOD null_method = { +static const BIO_METHOD null_method = { .type = BIO_TYPE_NULL, .name = "NULL", .bwrite = null_write, @@ -82,7 +82,7 @@ static BIO_METHOD null_method = { .destroy = null_free }; -BIO_METHOD * +const BIO_METHOD * BIO_s_null(void) { return (&null_method); diff --git a/lib/libcrypto/bio/bss_sock.c b/lib/libcrypto/bio/bss_sock.c index dd470eb65e..9c650a8041 100644 --- a/lib/libcrypto/bio/bss_sock.c +++ b/lib/libcrypto/bio/bss_sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_sock.c,v 1.23 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: bss_sock.c,v 1.24 2018/05/01 13:29:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,7 +73,7 @@ static int sock_new(BIO *h); static int sock_free(BIO *data); int BIO_sock_should_retry(int s); -static BIO_METHOD methods_sockp = { +static const BIO_METHOD methods_sockp = { .type = BIO_TYPE_SOCKET, .name = "socket", .bwrite = sock_write, @@ -84,7 +84,7 @@ static BIO_METHOD methods_sockp = { .destroy = sock_free }; -BIO_METHOD * +const BIO_METHOD * BIO_s_socket(void) { return (&methods_sockp); diff --git a/lib/libcrypto/bn/bn_add.c b/lib/libcrypto/bn/bn_add.c index 334fb4f5d4..048a136b95 100644 --- a/lib/libcrypto/bn/bn_add.c +++ b/lib/libcrypto/bn/bn_add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_add.c,v 1.11 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bn_add.c,v 1.13 2018/07/23 18:07:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,61 +62,51 @@ #include "bn_lcl.h" -/* r can == a or b */ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { - const BIGNUM *tmp; - int a_neg = a->neg, ret; + int ret, r_neg; bn_check_top(a); bn_check_top(b); - /* a + b a+b - * a + -b a-b - * -a + b b-a - * -a + -b -(a+b) - */ - if (a_neg ^ b->neg) { - /* only one is negative */ - if (a_neg) - { tmp = a; - a = b; - b = tmp; - } - - /* we are now a - b */ - - if (BN_ucmp(a, b) < 0) { - if (!BN_usub(r, b, a)) - return (0); - r->neg = 1; + if (a->neg == b->neg) { + r_neg = a->neg; + ret = BN_uadd(r, a, b); + } else { + int cmp = BN_ucmp(a, b); + + if (cmp > 0) { + r_neg = a->neg; + ret = BN_usub(r, a, b); + } else if (cmp < 0) { + r_neg = b->neg; + ret = BN_usub(r, b, a); } else { - if (!BN_usub(r, a, b)) - return (0); - r->neg = 0; + r_neg = 0; + BN_zero(r); + ret = 1; } - return (1); } - ret = BN_uadd(r, a, b); - r->neg = a_neg; + r->neg = r_neg; bn_check_top(r); return ret; } -/* unsigned add of b to a */ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { int max, min, dif; - BN_ULONG *ap, *bp, *rp, carry, t1, t2; - const BIGNUM *tmp; + const BN_ULONG *ap, *bp; + BN_ULONG *rp, carry, t1, t2; bn_check_top(a); bn_check_top(b); if (a->top < b->top) { + const BIGNUM *tmp; + tmp = a; a = b; b = tmp; @@ -137,41 +127,28 @@ BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) carry = bn_add_words(rp, ap, bp, min); rp += min; ap += min; - bp += min; - - if (carry) { - while (dif) { - dif--; - t1 = *(ap++); - t2 = (t1 + 1) & BN_MASK2; - *(rp++) = t2; - if (t2) { - carry = 0; - break; - } - } - if (carry) { - /* carry != 0 => dif == 0 */ - *rp = 1; - r->top++; - } + + while (dif) { + dif--; + t1 = *(ap++); + t2 = (t1 + carry) & BN_MASK2; + *(rp++) = t2; + carry &= (t2 == 0); } - if (dif && rp != ap) - while (dif--) - /* copy remaining words if ap != rp */ - *(rp++) = *(ap++); + *rp = carry; + r->top += carry; + r->neg = 0; bn_check_top(r); return 1; } -/* unsigned subtraction of b from a, a must be larger than b. */ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { int max, min, dif; - BN_ULONG t1, t2, *ap, *bp, *rp; - int i, carry; + const BN_ULONG *ap, *bp; + BN_ULONG t1, t2, borrow, *rp; bn_check_top(a); bn_check_top(b); @@ -180,134 +157,67 @@ BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) min = b->top; dif = max - min; - if (dif < 0) /* hmm... should not be happening */ - { + if (dif < 0) { BNerror(BN_R_ARG2_LT_ARG3); - return (0); + return 0; } if (bn_wexpand(r, max) == NULL) - return (0); + return 0; ap = a->d; bp = b->d; rp = r->d; -#if 1 - carry = 0; - for (i = min; i != 0; i--) { - t1= *(ap++); - t2= *(bp++); - if (carry) { - carry = (t1 <= t2); - t1 = (t1 - t2 - 1)&BN_MASK2; - } else { - carry = (t1 < t2); - t1 = (t1 - t2)&BN_MASK2; - } - *(rp++) = t1&BN_MASK2; - } -#else - carry = bn_sub_words(rp, ap, bp, min); + borrow = bn_sub_words(rp, ap, bp, min); ap += min; - bp += min; rp += min; -#endif - if (carry) /* subtracted */ - { - if (!dif) - /* error: a < b */ - return 0; - while (dif) { - dif--; - t1 = *(ap++); - t2 = (t1 - 1)&BN_MASK2; - *(rp++) = t2; - if (t1) - break; - } - } -#if 0 - memcpy(rp, ap, sizeof(*rp)*(max - i)); -#else - if (rp != ap) { - for (;;) { - if (!dif--) - break; - rp[0] = ap[0]; - if (!dif--) - break; - rp[1] = ap[1]; - if (!dif--) - break; - rp[2] = ap[2]; - if (!dif--) - break; - rp[3] = ap[3]; - rp += 4; - ap += 4; - } + + while (dif) { + dif--; + t1 = *(ap++); + t2 = (t1 - borrow) & BN_MASK2; + *(rp++) = t2; + borrow &= (t1 == 0); } -#endif + + while (max > 0 && *--rp == 0) + max--; r->top = max; r->neg = 0; bn_correct_top(r); - return (1); + return 1; } int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { - int max; - int add = 0, neg = 0; - const BIGNUM *tmp; + int ret, r_neg; bn_check_top(a); bn_check_top(b); - /* a - b a-b - * a - -b a+b - * -a - b -(a+b) - * -a - -b b-a - */ - if (a->neg) { - if (b->neg) { - tmp = a; - a = b; - b = tmp; - } else { - add = 1; - neg = 1; - } + if (a->neg != b->neg) { + r_neg = a->neg; + ret = BN_uadd(r, a, b); } else { - if (b->neg) { - add = 1; - neg = 0; + int cmp = BN_ucmp(a, b); + + if (cmp > 0) { + r_neg = a->neg; + ret = BN_usub(r, a, b); + } else if (cmp < 0) { + r_neg = !b->neg; + ret = BN_usub(r, b, a); + } else { + r_neg = 0; + BN_zero(r); + ret = 1; } } - if (add) { - if (!BN_uadd(r, a, b)) - return (0); - r->neg = neg; - return (1); - } - - /* We are actually doing a - b :-) */ - - max = (a->top > b->top) ? a->top : b->top; - if (bn_wexpand(r, max) == NULL) - return (0); - if (BN_ucmp(a, b) < 0) { - if (!BN_usub(r, b, a)) - return (0); - r->neg = 1; - } else { - if (!BN_usub(r, a, b)) - return (0); - r->neg = 0; - } + r->neg = r_neg; bn_check_top(r); - return (1); + return ret; } diff --git a/lib/libcrypto/bn/bn_lcl.h b/lib/libcrypto/bn/bn_lcl.h index c010410cd1..b8319dd700 100644 --- a/lib/libcrypto/bn/bn_lcl.h +++ b/lib/libcrypto/bn/bn_lcl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lcl.h,v 1.27 2017/01/25 06:15:44 beck Exp $ */ +/* $OpenBSD: bn_lcl.h,v 1.29 2018/07/23 18:14:32 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -605,5 +605,8 @@ BIGNUM *BN_mod_inverse_nonct(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); int BN_gcd_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); int BN_gcd_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); + +int BN_swap_ct(BN_ULONG swap, BIGNUM *a, BIGNUM *b, size_t nwords); + __END_HIDDEN_DECLS #endif diff --git a/lib/libcrypto/bn/bn_lib.c b/lib/libcrypto/bn/bn_lib.c index ffb5ee7c2e..0b79a87413 100644 --- a/lib/libcrypto/bn/bn_lib.c +++ b/lib/libcrypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.39 2018/02/20 17:13:14 jsing Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.45 2018/07/23 18:14:32 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -529,7 +529,7 @@ BN_clear(BIGNUM *a) { bn_check_top(a); if (a->d != NULL) - memset(a->d, 0, a->dmax * sizeof(a->d[0])); + explicit_bzero(a->d, a->dmax * sizeof(a->d[0])); a->top = 0; a->neg = 0; } @@ -837,8 +837,10 @@ bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl) /* * Constant-time conditional swap of a and b. - * a and b are swapped if condition is not 0. The code assumes that at most one bit of condition is set. - * nwords is the number of words to swap. The code assumes that at least nwords are allocated in both a and b, + * a and b are swapped if condition is not 0. + * The code assumes that at most one bit of condition is set. + * nwords is the number of words to swap. + * The code assumes that at least nwords are allocated in both a and b, * and that no more than nwords are used by either a or b. * a and b cannot be the same number */ @@ -889,6 +891,57 @@ BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords) #undef BN_CONSTTIME_SWAP } +/* + * Constant-time conditional swap of a and b. + * a and b are swapped if condition is not 0. + * nwords is the number of words to swap. + */ +int +BN_swap_ct(BN_ULONG condition, BIGNUM *a, BIGNUM *b, size_t nwords) +{ + BN_ULONG t; + int i, words; + + if (a == b) + return 1; + if (nwords > INT_MAX) + return 0; + words = (int)nwords; + if (bn_wexpand(a, words) == NULL || bn_wexpand(b, words) == NULL) + return 0; + if (a->top > words || b->top > words) { + BNerror(BN_R_INVALID_LENGTH); + return 0; + } + + /* Set condition to 0 (if it was zero) or all 1s otherwise. */ + condition = ((~condition & (condition - 1)) >> (BN_BITS2 - 1)) - 1; + + /* swap top field */ + t = (a->top ^ b->top) & condition; + a->top ^= t; + b->top ^= t; + + /* swap neg field */ + t = (a->neg ^ b->neg) & condition; + a->neg ^= t; + b->neg ^= t; + + /* swap BN_FLG_CONSTTIME from flag field */ + t = ((a->flags ^ b->flags) & BN_FLG_CONSTTIME) & condition; + a->flags ^= t; + b->flags ^= t; + + /* swap the data */ + for (i = 0; i < words; i++) { + t = (a->d[i] ^ b->d[i]) & condition; + a->d[i] ^= t; + b->d[i] ^= t; + } + + return 1; +} + BN_GENCB * BN_GENCB_new(void) { diff --git a/lib/libcrypto/cert.pem b/lib/libcrypto/cert.pem index 301fc8dc35..6587ae5950 100644 --- a/lib/libcrypto/cert.pem +++ b/lib/libcrypto/cert.pem @@ -1,4 +1,4 @@ -# $OpenBSD: cert.pem,v 1.16 2018/03/21 15:26:09 sthen Exp $ +# $OpenBSD: cert.pem,v 1.17 2018/09/12 22:17:08 sthen Exp $ ### /C=ES/CN=Autoridad de Certificacion Firmaprofesional CIF A62634068 === /C=ES/CN=Autoridad de Certificacion Firmaprofesional CIF A62634068 @@ -5340,53 +5340,6 @@ e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p TpPDpFQUWw== -----END CERTIFICATE----- -### T\DCRKTRUST Bilgi \U0130leti\U015Fim ve Bili\U015Fim G\FCvenli\U011Fi Hizmetleri A.\U015E. - -=== /C=TR/L=Ankara/O=T\xC3\x9CRKTRUST Bilgi \xC4\xB0leti\xC5\x9Fim ve Bili\xC5\x9Fim G\xC3\xBCvenli\xC4\x9Fi Hizmetleri A.\xC5\x9E./CN=T\xC3\x9CRKTRUST Elektronik Sertifika Hizmet Sa\xC4\x9Flay\xC4\xB1c\xC4\xB1s\xC4\xB1 H5 -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 156233699172481 (0x8e17fe242081) - Signature Algorithm: sha256WithRSAEncryption - Validity - Not Before: Apr 30 08:07:01 2013 GMT - Not After : Apr 28 08:07:01 2023 GMT - Subject: C=TR, L=Ankara, O=T\xC3\x9CRKTRUST Bilgi \xC4\xB0leti\xC5\x9Fim ve Bili\xC5\x9Fim G\xC3\xBCvenli\xC4\x9Fi Hizmetleri A.\xC5\x9E., CN=T\xC3\x9CRKTRUST Elektronik Sertifika Hizmet Sa\xC4\x9Flay\xC4\xB1c\xC4\xB1s\xC4\xB1 H5 - X509v3 extensions: - X509v3 Subject Key Identifier: - 56:99:07:1E:D3:AC:0C:69:64:B4:0C:50:47:DE:43:2C:BE:20:C0:FB - X509v3 Key Usage: critical - Certificate Sign, CRL Sign - X509v3 Basic Constraints: critical - CA:TRUE -SHA1 Fingerprint=C4:18:F6:4D:46:D1:DF:00:3D:27:30:13:72:43:A9:12:11:C6:75:FB -SHA256 Fingerprint=49:35:1B:90:34:44:C1:85:CC:DC:5C:69:3D:24:D8:55:5C:B2:08:D6:A8:14:13:07:69:9F:4A:F0:63:19:9D:78 ------BEGIN CERTIFICATE----- -MIIEJzCCAw+gAwIBAgIHAI4X/iQggTANBgkqhkiG9w0BAQsFADCBsTELMAkGA1UE -BhMCVFIxDzANBgNVBAcMBkFua2FyYTFNMEsGA1UECgxEVMOcUktUUlVTVCBCaWxn -aSDEsGxldGnFn2ltIHZlIEJpbGnFn2ltIEfDvHZlbmxpxJ9pIEhpem1ldGxlcmkg -QS7Fni4xQjBABgNVBAMMOVTDnFJLVFJVU1QgRWxla3Ryb25payBTZXJ0aWZpa2Eg -SGl6bWV0IFNhxJ9sYXnEsWPEsXPEsSBINTAeFw0xMzA0MzAwODA3MDFaFw0yMzA0 -MjgwODA3MDFaMIGxMQswCQYDVQQGEwJUUjEPMA0GA1UEBwwGQW5rYXJhMU0wSwYD -VQQKDERUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8 -dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLjFCMEAGA1UEAww5VMOcUktUUlVTVCBF -bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxIEg1MIIB -IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApCUZ4WWe60ghUEoI5RHwWrom -/4NZzkQqL/7hzmAD/I0Dpe3/a6i6zDQGn1k19uwsu537jVJp45wnEFPzpALFp/kR -Gml1bsMdi9GYjZOHp3GXDSHHmflS0yxjXVW86B8BSLlg/kJK9siArs1mep5Fimh3 -4khon6La8eHBEJ/rPCmBp+EyCNSgBbGM+42WAA4+Jd9ThiI7/PS98wl+d+yG6w8z -5UNP9FR1bSmZLmZaQ9/LXMrI5Tjxfjs1nQ/0xVqhzPMggCTTV+wVunUlm+hkS7M0 -hO8EuPbJbKoCPrZV4jI3X/xml1/N1p7HIL9Nxqw/dV8c7TKcfGkAaZHjIxhT6QID -AQABo0IwQDAdBgNVHQ4EFgQUVpkHHtOsDGlktAxQR95DLL4gwPswDgYDVR0PAQH/ -BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAJ5FdnsX -SDLyOIspve6WSk6BGLFRRyDN0GSxDsnZAdkJzsiZ3GglE9Rc8qPoBP5yCccLqh0l -VX6Wmle3usURehnmp349hQ71+S4pL+f5bFgWV1Al9j4uPqrtd3GqqpmWRgqujuwq -URawXs3qZwQcWDD1YIq9pr1N5Za0/EKJAWv2cMhQOQwt1WbZyNKzMrcbGW3LM/nf -peYVhDfwwvJllpKQd/Ct9JDpEXjXk4nAPQu6KfTomZ1yju2dL+6SfaHx/126M2CF -Yv4HAqGEVka+lgqaE9chTLd8B59OTj+RdPsnnRHM3eaxynFNExc5JsUpISuTKWqW -+qtB4Uu2NQvAmxU= ------END CERTIFICATE----- - ### TAIWAN-CA === /C=TW/O=TAIWAN-CA/OU=Root CA/CN=TWCA Global Root CA diff --git a/lib/libcrypto/compat/include/unistd.h b/lib/libcrypto/compat/include/unistd.h index d596043318..f521b943b3 100644 --- a/lib/libcrypto/compat/include/unistd.h +++ b/lib/libcrypto/compat/include/unistd.h @@ -7,7 +7,16 @@ #define LIBCRYPTOCOMPAT_UNISTD_H #ifndef _MSC_VER + #include_next + +#ifdef __MINGW32__ +int ftruncate(int fd, off_t length); +uid_t getuid(void); +ssize_t pread(int d, void *buf, size_t nbytes, off_t offset); +ssize_t pwrite(int d, const void *buf, size_t nbytes, off_t offset); +#endif + #else #include @@ -22,10 +31,19 @@ #define X_OK 0 #define F_OK 0 +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + #define access _access unsigned int sleep(unsigned int seconds); +int ftruncate(int fd, off_t length); +uid_t getuid(void); +ssize_t pread(int d, void *buf, size_t nbytes, off_t offset); +ssize_t pwrite(int d, const void *buf, size_t nbytes, off_t offset); + #endif #ifndef HAVE_GETENTROPY @@ -44,6 +62,7 @@ int getpagesize(void); #endif #define pledge(request, paths) 0 +#define unveil(path, permissions) 0 #ifndef HAVE_PIPE2 int pipe2(int fildes[2], int flags); diff --git a/lib/libcrypto/crypto.h b/lib/libcrypto/crypto.h index 67e06a1509..e614c6ad65 100644 --- a/lib/libcrypto/crypto.h +++ b/lib/libcrypto/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.45 2018/03/19 03:35:38 beck Exp $ */ +/* $OpenBSD: crypto.h,v 1.47 2018/08/24 19:16:03 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -299,6 +299,7 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) * via CRYPTO_ex_data_new_class). */ #define CRYPTO_EX_INDEX_USER 100 +#ifndef LIBRESSL_INTERNAL #define CRYPTO_malloc_init() (0) #define CRYPTO_malloc_debug_init() (0) @@ -329,6 +330,7 @@ int CRYPTO_is_mem_check_on(void); #define OPENSSL_malloc_locked(num) \ CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) #define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) +#endif const char *OpenSSL_version(int type); #define OPENSSL_VERSION 0 @@ -493,11 +495,11 @@ long CRYPTO_dbg_get_options(void) __attribute__ ((deprecated)); -void CRYPTO_mem_leaks_fp(FILE *); -void CRYPTO_mem_leaks(struct bio_st *bio); +int CRYPTO_mem_leaks_fp(FILE *); +int CRYPTO_mem_leaks(struct bio_st *bio); /* unsigned long order, char *file, int line, int num_bytes, char *addr */ -typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); -void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); +typedef int *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); +int CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); /* die if we have to */ void OpenSSLDie(const char *file, int line, const char *assertion); diff --git a/lib/libcrypto/dh/dh_ameth.c b/lib/libcrypto/dh/dh_ameth.c index 0402092a4f..5054d17a3f 100644 --- a/lib/libcrypto/dh/dh_ameth.c +++ b/lib/libcrypto/dh/dh_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_ameth.c,v 1.14 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: dh_ameth.c,v 1.17 2018/08/24 20:22:15 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -78,8 +78,8 @@ dh_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) const unsigned char *p, *pm; int pklen, pmlen; int ptype; - void *pval; - ASN1_STRING *pstr; + const void *pval; + const ASN1_STRING *pstr; X509_ALGOR *palg; ASN1_INTEGER *public_key = NULL; DH *dh = NULL; @@ -180,14 +180,14 @@ err: */ static int -dh_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) +dh_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) { const unsigned char *p, *pm; int pklen, pmlen; int ptype; - void *pval; - ASN1_STRING *pstr; - X509_ALGOR *palg; + const void *pval; + const ASN1_STRING *pstr; + const X509_ALGOR *palg; ASN1_INTEGER *privkey = NULL; DH *dh = NULL; diff --git a/lib/libcrypto/dh/dh_key.c b/lib/libcrypto/dh/dh_key.c index d79e98e785..3920a00d09 100644 --- a/lib/libcrypto/dh/dh_key.c +++ b/lib/libcrypto/dh/dh_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_key.c,v 1.27.2.1 2018/06/13 15:13:30 jsing Exp $ */ +/* $OpenBSD: dh_key.c,v 1.29 2018/06/12 15:33:18 sthen Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -200,7 +200,7 @@ compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) BN_CTX_start(ctx); if ((tmp = BN_CTX_get(ctx)) == NULL) goto err; - + if (dh->priv_key == NULL) { DHerror(DH_R_NO_PRIVATE_VALUE); goto err; diff --git a/lib/libcrypto/dh/dh_lib.c b/lib/libcrypto/dh/dh_lib.c index 2153b42a3b..446bc65aa2 100644 --- a/lib/libcrypto/dh/dh_lib.c +++ b/lib/libcrypto/dh/dh_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_lib.c,v 1.30.2.1 2018/05/02 16:57:35 tb Exp $ */ +/* $OpenBSD: dh_lib.c,v 1.32 2018/05/02 15:48:38 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -98,10 +98,8 @@ DH_set_method(DH *dh, const DH_METHOD *meth) if (mtmp->finish) mtmp->finish(dh); #ifndef OPENSSL_NO_ENGINE - if (dh->engine) { - ENGINE_finish(dh->engine); - dh->engine = NULL; - } + ENGINE_finish(dh->engine); + dh->engine = NULL; #endif dh->meth = meth; if (meth->init) @@ -139,7 +137,7 @@ DH_new_method(ENGINE *engine) ret->engine = ENGINE_get_default_DH(); if(ret->engine) { ret->meth = ENGINE_get_DH(ret->engine); - if (!ret->meth) { + if (ret->meth == NULL) { DHerror(ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); @@ -166,8 +164,7 @@ DH_new_method(ENGINE *engine) CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); if (ret->meth->init != NULL && !ret->meth->init(ret)) { #ifndef OPENSSL_NO_ENGINE - if (ret->engine) - ENGINE_finish(ret->engine); + ENGINE_finish(ret->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); free(ret); @@ -190,8 +187,7 @@ DH_free(DH *r) if (r->meth->finish) r->meth->finish(r); #ifndef OPENSSL_NO_ENGINE - if (r->engine) - ENGINE_finish(r->engine); + ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); diff --git a/lib/libcrypto/dsa/dsa_ameth.c b/lib/libcrypto/dsa/dsa_ameth.c index 92f543de9e..26d81eed7b 100644 --- a/lib/libcrypto/dsa/dsa_ameth.c +++ b/lib/libcrypto/dsa/dsa_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_ameth.c,v 1.23 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: dsa_ameth.c,v 1.26 2018/08/24 20:22:15 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -75,8 +75,8 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) const unsigned char *p, *pm; int pklen, pmlen; int ptype; - void *pval; - ASN1_STRING *pstr; + const void *pval; + const ASN1_STRING *pstr; X509_ALGOR *palg; ASN1_INTEGER *public_key = NULL; @@ -179,14 +179,14 @@ err: * AlgorithmIdentifier the pubkey must be recalculated. */ static int -dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) +dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) { const unsigned char *p, *pm; int pklen, pmlen; int ptype; - void *pval; - ASN1_STRING *pstr; - X509_ALGOR *palg; + const void *pval; + const ASN1_STRING *pstr; + const X509_ALGOR *palg; ASN1_INTEGER *privkey = NULL; BN_CTX *ctx = NULL; DSA *dsa = NULL; diff --git a/lib/libcrypto/dsa/dsa_asn1.c b/lib/libcrypto/dsa/dsa_asn1.c index aac67dbd03..23f08bb1f9 100644 --- a/lib/libcrypto/dsa/dsa_asn1.c +++ b/lib/libcrypto/dsa/dsa_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_asn1.c,v 1.21 2018/02/20 17:48:35 tb Exp $ */ +/* $OpenBSD: dsa_asn1.c,v 1.22 2018/06/14 17:03:19 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -71,13 +71,10 @@ sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) if (operation == ASN1_OP_NEW_PRE) { DSA_SIG *sig; - sig = malloc(sizeof(DSA_SIG)); - if (!sig) { + if ((sig = DSA_SIG_new()) == NULL) { DSAerror(ERR_R_MALLOC_FAILURE); return 0; } - sig->r = NULL; - sig->s = NULL; *pval = (ASN1_VALUE *)sig; return 2; } diff --git a/lib/libcrypto/dsa/dsa_lib.c b/lib/libcrypto/dsa/dsa_lib.c index 8190d07348..d5fdd6e78e 100644 --- a/lib/libcrypto/dsa/dsa_lib.c +++ b/lib/libcrypto/dsa/dsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_lib.c,v 1.28 2018/02/20 17:52:27 tb Exp $ */ +/* $OpenBSD: dsa_lib.c,v 1.29 2018/04/14 07:09:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -108,10 +108,8 @@ DSA_set_method(DSA *dsa, const DSA_METHOD *meth) if (mtmp->finish) mtmp->finish(dsa); #ifndef OPENSSL_NO_ENGINE - if (dsa->engine) { - ENGINE_finish(dsa->engine); - dsa->engine = NULL; - } + ENGINE_finish(dsa->engine); + dsa->engine = NULL; #endif dsa->meth = meth; if (meth->init) @@ -142,7 +140,7 @@ DSA_new_method(ENGINE *engine) ret->engine = ENGINE_get_default_DSA(); if (ret->engine) { ret->meth = ENGINE_get_DSA(ret->engine); - if (!ret->meth) { + if (ret->meth == NULL) { DSAerror(ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); @@ -170,8 +168,7 @@ DSA_new_method(ENGINE *engine) CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); if (ret->meth->init != NULL && !ret->meth->init(ret)) { #ifndef OPENSSL_NO_ENGINE - if (ret->engine) - ENGINE_finish(ret->engine); + ENGINE_finish(ret->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); free(ret); @@ -196,8 +193,7 @@ DSA_free(DSA *r) if (r->meth->finish) r->meth->finish(r); #ifndef OPENSSL_NO_ENGINE - if (r->engine) - ENGINE_finish(r->engine); + ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); diff --git a/lib/libcrypto/dsa/dsa_ossl.c b/lib/libcrypto/dsa/dsa_ossl.c index 4e75512df8..c9399573ab 100644 --- a/lib/libcrypto/dsa/dsa_ossl.c +++ b/lib/libcrypto/dsa/dsa_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_ossl.c,v 1.30.2.1 2018/06/13 15:08:08 jsing Exp $ */ +/* $OpenBSD: dsa_ossl.c,v 1.37 2018/06/14 18:34:50 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,9 +70,9 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, - BIGNUM **rp); + BIGNUM **rp); static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, - DSA *dsa); + DSA *dsa); static int dsa_init(DSA *dsa); static int dsa_finish(DSA *dsa); @@ -82,7 +82,7 @@ static DSA_METHOD openssl_dsa_meth = { .dsa_sign_setup = dsa_sign_setup, .dsa_do_verify = dsa_do_verify, .init = dsa_init, - .finish = dsa_finish + .finish = dsa_finish, }; const DSA_METHOD * @@ -94,16 +94,17 @@ DSA_OpenSSL(void) static DSA_SIG * dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) { - BIGNUM *kinv = NULL, *r = NULL, *s = NULL; - BIGNUM m; - BIGNUM xr; + BIGNUM b, bm, bxr, binv, m, *kinv = NULL, *r = NULL, *s = NULL; BN_CTX *ctx = NULL; int reason = ERR_R_BN_LIB; DSA_SIG *ret = NULL; int noredo = 0; + BN_init(&b); + BN_init(&binv); + BN_init(&bm); + BN_init(&bxr); BN_init(&m); - BN_init(&xr); if (!dsa->p || !dsa->q || !dsa->g) { reason = DSA_R_MISSING_PARAMETERS; @@ -116,7 +117,18 @@ dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) ctx = BN_CTX_new(); if (ctx == NULL) goto err; -redo: + + /* + * If the digest length is greater than N (the bit length of q), the + * leftmost N bits of the digest shall be used, see FIPS 186-3, 4.2. + * In this case the digest length is given in bytes. + */ + if (dlen > BN_num_bytes(dsa->q)) + dlen = BN_num_bytes(dsa->q); + if (BN_bin2bn(dgst, dlen, &m) == NULL) + goto err; + + redo: if (dsa->kinv == NULL || dsa->r == NULL) { if (!DSA_sign_setup(dsa, ctx, &kinv, &r)) goto err; @@ -128,31 +140,43 @@ redo: noredo = 1; } - /* - * If the digest length is greater than the size of q use the - * BN_num_bits(dsa->q) leftmost bits of the digest, see - * fips 186-3, 4.2 + * Compute: + * + * s = inv(k)(m + xr) mod q + * + * In order to reduce the possibility of a side-channel attack, the + * following is calculated using a blinding value: + * + * s = inv(k)inv(b)(bm + bxr) mod q + * + * Where b is a random value in the range [1, q-1]. */ - if (dlen > BN_num_bytes(dsa->q)) - dlen = BN_num_bytes(dsa->q); - if (BN_bin2bn(dgst,dlen,&m) == NULL) + if (!BN_sub(&bm, dsa->q, BN_value_one())) + goto err; + if (!BN_rand_range(&b, &bm)) + goto err; + if (!BN_add(&b, &b, BN_value_one())) + goto err; + if (BN_mod_inverse_ct(&binv, &b, dsa->q, ctx) == NULL) goto err; - /* Compute s = inv(k) (m + xr) mod q */ - if (!BN_mod_mul(&xr, dsa->priv_key, r, dsa->q, ctx)) /* s = xr */ + if (!BN_mod_mul(&bxr, &b, dsa->priv_key, dsa->q, ctx)) /* bx */ + goto err; + if (!BN_mod_mul(&bxr, &bxr, r, dsa->q, ctx)) /* bxr */ + goto err; + if (!BN_mod_mul(&bm, &b, &m, dsa->q, ctx)) /* bm */ goto err; - if (!BN_mod_add(s, &xr, &m, dsa->q, ctx)) /* s = m + xr */ + if (!BN_mod_add(s, &bxr, &bm, dsa->q, ctx)) /* s = bm + bxr */ + goto err; + if (!BN_mod_mul(s, s, &binv, dsa->q, ctx)) /* s = m + xr */ goto err; if (!BN_mod_mul(s, s, kinv, dsa->q, ctx)) goto err; - ret = DSA_SIG_new(); - if (ret == NULL) - goto err; /* - * Redo if r or s is zero as required by FIPS 186-3: this is - * very unlikely. + * Redo if r or s is zero as required by FIPS 186-3: this is very + * unlikely. */ if (BN_is_zero(r) || BN_is_zero(s)) { if (noredo) { @@ -161,19 +185,28 @@ redo: } goto redo; } + + if ((ret = DSA_SIG_new()) == NULL) { + reason = ERR_R_MALLOC_FAILURE; + goto err; + } ret->r = r; ret->s = s; -err: + err: if (!ret) { DSAerror(reason); BN_free(r); BN_free(s); } BN_CTX_free(ctx); + BN_clear_free(&b); + BN_clear_free(&bm); + BN_clear_free(&bxr); + BN_clear_free(&binv); BN_clear_free(&m); - BN_clear_free(&xr); BN_clear_free(kinv); + return ret; } @@ -181,8 +214,8 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { BN_CTX *ctx; - BIGNUM k, *kinv = NULL, *r = NULL; - int ret = 0; + BIGNUM k, l, m, *kinv = NULL, *r = NULL; + int q_bits, ret = 0; if (!dsa->p || !dsa->q || !dsa->g) { DSAerror(DSA_R_MISSING_PARAMETERS); @@ -190,6 +223,8 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) } BN_init(&k); + BN_init(&l); + BN_init(&m); if (ctx_in == NULL) { if ((ctx = BN_CTX_new()) == NULL) @@ -200,6 +235,13 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) if ((r = BN_new()) == NULL) goto err; + /* Preallocate space */ + q_bits = BN_num_bits(dsa->q); + if (!BN_set_bit(&k, q_bits) || + !BN_set_bit(&l, q_bits) || + !BN_set_bit(&m, q_bits)) + goto err; + /* Get random k */ do { if (!BN_rand_range(&k, dsa->q)) @@ -218,30 +260,33 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) /* * We do not want timing information to leak the length of k, - * so we compute g^k using an equivalent exponent of fixed - * length. + * so we compute G^k using an equivalent exponent of fixed + * bit-length. + * + * We unconditionally perform both of these additions to prevent a + * small timing information leakage. We then choose the sum that is + * one bit longer than the modulus. * - * (This is a kludge that we need because the BN_mod_exp_mont() - * does not let us specify the desired timing behaviour.) + * TODO: revisit the BN_copy aiming for a memory access agnostic + * conditional copy. */ - if (!BN_add(&k, &k, dsa->q)) + if (!BN_add(&l, &k, dsa->q) || + !BN_add(&m, &l, dsa->q) || + !BN_copy(&k, BN_num_bits(&l) > q_bits ? &l : &m)) goto err; - if (BN_num_bits(&k) <= BN_num_bits(dsa->q)) { - if (!BN_add(&k, &k, dsa->q)) - goto err; - } if (dsa->meth->bn_mod_exp != NULL) { if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, &k, dsa->p, ctx, - dsa->method_mont_p)) + dsa->method_mont_p)) goto err; } else { - if (!BN_mod_exp_mont_ct(r, dsa->g, &k, dsa->p, ctx, dsa->method_mont_p)) + if (!BN_mod_exp_mont_ct(r, dsa->g, &k, dsa->p, ctx, + dsa->method_mont_p)) goto err; } - if (!BN_mod_ct(r,r,dsa->q,ctx)) + if (!BN_mod_ct(r, r, dsa->q, ctx)) goto err; /* Compute part of 's = inv(k) (m + xr) mod q' */ @@ -253,8 +298,10 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) kinv = NULL; BN_clear_free(*rp); *rp = r; + ret = 1; -err: + + err: if (!ret) { DSAerror(ERR_R_BN_LIB); BN_clear_free(r); @@ -262,6 +309,9 @@ err: if (ctx_in == NULL) BN_CTX_free(ctx); BN_clear_free(&k); + BN_clear_free(&l); + BN_clear_free(&m); + return ret; } @@ -279,7 +329,7 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) } i = BN_num_bits(dsa->q); - /* fips 186-3 allows only different sizes for q */ + /* FIPS 186-3 allows only three different sizes for q. */ if (i != 160 && i != 224 && i != 256) { DSAerror(DSA_R_BAD_Q_VALUE); return -1; @@ -307,23 +357,22 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) goto err; } - /* Calculate W = inv(S) mod Q - * save W in u2 */ + /* Calculate w = inv(s) mod q, saving w in u2. */ if ((BN_mod_inverse_ct(&u2, sig->s, dsa->q, ctx)) == NULL) goto err; - /* save M in u1 */ /* * If the digest length is greater than the size of q use the - * BN_num_bits(dsa->q) leftmost bits of the digest, see - * fips 186-3, 4.2 + * BN_num_bits(dsa->q) leftmost bits of the digest, see FIPS 186-3, 4.2. */ if (dgst_len > (i >> 3)) dgst_len = (i >> 3); + + /* Save m in u1. */ if (BN_bin2bn(dgst, dgst_len, &u1) == NULL) goto err; - /* u1 = M * w mod q */ + /* u1 = m * w mod q */ if (!BN_mod_mul(&u1, &u1, &u2, dsa->q, ctx)) goto err; @@ -331,7 +380,6 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) if (!BN_mod_mul(&u2, sig->r, &u2, dsa->q, ctx)) goto err; - if (dsa->flags & DSA_FLAG_CACHE_MONT_P) { mont = BN_MONT_CTX_set_locked(&dsa->method_mont_p, CRYPTO_LOCK_DSA, dsa->p, ctx); @@ -340,12 +388,12 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) } if (dsa->meth->dsa_mod_exp != NULL) { - if (!dsa->meth->dsa_mod_exp(dsa, &t1, dsa->g, &u1, dsa->pub_key, &u2, - dsa->p, ctx, mont)) + if (!dsa->meth->dsa_mod_exp(dsa, &t1, dsa->g, &u1, dsa->pub_key, + &u2, dsa->p, ctx, mont)) goto err; } else { - if (!BN_mod_exp2_mont(&t1, dsa->g, &u1, dsa->pub_key, &u2, dsa->p, ctx, - mont)) + if (!BN_mod_exp2_mont(&t1, dsa->g, &u1, dsa->pub_key, &u2, + dsa->p, ctx, mont)) goto err; } @@ -354,17 +402,17 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) if (!BN_mod_ct(&u1, &t1, dsa->q, ctx)) goto err; - /* V is now in u1. If the signature is correct, it will be - * equal to R. */ + /* v is in u1 - if the signature is correct, it will be equal to r. */ ret = BN_ucmp(&u1, sig->r) == 0; -err: + err: if (ret < 0) DSAerror(ERR_R_BN_LIB); BN_CTX_free(ctx); BN_free(&u1); BN_free(&u2); BN_free(&t1); + return ret; } diff --git a/lib/libcrypto/dsa/dsa_sign.c b/lib/libcrypto/dsa/dsa_sign.c index 355bdd20d6..0f55ea1868 100644 --- a/lib/libcrypto/dsa/dsa_sign.c +++ b/lib/libcrypto/dsa/dsa_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_sign.c,v 1.19 2014/10/18 17:20:40 jsing Exp $ */ +/* $OpenBSD: dsa_sign.c,v 1.20 2018/06/14 17:01:49 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -76,20 +76,13 @@ DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) DSA_SIG * DSA_SIG_new(void) { - DSA_SIG *sig; - - sig = malloc(sizeof(DSA_SIG)); - if (!sig) - return NULL; - sig->r = NULL; - sig->s = NULL; - return sig; + return calloc(1, sizeof(DSA_SIG)); } void DSA_SIG_free(DSA_SIG *sig) { - if (sig) { + if (sig != NULL) { BN_free(sig->r); BN_free(sig->s); free(sig); diff --git a/lib/libcrypto/dso/dso_lib.c b/lib/libcrypto/dso/dso_lib.c index 7902fbcc6e..6dc98803ec 100644 --- a/lib/libcrypto/dso/dso_lib.c +++ b/lib/libcrypto/dso/dso_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dso_lib.c,v 1.19 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: dso_lib.c,v 1.20 2018/08/24 19:27:01 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -174,13 +174,15 @@ DSO_flags(DSO *dso) int DSO_up_ref(DSO *dso) { + int refs; + if (dso == NULL) { DSOerror(ERR_R_PASSED_NULL_PARAMETER); return (0); } - CRYPTO_add(&dso->references, 1, CRYPTO_LOCK_DSO); - return (1); + refs = CRYPTO_add(&dso->references, 1, CRYPTO_LOCK_DSO); + return ((refs > 1) ? 1 : 0); } DSO * diff --git a/lib/libcrypto/ec/ec.h b/lib/libcrypto/ec/ec.h index dc70cfa6af..d9df48603a 100644 --- a/lib/libcrypto/ec/ec.h +++ b/lib/libcrypto/ec/ec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec.h,v 1.12 2016/11/04 17:33:19 miod Exp $ */ +/* $OpenBSD: ec.h,v 1.13 2018/05/19 10:37:02 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -911,7 +911,7 @@ EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); * of bytes needed). * \return 1 on success and 0 if an error occurred */ -int i2o_ECPublicKey(EC_KEY *key, unsigned char **out); +int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); #ifndef OPENSSL_NO_BIO /** Prints out the ec parameters on human readable form. diff --git a/lib/libcrypto/ec/ec2_mult.c b/lib/libcrypto/ec/ec2_mult.c index 1c8bb18076..3e5d1dca85 100644 --- a/lib/libcrypto/ec/ec2_mult.c +++ b/lib/libcrypto/ec/ec2_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_mult.c,v 1.9 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ec2_mult.c,v 1.13 2018/07/23 18:24:22 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -71,6 +71,7 @@ #include +#include "bn_lcl.h" #include "ec_lcl.h" #ifndef OPENSSL_NO_EC2M @@ -111,7 +112,7 @@ gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx) ret = 1; -err: + err: BN_CTX_end(ctx); return ret; } @@ -155,7 +156,7 @@ gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, ret = 1; -err: + err: BN_CTX_end(ctx); return ret; } @@ -243,7 +244,7 @@ gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIGNUM *x1, ret = 2; -err: + err: BN_CTX_end(ctx); return ret; } @@ -324,14 +325,18 @@ ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, for (; i >= 0; i--) { word = scalar->d[i]; while (mask) { - BN_consttime_swap(word & mask, x1, x2, group->field.top); - BN_consttime_swap(word & mask, z1, z2, group->field.top); + if (!BN_swap_ct(word & mask, x1, x2, group->field.top)) + goto err; + if (!BN_swap_ct(word & mask, z1, z2, group->field.top)) + goto err; if (!gf2m_Madd(group, &point->X, x2, z2, x1, z1, ctx)) goto err; if (!gf2m_Mdouble(group, x1, z1, ctx)) goto err; - BN_consttime_swap(word & mask, x1, x2, group->field.top); - BN_consttime_swap(word & mask, z1, z2, group->field.top); + if (!BN_swap_ct(word & mask, x1, x2, group->field.top)) + goto err; + if (!BN_swap_ct(word & mask, z1, z2, group->field.top)) + goto err; mask >>= 1; } mask = BN_TBIT; @@ -356,7 +361,7 @@ ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, ret = 1; -err: + err: BN_CTX_end(ctx); return ret; } @@ -424,7 +429,7 @@ ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, ret = 1; -err: + err: EC_POINT_free(p); EC_POINT_free(acc); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/ec2_oct.c b/lib/libcrypto/ec/ec2_oct.c index f434d726d2..268eccf471 100644 --- a/lib/libcrypto/ec/ec2_oct.c +++ b/lib/libcrypto/ec/ec2_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_oct.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ec2_oct.c,v 1.11 2018/07/15 16:27:39 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -157,7 +157,7 @@ ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -272,7 +272,7 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, BN_CTX_free(new_ctx); return ret; -err: + err: if (used_ctx) BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -374,7 +374,7 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, } ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c index 6157599990..1ca04194b3 100644 --- a/lib/libcrypto/ec/ec2_smpl.c +++ b/lib/libcrypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.20 2018/07/16 17:32:39 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -107,15 +107,11 @@ EC_GF2m_simple_method(void) .point_cmp = ec_GF2m_simple_cmp, .make_affine = ec_GF2m_simple_make_affine, .points_make_affine = ec_GF2m_simple_points_make_affine, - - /* - * the following three method functions are defined in - * ec2_mult.c - */ - .mul = ec_GF2m_simple_mul, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, .precompute_mult = ec_GF2m_precompute_mult, .have_precompute_mult = ec_GF2m_have_precompute_mult, - .field_mul = ec_GF2m_simple_field_mul, .field_sqr = ec_GF2m_simple_field_sqr, .field_div = ec_GF2m_simple_field_div, @@ -232,7 +228,7 @@ ec_GF2m_simple_group_set_curve(EC_GROUP * group, group->b.d[i] = 0; ret = 1; -err: + err: return ret; } @@ -260,7 +256,7 @@ ec_GF2m_simple_group_get_curve(const EC_GROUP *group, } ret = 1; -err: + err: return ret; } @@ -306,7 +302,7 @@ ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) ret = 1; -err: + err: if (ctx != NULL) BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -398,7 +394,7 @@ ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * p point->Z_is_one = 1; ret = 1; -err: + err: return ret; } @@ -432,7 +428,7 @@ ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, } ret = 1; -err: + err: return ret; } @@ -549,7 +545,7 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -641,7 +637,7 @@ ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX if (!BN_GF2m_add(lh, lh, y2)) goto err; ret = BN_is_zero(lh); -err: + err: if (ctx) BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -693,7 +689,7 @@ ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, goto err; ret = ((BN_cmp(aX, bX) == 0) && BN_cmp(aY, bY) == 0) ? 0 : 1; -err: + err: if (ctx) BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -734,7 +730,7 @@ ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ct ret = 1; -err: + err: if (ctx) BN_CTX_end(ctx); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/ec_ameth.c b/lib/libcrypto/ec/ec_ameth.c index 0932f1e3c9..04c068200f 100644 --- a/lib/libcrypto/ec/ec_ameth.c +++ b/lib/libcrypto/ec/ec_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_ameth.c,v 1.19 2018/03/12 13:14:21 inoguchi Exp $ */ +/* $OpenBSD: ec_ameth.c,v 1.25 2018/08/24 20:22:15 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -126,7 +126,7 @@ eckey_pub_encode(X509_PUBKEY * pk, const EVP_PKEY * pkey) if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_EC), ptype, pval, penc, penclen)) return 1; -err: + err: if (ptype == V_ASN1_OBJECT) ASN1_OBJECT_free(pval); else @@ -136,12 +136,12 @@ err: } static EC_KEY * -eckey_type2param(int ptype, void *pval) +eckey_type2param(int ptype, const void *pval) { EC_KEY *eckey = NULL; if (ptype == V_ASN1_SEQUENCE) { - ASN1_STRING *pstr = pval; + const ASN1_STRING *pstr = pval; const unsigned char *pm = NULL; int pmlen; @@ -152,7 +152,7 @@ eckey_type2param(int ptype, void *pval) goto ecerr; } } else if (ptype == V_ASN1_OBJECT) { - ASN1_OBJECT *poid = pval; + const ASN1_OBJECT *poid = pval; EC_GROUP *group; /* @@ -177,7 +177,7 @@ eckey_type2param(int ptype, void *pval) return eckey; -ecerr: + ecerr: if (eckey) EC_KEY_free(eckey); return NULL; @@ -187,7 +187,7 @@ static int eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) { const unsigned char *p = NULL; - void *pval; + const void *pval; int ptype, pklen; EC_KEY *eckey = NULL; X509_ALGOR *palg; @@ -210,7 +210,7 @@ eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) EVP_PKEY_assign_EC_KEY(pkey, eckey); return 1; -ecerr: + ecerr: if (eckey) EC_KEY_free(eckey); return 0; @@ -232,13 +232,13 @@ eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b) } static int -eckey_priv_decode(EVP_PKEY * pkey, PKCS8_PRIV_KEY_INFO * p8) +eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8) { const unsigned char *p = NULL; - void *pval; + const void *pval; int ptype, pklen; EC_KEY *eckey = NULL; - X509_ALGOR *palg; + const X509_ALGOR *palg; if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) return 0; @@ -290,9 +290,9 @@ eckey_priv_decode(EVP_PKEY * pkey, PKCS8_PRIV_KEY_INFO * p8) EVP_PKEY_assign_EC_KEY(pkey, eckey); return 1; -ecliberr: + ecliberr: ECerror(ERR_R_EC_LIB); -ecerr: + ecerr: if (eckey) EC_KEY_free(eckey); return 0; @@ -483,7 +483,7 @@ do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) if (!ECPKParameters_print(bp, group, off)) goto err; ret = 1; -err: + err: if (!ret) ECerror(reason); BN_free(pub_key); diff --git a/lib/libcrypto/ec/ec_asn1.c b/lib/libcrypto/ec/ec_asn1.c index 381addfcf6..f69dd023de 100644 --- a/lib/libcrypto/ec/ec_asn1.c +++ b/lib/libcrypto/ec/ec_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_asn1.c,v 1.25 2018/03/12 13:14:21 inoguchi Exp $ */ +/* $OpenBSD: ec_asn1.c,v 1.31 2018/09/01 16:23:15 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -86,6 +86,7 @@ EC_GROUP_get_basis_type(const EC_GROUP * group) /* everything else is currently not supported */ return 0; } + #ifndef OPENSSL_NO_EC2M int EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k) @@ -104,6 +105,7 @@ EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k) return 1; } + int EC_GROUP_get_pentanomial_basis(const EC_GROUP * group, unsigned int *k1, unsigned int *k2, unsigned int *k3) @@ -128,7 +130,6 @@ EC_GROUP_get_pentanomial_basis(const EC_GROUP * group, unsigned int *k1, } #endif - /* some structures needed for the asn1 encoding */ typedef struct x9_62_pentanomial_st { long k1; @@ -334,6 +335,7 @@ const ASN1_ITEM X9_62_CHARACTERISTIC_TWO_it = { .size = sizeof(X9_62_CHARACTERISTIC_TWO), .sname = "X9_62_CHARACTERISTIC_TWO", }; + X9_62_CHARACTERISTIC_TWO *X9_62_CHARACTERISTIC_TWO_new(void); void X9_62_CHARACTERISTIC_TWO_free(X9_62_CHARACTERISTIC_TWO *a); @@ -348,6 +350,7 @@ X9_62_CHARACTERISTIC_TWO_free(X9_62_CHARACTERISTIC_TWO *a) { ASN1_item_free((ASN1_VALUE *)a, &X9_62_CHARACTERISTIC_TWO_it); } + static const ASN1_TEMPLATE fieldID_def_tt = { .flags = 0, .tag = 0, @@ -506,6 +509,7 @@ const ASN1_ITEM ECPARAMETERS_it = { .size = sizeof(ECPARAMETERS), .sname = "ECPARAMETERS", }; + ECPARAMETERS *ECPARAMETERS_new(void); void ECPARAMETERS_free(ECPARAMETERS *a); @@ -655,6 +659,7 @@ EC_PRIVATEKEY_free(EC_PRIVATEKEY *a) { ASN1_item_free((ASN1_VALUE *)a, &EC_PRIVATEKEY_it); } + /* some declarations of internal function */ /* ec_asn1_group2field() sets the values in a X9_62_FIELDID object */ @@ -675,7 +680,6 @@ static EC_GROUP *ec_asn1_pkparameters2group(const ECPKPARAMETERS *); static ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *, ECPKPARAMETERS *); - /* the function definitions */ static int @@ -789,7 +793,7 @@ ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) ok = 1; -err: + err: BN_free(tmp); return (ok); } @@ -892,7 +896,7 @@ ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) ok = 1; -err: + err: free(buffer_1); free(buffer_2); BN_free(tmp_1); @@ -984,7 +988,8 @@ ec_asn1_group2parameters(const EC_GROUP * group, ECPARAMETERS * param) } ok = 1; -err: if (!ok) { + err: + if (!ok) { if (ret && !param) ECPARAMETERS_free(ret); ret = NULL; @@ -1240,7 +1245,8 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) } ok = 1; -err: if (!ok) { + err: + if (!ok) { EC_GROUP_clear_free(ret); ret = NULL; } @@ -1308,7 +1314,7 @@ d2i_ECPKParameters(EC_GROUP ** a, const unsigned char **in, long len) *a = group; } -err: + err: ECPKPARAMETERS_free(params); return (group); } @@ -1421,7 +1427,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) *a = ret; return (ret); -err: + err: if (a == NULL || *a != ret) EC_KEY_free(ret); if (priv_key) @@ -1506,7 +1512,7 @@ i2d_ECPrivateKey(EC_KEY * a, unsigned char **out) goto err; } ok = 1; -err: + err: free(buffer); if (priv_key) EC_PRIVATEKEY_free(priv_key); @@ -1558,10 +1564,7 @@ o2i_ECPublicKey(EC_KEY ** a, const unsigned char **in, long len) EC_KEY *ret = NULL; if (a == NULL || (*a) == NULL || (*a)->group == NULL) { - /* - * sorry, but a EC_GROUP-structur is necessary to set the - * public key - */ + /* An EC_GROUP structure is necessary to set the public key. */ ECerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } @@ -1582,7 +1585,7 @@ o2i_ECPublicKey(EC_KEY ** a, const unsigned char **in, long len) } int -i2o_ECPublicKey(EC_KEY * a, unsigned char **out) +i2o_ECPublicKey(const EC_KEY * a, unsigned char **out) { size_t buf_len = 0; int new_buffer = 0; diff --git a/lib/libcrypto/ec/ec_check.c b/lib/libcrypto/ec/ec_check.c index bbb03498ac..dcca661674 100644 --- a/lib/libcrypto/ec/ec_check.c +++ b/lib/libcrypto/ec/ec_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_check.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ec_check.c,v 1.9 2018/07/15 16:27:39 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -106,7 +106,7 @@ EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) } ret = 1; -err: + err: if (ctx != NULL) BN_CTX_end(ctx); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/ec_curve.c b/lib/libcrypto/ec/ec_curve.c index d4f6c28d1e..e075b1ed3e 100644 --- a/lib/libcrypto/ec/ec_curve.c +++ b/lib/libcrypto/ec/ec_curve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_curve.c,v 1.16 2018/03/16 12:31:09 mpi Exp $ */ +/* $OpenBSD: ec_curve.c,v 1.19 2018/07/15 16:27:39 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -3235,7 +3235,7 @@ ec_group_new_from_data(const ec_list_element curve) } } ok = 1; -err: + err: if (!ok) { EC_GROUP_free(group); group = NULL; diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c index 595b88cefc..d1b8e8fcc1 100644 --- a/lib/libcrypto/ec/ec_key.c +++ b/lib/libcrypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.14 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ec_key.c,v 1.17 2018/07/15 16:27:39 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -253,7 +253,7 @@ EC_KEY_generate_key(EC_KEY * eckey) ok = 1; -err: + err: BN_free(order); if (pub_key != NULL && eckey->pub_key == NULL) EC_POINT_free(pub_key); @@ -324,7 +324,7 @@ EC_KEY_check_key(const EC_KEY * eckey) } } ok = 1; -err: + err: BN_CTX_free(ctx); EC_POINT_free(point); return (ok); @@ -395,7 +395,7 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) ok = 1; -err: + err: BN_CTX_free(ctx); EC_POINT_free(point); return ok; diff --git a/lib/libcrypto/ec/ec_lcl.h b/lib/libcrypto/ec/ec_lcl.h index e1c91e67ab..e430b3f64d 100644 --- a/lib/libcrypto/ec/ec_lcl.h +++ b/lib/libcrypto/ec/ec_lcl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lcl.h,v 1.7 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: ec_lcl.h,v 1.10 2018/07/16 17:32:39 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -160,10 +160,12 @@ struct ec_method_st { int (*make_affine)(const EC_GROUP *, EC_POINT *, BN_CTX *); int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); - /* used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult, EC_POINT_have_precompute_mult - * (default implementations are used if the 'mul' pointer is 0): */ - int (*mul)(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, - size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); + /* used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult, EC_POINT_have_precompute_mult */ + int (*mul_generator_ct)(const EC_GROUP *, EC_POINT *r, const BIGNUM *scalar, BN_CTX *); + int (*mul_single_ct)(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + const EC_POINT *point, BN_CTX *); + int (*mul_double_nonct)(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, + const BIGNUM *p_scalar, const EC_POINT *point, BN_CTX *); int (*precompute_mult)(EC_GROUP *group, BN_CTX *); int (*have_precompute_mult)(const EC_GROUP *group); @@ -337,6 +339,11 @@ int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); +int ec_GFp_simple_mul_generator_ct(const EC_GROUP *, EC_POINT *r, const BIGNUM *scalar, BN_CTX *); +int ec_GFp_simple_mul_single_ct(const EC_GROUP *, EC_POINT *r, const BIGNUM *scalar, + const EC_POINT *point, BN_CTX *); +int ec_GFp_simple_mul_double_nonct(const EC_GROUP *, EC_POINT *r, const BIGNUM *g_scalar, + const BIGNUM *p_scalar, const EC_POINT *point, BN_CTX *); /* method functions in ecp_mont.c */ diff --git a/lib/libcrypto/ec/ec_lib.c b/lib/libcrypto/ec/ec_lib.c index 0d062111b5..7e0ea017f9 100644 --- a/lib/libcrypto/ec/ec_lib.c +++ b/lib/libcrypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.24 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.29 2018/07/16 17:32:39 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -526,7 +526,7 @@ EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx) return r; -err: + err: BN_CTX_end(ctx); if (ctx_new) BN_CTX_free(ctx); @@ -1026,47 +1026,88 @@ EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], } -/* Functions for point multiplication. - * - * If group->meth->mul is 0, we use the wNAF-based implementations in ec_mult.c; - * otherwise we dispatch through methods. - */ - +/* Functions for point multiplication */ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx) { - if (group->meth->mul == 0) - /* use default */ - return ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx); - - return group->meth->mul(group, r, scalar, num, points, scalars, ctx); + /* + * The function pointers must be set, and only support num == 0 and + * num == 1. + */ + if (group->meth->mul_generator_ct == NULL || + group->meth->mul_single_ct == NULL || + group->meth->mul_double_nonct == NULL || + num > 1) { + ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + + /* Either bP or aG + bP, this is sane. */ + if (num == 1 && points != NULL && scalars != NULL) + return EC_POINT_mul(group, r, scalar, points[0], scalars[0], + ctx); + + /* aG, this is sane */ + if (scalar != NULL && points == NULL && scalars == NULL) + return EC_POINT_mul(group, r, scalar, NULL, NULL, ctx); + + /* anything else is an error */ + ECerror(ERR_R_EC_LIB); + return 0; } int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx) { - /* just a convenient interface to EC_POINTs_mul() */ - - const EC_POINT *points[1]; - const BIGNUM *scalars[1]; - - points[0] = point; - scalars[0] = p_scalar; - - return EC_POINTs_mul(group, r, g_scalar, - (point != NULL && p_scalar != NULL), - points, scalars, ctx); + if (group->meth->mul_generator_ct == NULL || + group->meth->mul_single_ct == NULL || + group->meth->mul_double_nonct == NULL) { + ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + if (g_scalar != NULL && point == NULL && p_scalar == NULL) { + /* + * In this case we want to compute g_scalar * GeneratorPoint: + * this codepath is reached most prominently by (ephemeral) key + * generation of EC cryptosystems (i.e. ECDSA keygen and sign + * setup, ECDH keygen/first half), where the scalar is always + * secret. This is why we ignore if BN_FLG_CONSTTIME is actually + * set and we always call the constant time version. + */ + return group->meth->mul_generator_ct(group, r, g_scalar, ctx); + } + if (g_scalar == NULL && point != NULL && p_scalar != NULL) { + /* In this case we want to compute p_scalar * GenericPoint: + * this codepath is reached most prominently by the second half + * of ECDH, where the secret scalar is multiplied by the peer's + * public point. To protect the secret scalar, we ignore if + * BN_FLG_CONSTTIME is actually set and we always call the + * constant time version. + */ + return group->meth->mul_single_ct(group, r, p_scalar, point, + ctx); + } + if (g_scalar != NULL && point != NULL && p_scalar != NULL) { + /* + * In this case we want to compute + * g_scalar * GeneratorPoint + p_scalar * GenericPoint: + * this codepath is reached most prominently by ECDSA signature + * verification. So we call the non-ct version. + */ + return group->meth->mul_double_nonct(group, r, g_scalar, + p_scalar, point, ctx); + } + + /* Anything else is an error. */ + ECerror(ERR_R_EC_LIB); + return 0; } int EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx) { - if (group->meth->mul == 0) - /* use default */ - return ec_wNAF_precompute_mult(group, ctx); - if (group->meth->precompute_mult != 0) return group->meth->precompute_mult(group, ctx); else @@ -1076,10 +1117,6 @@ EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx) int EC_GROUP_have_precompute_mult(const EC_GROUP * group) { - if (group->meth->mul == 0) - /* use default */ - return ec_wNAF_have_precompute_mult(group); - if (group->meth->have_precompute_mult != 0) return group->meth->have_precompute_mult(group); else diff --git a/lib/libcrypto/ec/ec_mult.c b/lib/libcrypto/ec/ec_mult.c index a565263bb6..05f89a5787 100644 --- a/lib/libcrypto/ec/ec_mult.c +++ b/lib/libcrypto/ec/ec_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_mult.c,v 1.21 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ec_mult.c,v 1.24 2018/07/15 16:27:39 tb Exp $ */ /* * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. */ @@ -301,7 +301,7 @@ compute_wNAF(const BIGNUM * scalar, int w, size_t * ret_len) len = j; ok = 1; -err: + err: if (!ok) { free(r); r = NULL; @@ -678,7 +678,7 @@ ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, ret = 1; -err: + err: BN_CTX_free(new_ctx); EC_POINT_free(tmp); free(wsize); @@ -857,7 +857,7 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) pre_comp = NULL; ret = 1; -err: + err: if (ctx != NULL) BN_CTX_end(ctx); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/eck_prn.c b/lib/libcrypto/ec/eck_prn.c index 653d78e5cd..be57d875e3 100644 --- a/lib/libcrypto/ec/eck_prn.c +++ b/lib/libcrypto/ec/eck_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eck_prn.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eck_prn.c,v 1.15 2018/07/15 16:27:39 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -321,7 +321,7 @@ ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off) goto err; } ret = 1; -err: + err: if (!ret) ECerror(reason); BN_free(p); diff --git a/lib/libcrypto/ec/ecp_mont.c b/lib/libcrypto/ec/ecp_mont.c index 68fc26de1e..ba4b9cad97 100644 --- a/lib/libcrypto/ec/ecp_mont.c +++ b/lib/libcrypto/ec/ecp_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_mont.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ecp_mont.c,v 1.16 2018/07/16 17:32:39 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -102,6 +102,9 @@ EC_GFp_mont_method(void) .point_cmp = ec_GFp_simple_cmp, .make_affine = ec_GFp_simple_make_affine, .points_make_affine = ec_GFp_simple_points_make_affine, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, .field_mul = ec_GFp_mont_field_mul, .field_sqr = ec_GFp_mont_field_sqr, .field_encode = ec_GFp_mont_field_encode, @@ -172,7 +175,7 @@ ec_GFp_mont_group_copy(EC_GROUP * dest, const EC_GROUP * src) } return 1; -err: + err: if (dest->field_data1 != NULL) { BN_MONT_CTX_free(dest->field_data1); dest->field_data1 = NULL; @@ -225,7 +228,7 @@ ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, BN_free(group->field_data2); group->field_data2 = NULL; } -err: + err: BN_CTX_free(new_ctx); BN_MONT_CTX_free(mont); BN_free(one); diff --git a/lib/libcrypto/ec/ecp_nist.c b/lib/libcrypto/ec/ecp_nist.c index 24cba64d2e..6ae1170808 100644 --- a/lib/libcrypto/ec/ecp_nist.c +++ b/lib/libcrypto/ec/ecp_nist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nist.c,v 1.10 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ecp_nist.c,v 1.14 2018/07/16 17:32:39 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -103,6 +103,9 @@ EC_GFp_nist_method(void) .point_cmp = ec_GFp_simple_cmp, .make_affine = ec_GFp_simple_make_affine, .points_make_affine = ec_GFp_simple_points_make_affine, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, .field_mul = ec_GFp_nist_field_mul, .field_sqr = ec_GFp_nist_field_sqr }; @@ -151,7 +154,7 @@ ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -179,7 +182,7 @@ ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, goto err; ret = 1; -err: + err: BN_CTX_free(ctx_new); return ret; } @@ -206,7 +209,7 @@ ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, goto err; ret = 1; -err: + err: BN_CTX_free(ctx_new); return ret; } diff --git a/lib/libcrypto/ec/ecp_nistp224.c b/lib/libcrypto/ec/ecp_nistp224.c index fce74578c7..643e9a69a6 100644 --- a/lib/libcrypto/ec/ecp_nistp224.c +++ b/lib/libcrypto/ec/ecp_nistp224.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp224.c,v 1.19 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ecp_nistp224.c,v 1.22 2018/07/15 16:27:39 tb Exp $ */ /* * Written by Emilia Kasper (Google) for the OpenSSL project. */ @@ -1281,7 +1281,7 @@ ec_GFp_nistp224_group_set_curve(EC_GROUP * group, const BIGNUM * p, } group->field_mod_func = BN_nist_mod_224; ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -1537,7 +1537,7 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, } ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); -err: + err: BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); @@ -1666,7 +1666,7 @@ ec_GFp_nistp224_precompute_mult(EC_GROUP * group, BN_CTX * ctx) goto err; ret = 1; pre = NULL; -err: + err: BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/ecp_nistp256.c b/lib/libcrypto/ec/ecp_nistp256.c index 6f3ec3c250..5c5fcde694 100644 --- a/lib/libcrypto/ec/ecp_nistp256.c +++ b/lib/libcrypto/ec/ecp_nistp256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp256.c,v 1.18 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ecp_nistp256.c,v 1.21 2018/07/15 16:27:39 tb Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1830,7 +1830,7 @@ ec_GFp_nistp256_group_set_curve(EC_GROUP * group, const BIGNUM * p, } group->field_mod_func = BN_nist_mod_256; ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -2090,7 +2090,7 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, } ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); -err: + err: BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); @@ -2213,7 +2213,7 @@ ec_GFp_nistp256_precompute_mult(EC_GROUP * group, BN_CTX * ctx) goto err; ret = 1; pre = NULL; -err: + err: BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/ecp_nistp521.c b/lib/libcrypto/ec/ecp_nistp521.c index 6dbc266937..b3525bfdad 100644 --- a/lib/libcrypto/ec/ecp_nistp521.c +++ b/lib/libcrypto/ec/ecp_nistp521.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp521.c,v 1.19 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ecp_nistp521.c,v 1.22 2018/07/15 16:27:39 tb Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1721,7 +1721,7 @@ ec_GFp_nistp521_group_set_curve(EC_GROUP * group, const BIGNUM * p, } group->field_mod_func = BN_nist_mod_521; ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -1979,7 +1979,7 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, } ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); -err: + err: BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); @@ -2088,7 +2088,7 @@ ec_GFp_nistp521_precompute_mult(EC_GROUP * group, BN_CTX * ctx) goto err; ret = 1; pre = NULL; -err: + err: BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/ecp_nistz256.c b/lib/libcrypto/ec/ecp_nistz256.c index b3b8f74b14..43010db7d0 100644 --- a/lib/libcrypto/ec/ecp_nistz256.c +++ b/lib/libcrypto/ec/ecp_nistz256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistz256.c,v 1.3 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ecp_nistz256.c,v 1.6 2018/07/15 16:27:39 tb Exp $ */ /* Copyright (c) 2014, Intel Corporation. * * Permission to use, copy, modify, and/or distribute this software for any @@ -565,7 +565,7 @@ ecp_nistz256_windowed_mul(const EC_GROUP *group, P256_POINT *r, } ret = 1; -err: + err: free(table); free(p_str); free(scalars); @@ -712,7 +712,7 @@ ecp_nistz256_mult_precompute(EC_GROUP *group, BN_CTX *ctx) ec_pre_comp = NULL; ret = 1; -err: + err: if (ctx != NULL) BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -985,7 +985,7 @@ ecp_nistz256_points_mul(const EC_GROUP *group, EC_POINT *r, ret = 1; -err: + err: if (ctx) BN_CTX_end(ctx); BN_CTX_free(new_ctx); diff --git a/lib/libcrypto/ec/ecp_oct.c b/lib/libcrypto/ec/ecp_oct.c index b93b516907..90c5ca2e4e 100644 --- a/lib/libcrypto/ec/ecp_oct.c +++ b/lib/libcrypto/ec/ecp_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_oct.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ecp_oct.c,v 1.11 2018/07/15 16:27:39 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -190,7 +190,7 @@ ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -294,7 +294,7 @@ ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_co BN_CTX_free(new_ctx); return ret; -err: + err: if (used_ctx) BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -388,7 +388,7 @@ ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, } ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c index ddba49c693..a25fd1df84 100644 --- a/lib/libcrypto/ec/ecp_smpl.c +++ b/lib/libcrypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.17 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.22 2018/07/16 17:32:39 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -103,6 +103,9 @@ EC_GFp_simple_method(void) .point_cmp = ec_GFp_simple_cmp, .make_affine = ec_GFp_simple_make_affine, .points_make_affine = ec_GFp_simple_points_make_affine, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, .field_mul = ec_GFp_simple_field_mul, .field_sqr = ec_GFp_simple_field_sqr }; @@ -220,7 +223,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP * group, ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -265,7 +268,7 @@ ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BI } ret = 1; -err: + err: BN_CTX_free(new_ctx); return ret; } @@ -346,7 +349,7 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) } ret = 1; -err: + err: if (ctx != NULL) BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -456,7 +459,7 @@ ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP * group, EC_POINT * } ret = 1; -err: + err: BN_CTX_free(new_ctx); return ret; } @@ -504,7 +507,7 @@ ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP * group, const EC_P ret = 1; -err: + err: BN_CTX_free(new_ctx); return ret; } @@ -624,7 +627,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -811,7 +814,7 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons ret = 1; -end: + end: if (ctx) /* otherwise we already called BN_CTX_end */ BN_CTX_end(ctx); BN_CTX_free(new_ctx); @@ -954,7 +957,7 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -1075,7 +1078,7 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX ret = (0 == BN_ucmp(tmp, rh)); -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -1177,7 +1180,7 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b /* points are equal */ ret = 0; -end: + end: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -1215,7 +1218,7 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx } ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; @@ -1380,7 +1383,7 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * ret = 1; -err: + err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); if (heap != NULL) { @@ -1409,3 +1412,248 @@ ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN { return BN_mod_sqr(r, a, &group->field, ctx); } + +#define EC_POINT_BN_set_flags(P, flags) do { \ + BN_set_flags(&(P)->X, (flags)); \ + BN_set_flags(&(P)->Y, (flags)); \ + BN_set_flags(&(P)->Z, (flags)); \ +} while(0) + +#define EC_POINT_CSWAP(c, a, b, w, t) do { \ + if (!BN_swap_ct(c, &(a)->X, &(b)->X, w) || \ + !BN_swap_ct(c, &(a)->Y, &(b)->Y, w) || \ + !BN_swap_ct(c, &(a)->Z, &(b)->Z, w)) \ + goto err; \ + t = ((a)->Z_is_one ^ (b)->Z_is_one) & (c); \ + (a)->Z_is_one ^= (t); \ + (b)->Z_is_one ^= (t); \ +} while(0) + +/* + * This function computes (in constant time) a point multiplication over the + * EC group. + * + * At a high level, it is Montgomery ladder with conditional swaps. + * + * It performs either a fixed point multiplication + * (scalar * generator) + * when point is NULL, or a variable point multiplication + * (scalar * point) + * when point is not NULL. + * + * scalar should be in the range [0,n) otherwise all constant time bets are off. + * + * NB: This says nothing about EC_POINT_add and EC_POINT_dbl, + * which of course are not constant time themselves. + * + * The product is stored in r. + * + * Returns 1 on success, 0 otherwise. + */ +static int +ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + const EC_POINT *point, BN_CTX *ctx) +{ + int i, cardinality_bits, group_top, kbit, pbit, Z_is_one; + EC_POINT *s = NULL; + BIGNUM *k = NULL; + BIGNUM *lambda = NULL; + BIGNUM *cardinality = NULL; + BN_CTX *new_ctx = NULL; + int ret = 0; + + if (ctx == NULL && (ctx = new_ctx = BN_CTX_new()) == NULL) + return 0; + + BN_CTX_start(ctx); + + if ((s = EC_POINT_new(group)) == NULL) + goto err; + + if (point == NULL) { + if (!EC_POINT_copy(s, group->generator)) + goto err; + } else { + if (!EC_POINT_copy(s, point)) + goto err; + } + + EC_POINT_BN_set_flags(s, BN_FLG_CONSTTIME); + + if ((cardinality = BN_CTX_get(ctx)) == NULL) + goto err; + if ((lambda = BN_CTX_get(ctx)) == NULL) + goto err; + if ((k = BN_CTX_get(ctx)) == NULL) + goto err; + if (!BN_mul(cardinality, &group->order, &group->cofactor, ctx)) + goto err; + + /* + * Group cardinalities are often on a word boundary. + * So when we pad the scalar, some timing diff might + * pop if it needs to be expanded due to carries. + * So expand ahead of time. + */ + cardinality_bits = BN_num_bits(cardinality); + group_top = cardinality->top; + if ((bn_wexpand(k, group_top + 1) == NULL) || + (bn_wexpand(lambda, group_top + 1) == NULL)) + goto err; + + if (!BN_copy(k, scalar)) + goto err; + + BN_set_flags(k, BN_FLG_CONSTTIME); + + if (BN_num_bits(k) > cardinality_bits || BN_is_negative(k)) { + /* + * This is an unusual input, and we don't guarantee + * constant-timeness + */ + if (!BN_nnmod(k, k, cardinality, ctx)) + goto err; + } + + if (!BN_add(lambda, k, cardinality)) + goto err; + BN_set_flags(lambda, BN_FLG_CONSTTIME); + if (!BN_add(k, lambda, cardinality)) + goto err; + /* + * lambda := scalar + cardinality + * k := scalar + 2*cardinality + */ + kbit = BN_is_bit_set(lambda, cardinality_bits); + if (!BN_swap_ct(kbit, k, lambda, group_top + 1)) + goto err; + + group_top = group->field.top; + if ((bn_wexpand(&s->X, group_top) == NULL) || + (bn_wexpand(&s->Y, group_top) == NULL) || + (bn_wexpand(&s->Z, group_top) == NULL) || + (bn_wexpand(&r->X, group_top) == NULL) || + (bn_wexpand(&r->Y, group_top) == NULL) || + (bn_wexpand(&r->Z, group_top) == NULL)) + goto err; + + /* top bit is a 1, in a fixed pos */ + if (!EC_POINT_copy(r, s)) + goto err; + + EC_POINT_BN_set_flags(r, BN_FLG_CONSTTIME); + + if (!EC_POINT_dbl(group, s, s, ctx)) + goto err; + + pbit = 0; + + /* + * The ladder step, with branches, is + * + * k[i] == 0: S = add(R, S), R = dbl(R) + * k[i] == 1: R = add(S, R), S = dbl(S) + * + * Swapping R, S conditionally on k[i] leaves you with state + * + * k[i] == 0: T, U = R, S + * k[i] == 1: T, U = S, R + * + * Then perform the ECC ops. + * + * U = add(T, U) + * T = dbl(T) + * + * Which leaves you with state + * + * k[i] == 0: U = add(R, S), T = dbl(R) + * k[i] == 1: U = add(S, R), T = dbl(S) + * + * Swapping T, U conditionally on k[i] leaves you with state + * + * k[i] == 0: R, S = T, U + * k[i] == 1: R, S = U, T + * + * Which leaves you with state + * + * k[i] == 0: S = add(R, S), R = dbl(R) + * k[i] == 1: R = add(S, R), S = dbl(S) + * + * So we get the same logic, but instead of a branch it's a + * conditional swap, followed by ECC ops, then another conditional swap. + * + * Optimization: The end of iteration i and start of i-1 looks like + * + * ... + * CSWAP(k[i], R, S) + * ECC + * CSWAP(k[i], R, S) + * (next iteration) + * CSWAP(k[i-1], R, S) + * ECC + * CSWAP(k[i-1], R, S) + * ... + * + * So instead of two contiguous swaps, you can merge the condition + * bits and do a single swap. + * + * k[i] k[i-1] Outcome + * 0 0 No Swap + * 0 1 Swap + * 1 0 Swap + * 1 1 No Swap + * + * This is XOR. pbit tracks the previous bit of k. + */ + + for (i = cardinality_bits - 1; i >= 0; i--) { + kbit = BN_is_bit_set(k, i) ^ pbit; + EC_POINT_CSWAP(kbit, r, s, group_top, Z_is_one); + if (!EC_POINT_add(group, s, r, s, ctx)) + goto err; + if (!EC_POINT_dbl(group, r, r, ctx)) + goto err; + /* + * pbit logic merges this cswap with that of the + * next iteration + */ + pbit ^= kbit; + } + /* one final cswap to move the right value into r */ + EC_POINT_CSWAP(pbit, r, s, group_top, Z_is_one); + + ret = 1; + + err: + EC_POINT_free(s); + if (ctx != NULL) + BN_CTX_end(ctx); + BN_CTX_free(new_ctx); + + return ret; +} + +#undef EC_POINT_BN_set_flags +#undef EC_POINT_CSWAP + +int +ec_GFp_simple_mul_generator_ct(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *scalar, BN_CTX *ctx) +{ + return ec_GFp_simple_mul_ct(group, r, scalar, NULL, ctx); +} + +int +ec_GFp_simple_mul_single_ct(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *scalar, const EC_POINT *point, BN_CTX *ctx) +{ + return ec_GFp_simple_mul_ct(group, r, scalar, point, ctx); +} + +int +ec_GFp_simple_mul_double_nonct(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *g_scalar, const BIGNUM *p_scalar, const EC_POINT *point, + BN_CTX *ctx) +{ + return ec_wNAF_mul(group, r, g_scalar, 1, &point, &p_scalar, ctx); +} diff --git a/lib/libcrypto/ecdh/ech_key.c b/lib/libcrypto/ecdh/ech_key.c index 5c2dc70b63..6911f1e341 100644 --- a/lib/libcrypto/ecdh/ech_key.c +++ b/lib/libcrypto/ecdh/ech_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_key.c,v 1.7 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ech_key.c,v 1.8 2018/09/02 17:20:31 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -125,6 +125,10 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, } group = EC_KEY_get0_group(ecdh); + + if (!EC_POINT_is_on_curve(group, pub_key, ctx)) + goto err; + if ((tmp = EC_POINT_new(group)) == NULL) { ECDHerror(ERR_R_MALLOC_FAILURE); goto err; diff --git a/lib/libcrypto/ecdh/ech_lib.c b/lib/libcrypto/ecdh/ech_lib.c index 2846a88612..cc8edafa07 100644 --- a/lib/libcrypto/ecdh/ech_lib.c +++ b/lib/libcrypto/ecdh/ech_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_lib.c,v 1.13 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ech_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -109,10 +109,8 @@ ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) return 0; #ifndef OPENSSL_NO_ENGINE - if (ecdh->engine) { - ENGINE_finish(ecdh->engine); - ecdh->engine = NULL; - } + ENGINE_finish(ecdh->engine); + ecdh->engine = NULL; #endif ecdh->meth = meth; return 1; @@ -138,7 +136,7 @@ ECDH_DATA_new_method(ENGINE *engine) ret->engine = ENGINE_get_default_ECDH(); if (ret->engine) { ret->meth = ENGINE_get_ECDH(ret->engine); - if (!ret->meth) { + if (ret->meth == NULL) { ECDHerror(ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); @@ -176,8 +174,7 @@ ecdh_data_free(void *data) ECDH_DATA *r = (ECDH_DATA *)data; #ifndef OPENSSL_NO_ENGINE - if (r->engine) - ENGINE_finish(r->engine); + ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data); diff --git a/lib/libcrypto/ecdsa/ecs_lib.c b/lib/libcrypto/ecdsa/ecs_lib.c index 4fbe1e060b..c688a95f3b 100644 --- a/lib/libcrypto/ecdsa/ecs_lib.c +++ b/lib/libcrypto/ecdsa/ecs_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_lib.c,v 1.12 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ecs_lib.c,v 1.13 2018/04/14 07:09:21 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * @@ -96,10 +96,8 @@ ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) return 0; #ifndef OPENSSL_NO_ENGINE - if (ecdsa->engine) { - ENGINE_finish(ecdsa->engine); - ecdsa->engine = NULL; - } + ENGINE_finish(ecdsa->engine); + ecdsa->engine = NULL; #endif ecdsa->meth = meth; @@ -126,7 +124,7 @@ ECDSA_DATA_new_method(ENGINE *engine) ret->engine = ENGINE_get_default_ECDSA(); if (ret->engine) { ret->meth = ENGINE_get_ECDSA(ret->engine); - if (!ret->meth) { + if (ret->meth == NULL) { ECDSAerror(ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); @@ -164,8 +162,7 @@ ecdsa_data_free(void *data) ECDSA_DATA *r = (ECDSA_DATA *)data; #ifndef OPENSSL_NO_ENGINE - if (r->engine) - ENGINE_finish(r->engine); + ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data); diff --git a/lib/libcrypto/ecdsa/ecs_ossl.c b/lib/libcrypto/ecdsa/ecs_ossl.c index 09f3bf8416..87d80642df 100644 --- a/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/lib/libcrypto/ecdsa/ecs_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_ossl.c,v 1.9.2.1 2018/06/13 15:08:08 jsing Exp $ */ +/* $OpenBSD: ecs_ossl.c,v 1.16 2018/07/10 21:36:02 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -65,7 +65,9 @@ #include "bn_lcl.h" #include "ecs_locl.h" -static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dlen, +static int ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len, + BIGNUM *order, BIGNUM *ret); +static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *, const BIGNUM *, EC_KEY *eckey); static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); @@ -86,36 +88,56 @@ ECDSA_OpenSSL(void) } static int +ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len, BIGNUM *order, + BIGNUM *ret) +{ + int dgst_bits, order_bits; + + if (!BN_bin2bn(dgst, dgst_len, ret)) { + ECDSAerror(ERR_R_BN_LIB); + return 0; + } + + /* FIPS 186-3 6.4: Use order_bits leftmost bits if digest is too long */ + dgst_bits = 8 * dgst_len; + order_bits = BN_num_bits(order); + if (dgst_bits > order_bits) { + if (!BN_rshift(ret, ret, dgst_bits - order_bits)) { + ECDSAerror(ERR_R_BN_LIB); + return 0; + } + } + + return 1; +} + +static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { - BN_CTX *ctx = NULL; - BIGNUM *k = NULL, *r = NULL, *order = NULL, *X = NULL; - EC_POINT *tmp_point = NULL; + BN_CTX *ctx = ctx_in; + BIGNUM *k = NULL, *r = NULL, *order = NULL, *X = NULL; + EC_POINT *point = NULL; const EC_GROUP *group; - int ret = 0; + int order_bits, ret = 0; if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) { ECDSAerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } - if (ctx_in == NULL) { + if (ctx == NULL) { if ((ctx = BN_CTX_new()) == NULL) { ECDSAerror(ERR_R_MALLOC_FAILURE); return 0; } - } else - ctx = ctx_in; - - k = BN_new(); /* this value is later returned in *kinvp */ - r = BN_new(); /* this value is later returned in *rp */ - order = BN_new(); - X = BN_new(); - if (!k || !r || !order || !X) { + } + + if ((k = BN_new()) == NULL || (r = BN_new()) == NULL || + (order = BN_new()) == NULL || (X = BN_new()) == NULL) { ECDSAerror(ERR_R_MALLOC_FAILURE); goto err; } - if ((tmp_point = EC_POINT_new(group)) == NULL) { + if ((point = EC_POINT_new(group)) == NULL) { ECDSAerror(ERR_R_EC_LIB); goto err; } @@ -124,44 +146,60 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) goto err; } + /* Preallocate space. */ + order_bits = BN_num_bits(order); + if (!BN_set_bit(k, order_bits) || + !BN_set_bit(r, order_bits) || + !BN_set_bit(X, order_bits)) + goto err; + do { - /* get random k */ - do + do { if (!BN_rand_range(k, order)) { - ECDSAerror(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED); + ECDSAerror( + ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED); goto err; } - while (BN_is_zero(k)); - - /* We do not want timing information to leak the length of k, - * so we compute G*k using an equivalent scalar of fixed - * bit-length. */ - if (!BN_add(k, k, order)) + } while (BN_is_zero(k)); + + /* + * We do not want timing information to leak the length of k, + * so we compute G * k using an equivalent scalar of fixed + * bit-length. + * + * We unconditionally perform both of these additions to prevent + * a small timing information leakage. We then choose the sum + * that is one bit longer than the order. This guarantees the + * code path used in the constant time implementations + * elsewhere. + * + * TODO: revisit the BN_copy aiming for a memory access agnostic + * conditional copy. + */ + if (!BN_add(r, k, order) || + !BN_add(X, r, order) || + !BN_copy(k, BN_num_bits(r) > order_bits ? r : X)) goto err; - if (BN_num_bits(k) <= BN_num_bits(order)) - if (!BN_add(k, k, order)) - goto err; BN_set_flags(k, BN_FLG_CONSTTIME); - /* compute r the x-coordinate of generator * k */ - if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) { + /* Compute r, the x-coordinate of G * k. */ + if (!EC_POINT_mul(group, point, k, NULL, NULL, ctx)) { ECDSAerror(ERR_R_EC_LIB); goto err; } if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { - if (!EC_POINT_get_affine_coordinates_GFp(group, - tmp_point, X, NULL, ctx)) { + if (!EC_POINT_get_affine_coordinates_GFp(group, point, + X, NULL, ctx)) { ECDSAerror(ERR_R_EC_LIB); goto err; } } #ifndef OPENSSL_NO_EC2M - else /* NID_X9_62_characteristic_two_field */ - { - if (!EC_POINT_get_affine_coordinates_GF2m(group, - tmp_point, X, NULL, ctx)) { + else { /* NID_X9_62_characteristic_two_field */ + if (!EC_POINT_get_affine_coordinates_GF2m(group, point, + X, NULL, ctx)) { ECDSAerror(ERR_R_EC_LIB); goto err; } @@ -173,28 +211,25 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) } } while (BN_is_zero(r)); - /* compute the inverse of k */ if (!BN_mod_inverse_ct(k, k, order, ctx)) { ECDSAerror(ERR_R_BN_LIB); goto err; } - /* clear old values if necessary */ BN_clear_free(*rp); BN_clear_free(*kinvp); - /* save the pre-computed values */ *rp = r; *kinvp = k; ret = 1; -err: - if (!ret) { + err: + if (ret == 0) { BN_clear_free(k); BN_clear_free(r); } if (ctx_in == NULL) BN_CTX_free(ctx); BN_free(order); - EC_POINT_free(tmp_point); + EC_POINT_free(point); BN_clear_free(X); return (ret); } @@ -204,14 +239,14 @@ static ECDSA_SIG * ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey) { - int ok = 0, i; - BIGNUM *kinv = NULL, *s, *m = NULL, *tmp = NULL, *order = NULL; - const BIGNUM *ckinv; - BN_CTX *ctx = NULL; - const EC_GROUP *group; + BIGNUM *b = NULL, *binv = NULL, *bm = NULL, *bxr = NULL; + BIGNUM *kinv = NULL, *m = NULL, *order = NULL, *range = NULL, *s; + const BIGNUM *ckinv, *priv_key; + BN_CTX *ctx = NULL; + const EC_GROUP *group; ECDSA_SIG *ret; ECDSA_DATA *ecdsa; - const BIGNUM *priv_key; + int ok = 0; ecdsa = ecdsa_check(eckey); group = EC_KEY_get0_group(eckey); @@ -222,15 +257,16 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, return NULL; } - ret = ECDSA_SIG_new(); - if (!ret) { + if ((ret = ECDSA_SIG_new()) == NULL) { ECDSAerror(ERR_R_MALLOC_FAILURE); return NULL; } s = ret->s; if ((ctx = BN_CTX_new()) == NULL || (order = BN_new()) == NULL || - (tmp = BN_new()) == NULL || (m = BN_new()) == NULL) { + (range = BN_new()) == NULL || (b = BN_new()) == NULL || + (binv = BN_new()) == NULL || (bm = BN_new()) == NULL || + (bxr = BN_new()) == NULL || (m = BN_new()) == NULL) { ECDSAerror(ERR_R_MALLOC_FAILURE); goto err; } @@ -239,21 +275,10 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, ECDSAerror(ERR_R_EC_LIB); goto err; } - i = BN_num_bits(order); - /* Need to truncate digest if it is too long: first truncate whole - * bytes. - */ - if (8 * dgst_len > i) - dgst_len = (i + 7)/8; - if (!BN_bin2bn(dgst, dgst_len, m)) { - ECDSAerror(ERR_R_BN_LIB); - goto err; - } - /* If still too long truncate remaining bits with a shift */ - if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) { - ECDSAerror(ERR_R_BN_LIB); + + if (!ecdsa_prepare_digest(dgst, dgst_len, order, m)) goto err; - } + do { if (in_kinv == NULL || in_r == NULL) { if (!ECDSA_sign_setup(eckey, ctx, &kinv, &ret->r)) { @@ -269,11 +294,55 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, } } - if (!BN_mod_mul(tmp, priv_key, ret->r, order, ctx)) { + /* + * Compute: + * + * s = inv(k)(m + xr) mod order + * + * In order to reduce the possibility of a side-channel attack, + * the following is calculated using a blinding value: + * + * s = inv(k)inv(b)(bm + bxr) mod order + * + * where b is a random value in the range [1, order-1]. + */ + + /* Generate b in range [1, order-1]. */ + if (!BN_sub(range, order, BN_value_one())) { ECDSAerror(ERR_R_BN_LIB); goto err; } - if (!BN_mod_add(s, tmp, m, order, ctx)) { + if (!BN_rand_range(b, range)) { + ECDSAerror(ERR_R_BN_LIB); + goto err; + } + if (!BN_add(b, b, BN_value_one())) { + ECDSAerror(ERR_R_BN_LIB); + goto err; + } + + if (BN_mod_inverse_ct(binv, b, order, ctx) == NULL) { + ECDSAerror(ERR_R_BN_LIB); + goto err; + } + + if (!BN_mod_mul(bxr, b, priv_key, order, ctx)) { /* bx */ + ECDSAerror(ERR_R_BN_LIB); + goto err; + } + if (!BN_mod_mul(bxr, bxr, ret->r, order, ctx)) { /* bxr */ + ECDSAerror(ERR_R_BN_LIB); + goto err; + } + if (!BN_mod_mul(bm, b, m, order, ctx)) { /* bm */ + ECDSAerror(ERR_R_BN_LIB); + goto err; + } + if (!BN_mod_add(s, bm, bxr, order, ctx)) { /* s = bm + bxr */ + ECDSAerror(ERR_R_BN_LIB); + goto err; + } + if (!BN_mod_mul(s, s, binv, order, ctx)) { /* s = m + xr */ ECDSAerror(ERR_R_BN_LIB); goto err; } @@ -281,9 +350,12 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, ECDSAerror(ERR_R_BN_LIB); goto err; } + if (BN_is_zero(s)) { - /* if kinv and r have been supplied by the caller - * don't to generate new kinv and r values */ + /* + * If kinv and r have been supplied by the caller, + * don't generate new kinv and r values + */ if (in_kinv != NULL && in_r != NULL) { ECDSAerror(ECDSA_R_NEED_NEW_SETUP_VALUES); goto err; @@ -295,16 +367,20 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, ok = 1; -err: - if (!ok) { + err: + if (ok == 0) { ECDSA_SIG_free(ret); ret = NULL; } BN_CTX_free(ctx); + BN_clear_free(b); + BN_clear_free(binv); + BN_clear_free(bm); + BN_clear_free(bxr); + BN_clear_free(kinv); BN_clear_free(m); - BN_clear_free(tmp); BN_free(order); - BN_clear_free(kinv); + BN_free(range); return ret; } @@ -312,22 +388,20 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey) { - int ret = -1, i; - BN_CTX *ctx; - BIGNUM *order, *u1, *u2, *m, *X; + BN_CTX *ctx; + BIGNUM *order, *u1, *u2, *m, *X; EC_POINT *point = NULL; const EC_GROUP *group; const EC_POINT *pub_key; + int ret = -1; - /* check input values */ if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL || (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) { ECDSAerror(ECDSA_R_MISSING_PARAMETERS); return -1; } - ctx = BN_CTX_new(); - if (!ctx) { + if ((ctx = BN_CTX_new()) == NULL) { ECDSAerror(ERR_R_MALLOC_FAILURE); return -1; } @@ -337,7 +411,7 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, u2 = BN_CTX_get(ctx); m = BN_CTX_get(ctx); X = BN_CTX_get(ctx); - if (!X) { + if (X == NULL) { ECDSAerror(ERR_R_BN_LIB); goto err; } @@ -347,45 +421,33 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, goto err; } - if (BN_is_zero(sig->r) || BN_is_negative(sig->r) || - BN_ucmp(sig->r, order) >= 0 || BN_is_zero(sig->s) || - BN_is_negative(sig->s) || BN_ucmp(sig->s, order) >= 0) { + /* Verify that r and s are in the range [1, order-1]. */ + if (BN_is_zero(sig->r) || BN_is_negative(sig->r) || + BN_ucmp(sig->r, order) >= 0 || + BN_is_zero(sig->s) || BN_is_negative(sig->s) || + BN_ucmp(sig->s, order) >= 0) { ECDSAerror(ECDSA_R_BAD_SIGNATURE); - ret = 0; /* signature is invalid */ + ret = 0; goto err; } - /* calculate tmp1 = inv(S) mod order */ - if (!BN_mod_inverse_ct(u2, sig->s, order, ctx)) { - ECDSAerror(ERR_R_BN_LIB); - goto err; - } - /* digest -> m */ - i = BN_num_bits(order); - /* Need to truncate digest if it is too long: first truncate whole - * bytes. - */ - if (8 * dgst_len > i) - dgst_len = (i + 7)/8; - if (!BN_bin2bn(dgst, dgst_len, m)) { - ECDSAerror(ERR_R_BN_LIB); + + if (!ecdsa_prepare_digest(dgst, dgst_len, order, m)) goto err; - } - /* If still too long truncate remaining bits with a shift */ - if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) { + + if (!BN_mod_inverse_ct(u2, sig->s, order, ctx)) { /* w = inv(s) */ ECDSAerror(ERR_R_BN_LIB); goto err; } - /* u1 = m * tmp mod order */ - if (!BN_mod_mul(u1, m, u2, order, ctx)) { + if (!BN_mod_mul(u1, m, u2, order, ctx)) { /* u1 = mw */ ECDSAerror(ERR_R_BN_LIB); goto err; } - /* u2 = r * w mod q */ - if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) { + if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) { /* u2 = rw */ ECDSAerror(ERR_R_BN_LIB); goto err; } + /* Compute the x-coordinate of G * u1 + pub_key * u2. */ if ((point = EC_POINT_new(group)) == NULL) { ECDSAerror(ERR_R_MALLOC_FAILURE); goto err; @@ -396,17 +458,16 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, } if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { - if (!EC_POINT_get_affine_coordinates_GFp(group, - point, X, NULL, ctx)) { + if (!EC_POINT_get_affine_coordinates_GFp(group, point, X, NULL, + ctx)) { ECDSAerror(ERR_R_EC_LIB); goto err; } } #ifndef OPENSSL_NO_EC2M - else /* NID_X9_62_characteristic_two_field */ - { - if (!EC_POINT_get_affine_coordinates_GF2m(group, - point, X, NULL, ctx)) { + else { /* NID_X9_62_characteristic_two_field */ + if (!EC_POINT_get_affine_coordinates_GF2m(group, point, X, NULL, + ctx)) { ECDSAerror(ERR_R_EC_LIB); goto err; } @@ -416,10 +477,11 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, ECDSAerror(ERR_R_BN_LIB); goto err; } - /* if the signature is correct u1 is equal to sig->r */ + + /* If the signature is correct, the x-coordinate is equal to sig->r. */ ret = (BN_ucmp(u1, sig->r) == 0); -err: + err: BN_CTX_end(ctx); BN_CTX_free(ctx); EC_POINT_free(point); diff --git a/lib/libcrypto/engine/eng_aesni.c b/lib/libcrypto/engine/eng_aesni.c index cd14bbc8cd..586f74792a 100644 --- a/lib/libcrypto/engine/eng_aesni.c +++ b/lib/libcrypto/engine/eng_aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_aesni.c,v 1.10 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_aesni.c,v 1.11 2018/04/14 07:18:37 tb Exp $ */ /* * Support for Intel AES-NI intruction set * Author: Huang Ying @@ -102,12 +102,12 @@ void ENGINE_load_aesni(void) /* On non-x86 CPUs it just returns. */ #ifdef COMPILE_HW_AESNI ENGINE *toadd = ENGINE_aesni(); - if (!toadd) + if (toadd == NULL) return; - ENGINE_add (toadd); - ENGINE_register_complete (toadd); - ENGINE_free (toadd); - ERR_clear_error (); + ENGINE_add(toadd); + ENGINE_register_complete(toadd); + ENGINE_free(toadd); + ERR_clear_error(); #endif } diff --git a/lib/libcrypto/engine/eng_cnf.c b/lib/libcrypto/engine/eng_cnf.c index 2ac077d492..24358af8cd 100644 --- a/lib/libcrypto/engine/eng_cnf.c +++ b/lib/libcrypto/engine/eng_cnf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_cnf.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_cnf.c,v 1.15 2018/04/14 07:18:37 tb Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -200,8 +200,7 @@ err: "section=%s, name=%s, value=%s", ecmd->section, ecmd->name, ecmd->value); } - if (e) - ENGINE_free(e); + ENGINE_free(e); return ret; } diff --git a/lib/libcrypto/engine/eng_init.c b/lib/libcrypto/engine/eng_init.c index 75d6698c70..793adba8be 100644 --- a/lib/libcrypto/engine/eng_init.c +++ b/lib/libcrypto/engine/eng_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_init.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_init.c,v 1.9 2018/04/14 07:09:21 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * @@ -134,10 +134,8 @@ ENGINE_finish(ENGINE *e) { int to_return = 1; - if (e == NULL) { - ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); - return 0; - } + if (e == NULL) + return 1; CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); to_return = engine_unlocked_finish(e, 1); CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); diff --git a/lib/libcrypto/engine/eng_lib.c b/lib/libcrypto/engine/eng_lib.c index 11ad771109..1aedcb18c6 100644 --- a/lib/libcrypto/engine/eng_lib.c +++ b/lib/libcrypto/engine/eng_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_lib.c,v 1.13 2018/03/17 16:20:01 beck Exp $ */ +/* $OpenBSD: eng_lib.c,v 1.14 2018/04/14 07:18:37 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -115,10 +115,8 @@ engine_free_util(ENGINE *e, int locked) { int i; - if (e == NULL) { - ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); - return 0; - } + if (e == NULL) + return 1; if (locked) i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE); else diff --git a/lib/libcrypto/engine/eng_list.c b/lib/libcrypto/engine/eng_list.c index 8bb1bc58f2..134866d2c6 100644 --- a/lib/libcrypto/engine/eng_list.c +++ b/lib/libcrypto/engine/eng_list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_list.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_list.c,v 1.23 2018/08/24 19:25:31 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -373,10 +373,12 @@ ENGINE_by_id(const char *id) int ENGINE_up_ref(ENGINE *e) { + int refs; + if (e == NULL) { ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } - CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); - return 1; + refs = CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); + return refs > 1 ? 1 : 0; } diff --git a/lib/libcrypto/engine/eng_openssl.c b/lib/libcrypto/engine/eng_openssl.c index 6154aebdee..f8f6c8f58c 100644 --- a/lib/libcrypto/engine/eng_openssl.c +++ b/lib/libcrypto/engine/eng_openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_openssl.c,v 1.12 2015/12/07 03:30:09 bcook Exp $ */ +/* $OpenBSD: eng_openssl.c,v 1.13 2018/04/14 07:18:37 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -177,7 +177,7 @@ engine_openssl(void) { ENGINE *ret = ENGINE_new(); - if (!ret) + if (ret == NULL) return NULL; if (!bind_helper(ret)) { ENGINE_free(ret); @@ -191,7 +191,7 @@ ENGINE_load_openssl(void) { ENGINE *toadd = engine_openssl(); - if (!toadd) + if (toadd == NULL) return; (void) ENGINE_add(toadd); /* If the "add" worked, it gets a structural reference. So either way, diff --git a/lib/libcrypto/engine/eng_padlock.c b/lib/libcrypto/engine/eng_padlock.c index 4f2d426a06..0281ab810c 100644 --- a/lib/libcrypto/engine/eng_padlock.c +++ b/lib/libcrypto/engine/eng_padlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_padlock.c,v 1.15 2016/11/04 13:56:05 miod Exp $ */ +/* $OpenBSD: eng_padlock.c,v 1.16 2018/04/14 07:18:37 tb Exp $ */ /* * Support for VIA PadLock Advanced Cryptography Engine (ACE) * Written by Michal Ludvig @@ -108,19 +108,21 @@ #ifdef OPENSSL_NO_DYNAMIC_ENGINE #ifdef COMPILE_HW_PADLOCK -static ENGINE *ENGINE_padlock (void); +static ENGINE *ENGINE_padlock(void); #endif -void ENGINE_load_padlock (void) +void +ENGINE_load_padlock(void) { /* On non-x86 CPUs it just returns. */ #ifdef COMPILE_HW_PADLOCK - ENGINE *toadd = ENGINE_padlock (); - if (!toadd) + ENGINE *toadd = ENGINE_padlock(); + + if (toadd == NULL) return; - ENGINE_add (toadd); - ENGINE_free (toadd); - ERR_clear_error (); + ENGINE_add(toadd); + ENGINE_free(toadd); + ERR_clear_error(); #endif } @@ -203,9 +205,8 @@ ENGINE_padlock(void) { ENGINE *eng = ENGINE_new(); - if (!eng) { + if (eng == NULL) return NULL; - } if (!padlock_bind_helper(eng)) { ENGINE_free(eng); diff --git a/lib/libcrypto/err/err.c b/lib/libcrypto/err/err.c index 320078da66..caabfe01d6 100644 --- a/lib/libcrypto/err/err.c +++ b/lib/libcrypto/err/err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err.c,v 1.46 2018/03/17 16:20:01 beck Exp $ */ +/* $OpenBSD: err.c,v 1.47 2018/04/03 21:59:37 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1107,7 +1107,8 @@ ERR_set_error_data(char *data, int flags) } void -ERR_asprintf_error_data(char * format, ...) { +ERR_asprintf_error_data(char * format, ...) +{ char *errbuf = NULL; va_list ap; int r; diff --git a/lib/libcrypto/evp/bio_b64.c b/lib/libcrypto/evp/bio_b64.c index b54e8793ec..82aaa8bf7a 100644 --- a/lib/libcrypto/evp/bio_b64.c +++ b/lib/libcrypto/evp/bio_b64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_b64.c,v 1.20 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: bio_b64.c,v 1.22 2018/08/24 19:47:25 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -91,7 +91,7 @@ typedef struct b64_struct { char tmp[B64_BLOCK_SIZE]; } BIO_B64_CTX; -static BIO_METHOD methods_b64 = { +static const BIO_METHOD methods_b64 = { .type = BIO_TYPE_BASE64, .name = "base64 encoding", .bwrite = b64_write, @@ -103,7 +103,7 @@ static BIO_METHOD methods_b64 = { .callback_ctrl = b64_callback_ctrl }; -BIO_METHOD * +const BIO_METHOD * BIO_f_base64(void) { return (&methods_b64); @@ -430,9 +430,10 @@ b64_write(BIO *b, const char *in, int inl) ret += n; } } else { - EVP_EncodeUpdate(&(ctx->base64), + if (!EVP_EncodeUpdate(&(ctx->base64), (unsigned char *)ctx->buf, &ctx->buf_len, - (unsigned char *)in, n); + (unsigned char *)in, n)) + return ((ret == 0) ? -1 : ret); OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len >= ctx->buf_off); ret += n; diff --git a/lib/libcrypto/evp/bio_enc.c b/lib/libcrypto/evp/bio_enc.c index 7c7cf9a8b3..7b55998952 100644 --- a/lib/libcrypto/evp/bio_enc.c +++ b/lib/libcrypto/evp/bio_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_enc.c,v 1.20 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: bio_enc.c,v 1.22 2018/08/24 19:30:24 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -87,7 +87,7 @@ typedef struct enc_struct { char buf[ENC_BLOCK_SIZE + BUF_OFFSET + 2]; } BIO_ENC_CTX; -static BIO_METHOD methods_enc = { +static const BIO_METHOD methods_enc = { .type = BIO_TYPE_CIPHER, .name = "cipher", .bwrite = enc_write, @@ -98,7 +98,7 @@ static BIO_METHOD methods_enc = { .callback_ctrl = enc_callback_ctrl }; -BIO_METHOD * +const BIO_METHOD * BIO_f_cipher(void) { return (&methods_enc); @@ -404,23 +404,32 @@ EVP_CIPHER_ctx *c; } */ -void +int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, const unsigned char *i, int e) { BIO_ENC_CTX *ctx; + long (*cb)(BIO *, int, const char *, int, long, long); if (b == NULL) - return; + return 0; - if ((b->callback != NULL) && - (b->callback(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 0L) <= 0)) - return; + if ((ctx = BIO_get_data(b)) == NULL) + return 0; - b->init = 1; - ctx = (BIO_ENC_CTX *)b->ptr; - EVP_CipherInit_ex(&(ctx->cipher), c, NULL, k, i, e); + if ((cb = BIO_get_callback(b)) != NULL) { + if (cb(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 0L) + <= 0) + return 0; + } - if (b->callback != NULL) - b->callback(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 1L); + BIO_set_init(b, 1); + + if (!EVP_CipherInit_ex(&(ctx->cipher), c, NULL, k, i, e)) + return 0; + + if (cb != NULL) + return cb(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 1L); + + return 1; } diff --git a/lib/libcrypto/evp/bio_md.c b/lib/libcrypto/evp/bio_md.c index b1973746a7..44f72185dc 100644 --- a/lib/libcrypto/evp/bio_md.c +++ b/lib/libcrypto/evp/bio_md.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_md.c,v 1.14 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: bio_md.c,v 1.15 2018/05/02 15:51:41 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -74,7 +74,7 @@ static int md_new(BIO *h); static int md_free(BIO *data); static long md_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); -static BIO_METHOD methods_md = { +static const BIO_METHOD methods_md = { .type = BIO_TYPE_MD, .name = "message digest", .bwrite = md_write, @@ -86,7 +86,7 @@ static BIO_METHOD methods_md = { .callback_ctrl = md_callback_ctrl }; -BIO_METHOD * +const BIO_METHOD * BIO_f_md(void) { return (&methods_md); diff --git a/lib/libcrypto/evp/digest.c b/lib/libcrypto/evp/digest.c index b69a928ab8..6a7d86d702 100644 --- a/lib/libcrypto/evp/digest.c +++ b/lib/libcrypto/evp/digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: digest.c,v 1.29 2018/02/17 14:55:31 jsing Exp $ */ +/* $OpenBSD: digest.c,v 1.30 2018/04/14 07:09:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -146,9 +146,8 @@ EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) /* Ensure an ENGINE left lying around from last time is cleared * (the previous check attempted to avoid this if the same * ENGINE and EVP_MD could be used). */ - if (ctx->engine) - ENGINE_finish(ctx->engine); - if (impl) { + ENGINE_finish(ctx->engine); + if (impl != NULL) { if (!ENGINE_init(impl)) { EVPerror(EVP_R_INITIALIZATION_ERROR); return 0; @@ -156,10 +155,10 @@ EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) } else /* Ask if an ENGINE is reserved for this job */ impl = ENGINE_get_digest_engine(type->type); - if (impl) { + if (impl != NULL) { /* There's an ENGINE for this job ... (apparently) */ const EVP_MD *d = ENGINE_get_digest(impl, type->type); - if (!d) { + if (d == NULL) { /* Same comment from evp_enc.c */ EVPerror(EVP_R_INITIALIZATION_ERROR); ENGINE_finish(impl); @@ -384,10 +383,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) freezero(ctx->md_data, ctx->digest->ctx_size); EVP_PKEY_CTX_free(ctx->pctx); #ifndef OPENSSL_NO_ENGINE - if (ctx->engine) - /* The EVP_MD we used belongs to an ENGINE, release the - * functional reference we held for this reason. */ - ENGINE_finish(ctx->engine); + ENGINE_finish(ctx->engine); #endif memset(ctx, 0, sizeof(*ctx)); diff --git a/lib/libcrypto/evp/encode.c b/lib/libcrypto/evp/encode.c index 1097a7c903..07cfd7f2bc 100644 --- a/lib/libcrypto/evp/encode.c +++ b/lib/libcrypto/evp/encode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: encode.c,v 1.24 2016/05/04 15:05:13 tedu Exp $ */ +/* $OpenBSD: encode.c,v 1.25 2018/08/24 19:45:11 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -120,7 +120,7 @@ EVP_EncodeInit(EVP_ENCODE_CTX *ctx) ctx->line_num = 0; } -void +int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) { @@ -128,13 +128,13 @@ EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, size_t total = 0; *outl = 0; - if (inl == 0) - return; + if (inl <= 0) + return 0; OPENSSL_assert(ctx->length <= (int)sizeof(ctx->enc_data)); if (ctx->length - ctx->num > inl) { memcpy(&(ctx->enc_data[ctx->num]), in, inl); ctx->num += inl; - return; + return 1; } if (ctx->num != 0) { i = ctx->length - ctx->num; @@ -160,12 +160,14 @@ EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, if (total > INT_MAX) { /* Too much output data! */ *outl = 0; - return; + return 0; } if (inl != 0) memcpy(&(ctx->enc_data[0]), in, inl); ctx->num = inl; *outl = total; + + return 1; } void diff --git a/lib/libcrypto/evp/evp.h b/lib/libcrypto/evp/evp.h index e12e771cc5..c09e2c046a 100644 --- a/lib/libcrypto/evp/evp.h +++ b/lib/libcrypto/evp/evp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: evp.h,v 1.58 2018/02/20 18:05:28 tb Exp $ */ +/* $OpenBSD: evp.h,v 1.69 2018/09/12 06:35:38 djm Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -491,10 +491,15 @@ unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher); #define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE) const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx); int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx); int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx, + unsigned char *iv, size_t len); +int EVP_CIPHER_CTX_set_iv(EVP_CIPHER_CTX *ctx, + const unsigned char *iv, size_t len); int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in); void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); @@ -617,7 +622,8 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen); int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey); -int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen); +int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen); int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *ek, int ekl, const unsigned char *iv, EVP_PKEY *priv); @@ -629,7 +635,7 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); -void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, +int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl); void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl); int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); @@ -651,10 +657,10 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); #ifndef OPENSSL_NO_BIO -BIO_METHOD *BIO_f_md(void); -BIO_METHOD *BIO_f_base64(void); -BIO_METHOD *BIO_f_cipher(void); -void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, +const BIO_METHOD *BIO_f_md(void); +const BIO_METHOD *BIO_f_base64(void); +const BIO_METHOD *BIO_f_cipher(void); +int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, const unsigned char *i, int enc); #endif @@ -866,12 +872,12 @@ int EVP_PKEY_encrypt_old(unsigned char *enc_key, const unsigned char *key, int EVP_PKEY_type(int type); int EVP_PKEY_id(const EVP_PKEY *pkey); int EVP_PKEY_base_id(const EVP_PKEY *pkey); -int EVP_PKEY_bits(EVP_PKEY *pkey); -int EVP_PKEY_size(EVP_PKEY *pkey); +int EVP_PKEY_bits(const EVP_PKEY *pkey); +int EVP_PKEY_size(const EVP_PKEY *pkey); int EVP_PKEY_set_type(EVP_PKEY *pkey, int type); int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len); int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); -void *EVP_PKEY_get0(EVP_PKEY *pkey); +void *EVP_PKEY_get0(const EVP_PKEY *pkey); #ifndef OPENSSL_NO_RSA struct rsa_st; @@ -995,7 +1001,7 @@ int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, int *ppkey_flags, const char **pinfo, const char **ppem_str, const EVP_PKEY_ASN1_METHOD *ameth); -const EVP_PKEY_ASN1_METHOD* EVP_PKEY_get0_asn1(EVP_PKEY *pkey); +const EVP_PKEY_ASN1_METHOD* EVP_PKEY_get0_asn1(const EVP_PKEY *pkey); EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info); void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, @@ -1010,7 +1016,7 @@ void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_size)(const EVP_PKEY *pk), int (*pkey_bits)(const EVP_PKEY *pk)); void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, - int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf), + int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf), int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk), int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)); diff --git a/lib/libcrypto/evp/evp_enc.c b/lib/libcrypto/evp/evp_enc.c index de7c690ca7..db2deb6905 100644 --- a/lib/libcrypto/evp/evp_enc.c +++ b/lib/libcrypto/evp/evp_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_enc.c,v 1.38 2018/02/17 16:54:08 jsing Exp $ */ +/* $OpenBSD: evp_enc.c,v 1.39 2018/04/14 07:09:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -577,10 +577,7 @@ EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) } free(c->cipher_data); #ifndef OPENSSL_NO_ENGINE - if (c->engine) - /* The EVP_CIPHER we used belongs to an ENGINE, release the - * functional reference we held for this reason. */ - ENGINE_finish(c->engine); + ENGINE_finish(c->engine); #endif explicit_bzero(c, sizeof(EVP_CIPHER_CTX)); return 1; diff --git a/lib/libcrypto/evp/evp_key.c b/lib/libcrypto/evp/evp_key.c index 33de513ef2..91d0fc0de9 100644 --- a/lib/libcrypto/evp/evp_key.c +++ b/lib/libcrypto/evp/evp_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_key.c,v 1.24 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: evp_key.c,v 1.26 2018/08/14 17:59:26 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -101,17 +101,21 @@ EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, char buff[BUFSIZ]; UI *ui; + if (len > BUFSIZ) + len = BUFSIZ; + /* Ensure that 0 <= min <= len - 1. In particular, 1 <= len. */ + if (min < 0 || len - 1 < min) + return -1; if ((prompt == NULL) && (prompt_string[0] != '\0')) prompt = prompt_string; ui = UI_new(); if (ui == NULL) return -1; - if (UI_add_input_string(ui, prompt, 0, buf, min, - (len >= BUFSIZ) ? BUFSIZ - 1 : len) < 0) + if (UI_add_input_string(ui, prompt, 0, buf, min, len - 1) < 0) return -1; if (verify) { - if (UI_add_verify_string(ui, prompt, 0, buff, min, - (len >= BUFSIZ) ? BUFSIZ - 1 : len, buf) < 0) + if (UI_add_verify_string(ui, prompt, 0, buff, min, len - 1, buf) + < 0) return -1; } ret = UI_process(ui); diff --git a/lib/libcrypto/evp/evp_lib.c b/lib/libcrypto/evp/evp_lib.c index ad97a3b7b9..90107739e7 100644 --- a/lib/libcrypto/evp/evp_lib.c +++ b/lib/libcrypto/evp/evp_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_lib.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: evp_lib.c,v 1.17 2018/09/12 06:35:38 djm Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -207,6 +207,12 @@ EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) return ctx->cipher; } +int +EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx) +{ + return ctx->encrypt; +} + unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher) { @@ -268,6 +274,44 @@ EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) } int +EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx, unsigned char *iv, size_t len) +{ + if (ctx == NULL || len != EVP_CIPHER_CTX_iv_length(ctx)) + return 0; + if (len > EVP_MAX_IV_LENGTH) + return 0; /* sanity check; shouldn't happen */ + /* + * Skip the memcpy entirely when the requested IV length is zero, + * since the iv pointer may be NULL or invalid. + */ + if (len != 0) { + if (iv == NULL) + return 0; + memcpy(iv, ctx->iv, len); + } + return 1; +} + +int +EVP_CIPHER_CTX_set_iv(EVP_CIPHER_CTX *ctx, const unsigned char *iv, size_t len) +{ + if (ctx == NULL || len != EVP_CIPHER_CTX_iv_length(ctx)) + return 0; + if (len > EVP_MAX_IV_LENGTH) + return 0; /* sanity check; shouldn't happen */ + /* + * Skip the memcpy entirely when the requested IV length is zero, + * since the iv pointer may be NULL or invalid. + */ + if (len != 0) { + if (iv == NULL) + return 0; + memcpy(ctx->iv, iv, len); + } + return 1; +} + +int EVP_MD_block_size(const EVP_MD *md) { return md->block_size; diff --git a/lib/libcrypto/evp/evp_pkey.c b/lib/libcrypto/evp/evp_pkey.c index 4dcd2a15a9..9ff544b84a 100644 --- a/lib/libcrypto/evp/evp_pkey.c +++ b/lib/libcrypto/evp/evp_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_pkey.c,v 1.19 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: evp_pkey.c,v 1.23 2018/08/24 20:26:03 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -67,10 +67,10 @@ /* Extract a private key from a PKCS8 structure */ EVP_PKEY * -EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8) +EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8) { EVP_PKEY *pkey = NULL; - ASN1_OBJECT *algoid; + const ASN1_OBJECT *algoid; char obj_tmp[80]; if (!PKCS8_pkey_get0(&algoid, NULL, NULL, NULL, p8)) @@ -105,16 +105,10 @@ error: return NULL; } -PKCS8_PRIV_KEY_INFO * -EVP_PKEY2PKCS8(EVP_PKEY *pkey) -{ - return EVP_PKEY2PKCS8_broken(pkey, PKCS8_OK); -} - /* Turn a private key into a PKCS8 structure */ PKCS8_PRIV_KEY_INFO * -EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken) +EVP_PKEY2PKCS8(EVP_PKEY *pkey) { PKCS8_PRIV_KEY_INFO *p8; @@ -122,7 +116,6 @@ EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken) EVPerror(ERR_R_MALLOC_FAILURE); return NULL; } - p8->broken = broken; if (pkey->ameth) { if (pkey->ameth->priv_encode) { @@ -145,27 +138,6 @@ error: return NULL; } -PKCS8_PRIV_KEY_INFO * -PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken) -{ - switch (broken) { - case PKCS8_OK: - p8->broken = PKCS8_OK; - return p8; - break; - - case PKCS8_NO_OCTET: - p8->broken = PKCS8_NO_OCTET; - p8->pkey->type = V_ASN1_SEQUENCE; - return p8; - break; - - default: - EVPerror(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE); - return NULL; - } -} - /* EVP_PKEY attribute functions */ int @@ -181,7 +153,8 @@ EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos) } int -EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, int lastpos) +EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj, + int lastpos) { return X509at_get_attr_by_OBJ(key->attributes, obj, lastpos); } diff --git a/lib/libcrypto/evp/m_md5_sha1.c b/lib/libcrypto/evp/m_md5_sha1.c index 272cdee9dd..4e8a0c32f6 100644 --- a/lib/libcrypto/evp/m_md5_sha1.c +++ b/lib/libcrypto/evp/m_md5_sha1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_md5_sha1.c,v 1.1 2017/02/28 14:15:37 jsing Exp $ */ +/* $OpenBSD: m_md5_sha1.c,v 1.2 2018/08/10 17:30:29 jsing Exp $ */ /* * Copyright (c) 2017 Joel Sing * @@ -20,6 +20,10 @@ #include #include +#ifndef OPENSSL_NO_RSA +#include +#endif + struct md5_sha1_ctx { MD5_CTX md5; SHA_CTX sha1; @@ -74,6 +78,13 @@ static const EVP_MD md5_sha1_md = { .final = md5_sha1_final, .block_size = MD5_CBLOCK, /* MD5_CBLOCK == SHA_CBLOCK */ .ctx_size = sizeof(EVP_MD *) + sizeof(struct md5_sha1_ctx), +#ifndef OPENSSL_NO_RSA + .sign = (evp_sign_method *)RSA_sign, + .verify = (evp_verify_method *)RSA_verify, + .required_pkey_type = { + EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, + }, +#endif }; const EVP_MD * diff --git a/lib/libcrypto/evp/m_sigver.c b/lib/libcrypto/evp/m_sigver.c index 6e955d9480..9e313c3630 100644 --- a/lib/libcrypto/evp/m_sigver.c +++ b/lib/libcrypto/evp/m_sigver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_sigver.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: m_sigver.c,v 1.7 2018/05/13 06:35:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -166,7 +166,7 @@ EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) } int -EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen) +EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen) { EVP_MD_CTX tmp_ctx; unsigned char md[EVP_MAX_MD_SIZE]; diff --git a/lib/libcrypto/evp/p_lib.c b/lib/libcrypto/evp/p_lib.c index 811fe0c86d..0e4c38e218 100644 --- a/lib/libcrypto/evp/p_lib.c +++ b/lib/libcrypto/evp/p_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_lib.c,v 1.20 2018/02/20 18:05:28 tb Exp $ */ +/* $OpenBSD: p_lib.c,v 1.24 2018/05/30 15:40:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -85,7 +85,7 @@ static void EVP_PKEY_free_it(EVP_PKEY *x); int -EVP_PKEY_bits(EVP_PKEY *pkey) +EVP_PKEY_bits(const EVP_PKEY *pkey) { if (pkey && pkey->ameth && pkey->ameth->pkey_bits) return pkey->ameth->pkey_bits(pkey); @@ -93,7 +93,7 @@ EVP_PKEY_bits(EVP_PKEY *pkey) } int -EVP_PKEY_size(EVP_PKEY *pkey) +EVP_PKEY_size(const EVP_PKEY *pkey) { if (pkey && pkey->ameth && pkey->ameth->pkey_size) return pkey->ameth->pkey_size(pkey); @@ -229,11 +229,8 @@ pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len) if ((type == pkey->save_type) && pkey->ameth) return 1; #ifndef OPENSSL_NO_ENGINE - /* If we have an ENGINE release it */ - if (pkey->engine) { - ENGINE_finish(pkey->engine); - pkey->engine = NULL; - } + ENGINE_finish(pkey->engine); + pkey->engine = NULL; #endif } if (str) @@ -241,7 +238,7 @@ pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len) else ameth = EVP_PKEY_asn1_find(&e, type); #ifndef OPENSSL_NO_ENGINE - if (!pkey && e) + if (pkey == NULL) ENGINE_finish(e); #endif if (!ameth) { @@ -280,7 +277,7 @@ EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key) } void * -EVP_PKEY_get0(EVP_PKEY *pkey) +EVP_PKEY_get0(const EVP_PKEY *pkey) { return pkey->pkey.ptr; } @@ -426,8 +423,7 @@ EVP_PKEY_type(int type) else ret = NID_undef; #ifndef OPENSSL_NO_ENGINE - if (e) - ENGINE_finish(e); + ENGINE_finish(e); #endif return ret; } @@ -470,10 +466,8 @@ EVP_PKEY_free_it(EVP_PKEY *x) x->pkey.ptr = NULL; } #ifndef OPENSSL_NO_ENGINE - if (x->engine) { - ENGINE_finish(x->engine); - x->engine = NULL; - } + ENGINE_finish(x->engine); + x->engine = NULL; #endif } diff --git a/lib/libcrypto/evp/pmeth_lib.c b/lib/libcrypto/evp/pmeth_lib.c index fc5f4ef91e..6b86a0ecfb 100644 --- a/lib/libcrypto/evp/pmeth_lib.c +++ b/lib/libcrypto/evp/pmeth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_lib.c,v 1.13 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: pmeth_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -188,10 +188,9 @@ int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) } ret = malloc(sizeof(EVP_PKEY_CTX)); - if (!ret) { + if (ret == NULL) { #ifndef OPENSSL_NO_ENGINE - if (e) - ENGINE_finish(e); + ENGINE_finish(e); #endif EVPerror(ERR_R_MALLOC_FAILURE); return NULL; @@ -394,10 +393,7 @@ EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) EVP_PKEY_free(ctx->pkey); EVP_PKEY_free(ctx->peerkey); #ifndef OPENSSL_NO_ENGINE - if (ctx->engine) - /* The EVP_PKEY_CTX we used belongs to an ENGINE, release the - * functional reference we held for this reason. */ - ENGINE_finish(ctx->engine); + ENGINE_finish(ctx->engine); #endif free(ctx); } diff --git a/lib/libcrypto/gost/gostr341001_ameth.c b/lib/libcrypto/gost/gostr341001_ameth.c index b6958c77d5..16295996dc 100644 --- a/lib/libcrypto/gost/gostr341001_ameth.c +++ b/lib/libcrypto/gost/gostr341001_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_ameth.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: gostr341001_ameth.c,v 1.15 2018/08/24 20:22:15 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -201,7 +201,7 @@ pub_decode_gost01(EVP_PKEY *pk, X509_PUBKEY *pub) == 0) return 0; (void)EVP_PKEY_assign_GOST(pk, NULL); - X509_ALGOR_get0(NULL, &ptype, (void **)&pval, palg); + X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg); if (ptype != V_ASN1_SEQUENCE) { GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT); return 0; @@ -394,14 +394,14 @@ priv_print_gost01(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx) } static int -priv_decode_gost01(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf) +priv_decode_gost01(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf) { const unsigned char *pkey_buf = NULL, *p = NULL; int priv_len = 0; BIGNUM *pk_num = NULL; int ret = 0; - X509_ALGOR *palg = NULL; - ASN1_OBJECT *palg_obj = NULL; + const X509_ALGOR *palg = NULL; + const ASN1_OBJECT *palg_obj = NULL; ASN1_INTEGER *priv_key = NULL; GOST_KEY *ec; int ptype = V_ASN1_UNDEF; @@ -410,7 +410,7 @@ priv_decode_gost01(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf) if (PKCS8_pkey_get0(&palg_obj, &pkey_buf, &priv_len, &palg, p8inf) == 0) return 0; (void)EVP_PKEY_assign_GOST(pk, NULL); - X509_ALGOR_get0(NULL, &ptype, (void **)&pval, palg); + X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg); if (ptype != V_ASN1_SEQUENCE) { GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT); return 0; @@ -421,21 +421,17 @@ priv_decode_gost01(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf) p = pkey_buf; if (V_ASN1_OCTET_STRING == *p) { /* New format - Little endian octet string */ - unsigned char rev_buf[32]; - int i; ASN1_OCTET_STRING *s = d2i_ASN1_OCTET_STRING(NULL, &p, priv_len); - if (s == NULL || s->length != 32) { + if (s == NULL) { GOSTerror(EVP_R_DECODE_ERROR); ASN1_STRING_free(s); return 0; } - for (i = 0; i < 32; i++) { - rev_buf[31 - i] = s->data[i]; - } + + pk_num = GOST_le2bn(s->data, s->length, NULL); ASN1_STRING_free(s); - pk_num = BN_bin2bn(rev_buf, 32, NULL); } else { priv_key = d2i_ASN1_INTEGER(NULL, &p, priv_len); if (priv_key == NULL) diff --git a/lib/libcrypto/hkdf/hkdf.c b/lib/libcrypto/hkdf/hkdf.c index 9fe587de13..fa1dfeb067 100644 --- a/lib/libcrypto/hkdf/hkdf.c +++ b/lib/libcrypto/hkdf/hkdf.c @@ -1,3 +1,4 @@ +/* $OpenBSD: hkdf.c,v 1.2 2018/04/03 13:33:53 tb Exp $ */ /* Copyright (c) 2014, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any diff --git a/lib/libcrypto/hkdf/hkdf.h b/lib/libcrypto/hkdf/hkdf.h index fb0fac37af..34450f9dd7 100644 --- a/lib/libcrypto/hkdf/hkdf.h +++ b/lib/libcrypto/hkdf/hkdf.h @@ -1,3 +1,4 @@ +/* $OpenBSD: hkdf.h,v 1.2 2018/04/03 13:33:53 tb Exp $ */ /* Copyright (c) 2014, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any diff --git a/lib/libcrypto/malloc-wrapper.c b/lib/libcrypto/malloc-wrapper.c index 12867387bf..cb9a31186d 100644 --- a/lib/libcrypto/malloc-wrapper.c +++ b/lib/libcrypto/malloc-wrapper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc-wrapper.c,v 1.6 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: malloc-wrapper.c,v 1.7 2018/05/13 13:49:04 jsing Exp $ */ /* * Copyright (c) 2014 Bob Beck * @@ -148,7 +148,6 @@ CRYPTO_realloc(void *ptr, int num, const char *file, int line) { if (num <= 0) return NULL; - return realloc(ptr, num); } @@ -156,18 +155,12 @@ void * CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file, int line) { - void *ret = NULL; - if (num <= 0) return NULL; + /* Original does not support shrinking. */ if (num < old_len) - return NULL; /* original does not support shrinking */ - ret = malloc(num); - if (ret && ptr && old_len > 0) { - memcpy(ret, ptr, old_len); - freezero(ptr, old_len); - } - return ret; + return NULL; + return recallocarray(ptr, old_len, num, 1); } void diff --git a/lib/libcrypto/man/ASN1_INTEGER_get.3 b/lib/libcrypto/man/ASN1_INTEGER_get.3 new file mode 100644 index 0000000000..e3585b4088 --- /dev/null +++ b/lib/libcrypto/man/ASN1_INTEGER_get.3 @@ -0,0 +1,238 @@ +.\" $OpenBSD: ASN1_INTEGER_get.3,v 1.1 2018/07/08 23:00:17 schwarze Exp $ +.\" selective merge up to: +.\" OpenSSL man3/ASN1_INTEGER_get_int64 eaf39a9f Jun 23 10:24:00 2018 +0200 +.\" +.\" This file was written by Dr. Stephen Henson . +.\" Copyright (c) 2015 The OpenSSL Project. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" 3. All advertising materials mentioning features or use of this +.\" software must display the following acknowledgment: +.\" "This product includes software developed by the OpenSSL Project +.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" +.\" +.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to +.\" endorse or promote products derived from this software without +.\" prior written permission. For written permission, please contact +.\" openssl-core@openssl.org. +.\" +.\" 5. Products derived from this software may not be called "OpenSSL" +.\" nor may "OpenSSL" appear in their names without prior written +.\" permission of the OpenSSL Project. +.\" +.\" 6. Redistributions of any form whatsoever must retain the following +.\" acknowledgment: +.\" "This product includes software developed by the OpenSSL Project +.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY +.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR +.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +.\" OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd $Mdocdate: July 8 2018 $ +.Dt ASN1_INTEGER_GET 3 +.Os +.Sh NAME +.Nm ASN1_INTEGER_get , +.Nm ASN1_INTEGER_set , +.Nm BN_to_ASN1_INTEGER , +.Nm ASN1_INTEGER_to_BN , +.Nm ASN1_ENUMERATED_get , +.Nm ASN1_ENUMERATED_set , +.Nm BN_to_ASN1_ENUMERATED , +.Nm ASN1_ENUMERATED_to_BN +.Nd ASN.1 INTEGER and ENUMERATED utilities +.Sh SYNOPSIS +.In openssl/asn1.h +.Ft long +.Fo ASN1_INTEGER_get +.Fa "const ASN1_INTEGER *a" +.Fc +.Ft int +.Fo ASN1_INTEGER_set +.Fa "ASN1_INTEGER *a" +.Fa "long v" +.Fc +.Ft ASN1_INTEGER * +.Fo BN_to_ASN1_INTEGER +.Fa "const BIGNUM *bn" +.Fa "ASN1_INTEGER *ai" +.Fc +.Ft BIGNUM * +.Fo ASN1_INTEGER_to_BN +.Fa "const ASN1_INTEGER *ai" +.Fa "BIGNUM *bn" +.Fc +.Ft long +.Fo ASN1_ENUMERATED_get +.Fa "const ASN1_ENUMERATED *a" +.Fc +.Ft int +.Fo ASN1_ENUMERATED_set +.Fa "ASN1_ENUMERATED *a" +.Fa "long v" +.Fc +.Ft ASN1_ENUMERATED * +.Fo BN_to_ASN1_ENUMERATED +.Fa "const BIGNUM *bn" +.Fa "ASN1_ENUMERATED *ai" +.Fc +.Ft BIGNUM * +.Fo ASN1_ENUMERATED_to_BN +.Fa "const ASN1_ENUMERATED *ai" +.Fa "BIGNUM *bn" +.Fc +.Sh DESCRIPTION +These functions convert to and from +.Vt ASN1_INTEGER +and +.Vt ASN1_ENUMERATED +objects. +.Pp +.Fn ASN1_INTEGER_get +converts +.Fa a +to the +.Vt long +type. +.Pp +.Fn ASN1_INTEGER_set +sets the value of +.Fa a +to +.Fa v . +.Pp +.Fn BN_to_ASN1_INTEGER +converts +.Fa bn +to an +.Vt ASN1_INTEGER . +If +.Fa ai +is +.Dv NULL , +a new +.Vt ASN1_INTEGER +object is returned. +Otherwise, the existing object +.Fa ai +is used instead. +.Pp +.Fn ASN1_INTEGER_to_BN +converts +.Fa ai +into a +.Vt BIGNUM . +If +.Fa bn +is +.Dv NULL , +a new +.Vt BIGNUM +object is returned. +Otherwise, the existing object +.Fa bn +is used instead. +.Pp +.Fn ASN1_ENUMERATED_get , +.Fn ASN1_ENUMERATED_set , +.Fn BN_to_ASN1_ENUMERATED , +and +.Fn ASN1_ENUMERATED_to_BN +behave like their +.Vt ASN1_INTEGER +counterparts except that they operate on an +.Vt ASN1_ENUMERATED +object. +.Sh RETURN VALUES +.Fn ASN1_INTEGER_get +and +.Fn ASN1_ENUMERATED_get +return the converted value, 0 if +.Fa a +is +.Dv NULL , +or \-1 on error, which is ambiguous because \-1 is a legitimate +value for an +.Vt ASN1_INTEGER . +.Pp +.Fn ASN1_INTEGER_set +and +.Fn ASN1_ENUMERATED_set +return 1 for success or 0 for failure. +They only fail if a memory allocation error occurs. +.Pp +.Fn BN_to_ASN1_INTEGER +and +.Fn BN_to_ASN1_ENUMERATED +return an +.Vt ASN1_INTEGER +or +.Vt ASN1_ENUMERATED +object, respectively, or +.Dv NULL +if an error occurs. +They only fail due to memory allocation errors. +.Pp +.Fn ASN1_INTEGER_to_BN +and +.Fn ASN1_ENUMERATED_to_BN +return a +.Vt BIGNUM +object of +.Dv NULL +if an error occurs. +They can fail if the passed type is incorrect (due to a programming error) +or due to memory allocation failures. +.Sh HISTORY +.Fn ASN1_INTEGER_set +first appeared in SSLeay 0.5.1. +.Fn ASN1_INTEGER_get , +.Fn BN_to_ASN1_INTEGER , +and +.Fn ASN1_INTEGER_to_BN +first appeared in SSLeay 0.6.0. +These functions have been available since +.Ox 2.3 . +.Pp +.Fn ASN1_ENUMERATED_get , +.Fn ASN1_ENUMERATED_set , +.Fn BN_to_ASN1_ENUMERATED , +and +.Fn ASN1_ENUMERATED_to_BN +first appeared in OpenSSL 0.9.2b and have been available since +.Ox 2.6 . +.Sh CAVEATS +In general an +.Vt ASN1_INTEGER +or +.Vt ASN1_ENUMERATED +type can contain an integer of almost arbitrary size +and so cannot always be represented by a C +.Vt long +type. +The ambiguous return values of +.Fn ASN1_INTEGER_get +and +.Fn ASN1_ENUMERATED_get +imply that these functions should be avoided if possible. diff --git a/lib/libcrypto/man/ASN1_OBJECT_new.3 b/lib/libcrypto/man/ASN1_OBJECT_new.3 index 489bbaf5e1..b661337ca0 100644 --- a/lib/libcrypto/man/ASN1_OBJECT_new.3 +++ b/lib/libcrypto/man/ASN1_OBJECT_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_OBJECT_new.3,v 1.9 2018/03/20 18:35:13 schwarze Exp $ +.\" $OpenBSD: ASN1_OBJECT_new.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d4 Mar 19 12:28:58 2016 -0400 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ASN1_OBJECT_NEW 3 .Os .Sh NAME @@ -137,5 +137,5 @@ Otherwise it returns a pointer to the new object. .Fn ASN1_OBJECT_new and .Fn ASN1_OBJECT_free -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/ASN1_STRING_length.3 b/lib/libcrypto/man/ASN1_STRING_length.3 index 7e10d131fd..65501acf31 100644 --- a/lib/libcrypto/man/ASN1_STRING_length.3 +++ b/lib/libcrypto/man/ASN1_STRING_length.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: ASN1_STRING_length.3,v 1.13 2018/03/23 23:18:17 schwarze Exp $ -.\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 +.\" $OpenBSD: ASN1_STRING_length.3,v 1.17 2018/05/19 22:55:17 schwarze Exp $ +.\" full merge up to: OpenSSL 4a56d2a3 Feb 25 16:49:27 2018 +0300 .\" .\" This file is a derived work. .\" The changes are covered by the following Copyright and license: @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt ASN1_STRING_LENGTH 3 .Os .Sh NAME @@ -84,8 +84,8 @@ .In openssl/asn1.h .Ft int .Fo ASN1_STRING_cmp -.Fa "ASN1_STRING *a" -.Fa "ASN1_STRING *b" +.Fa "const ASN1_STRING *a" +.Fa "const ASN1_STRING *b" .Fc .Ft unsigned char * .Fo ASN1_STRING_data @@ -93,7 +93,7 @@ .Fc .Ft ASN1_STRING * .Fo ASN1_STRING_dup -.Fa "ASN1_STRING *a" +.Fa "const ASN1_STRING *a" .Fc .Ft const unsigned char * .Fo ASN1_STRING_get0_data @@ -101,7 +101,7 @@ .Fc .Ft int .Fo ASN1_STRING_length -.Fa "ASN1_STRING *x" +.Fa "const ASN1_STRING *x" .Fc .Ft void .Fo ASN1_STRING_length_set @@ -117,11 +117,11 @@ .Ft int .Fo ASN1_STRING_to_UTF8 .Fa "unsigned char **out" -.Fa "ASN1_STRING *in" +.Fa "const ASN1_STRING *in" .Fc .Ft int .Fo ASN1_STRING_type -.Fa "ASN1_STRING *x" +.Fa "const ASN1_STRING *x" .Fc .Sh DESCRIPTION These functions manipulate @@ -240,9 +240,9 @@ is NUL terminated, and it may contain embedded NUL characters. The format of the data depends on the string type: for example for an .Vt IA5String -the data contains ASCII characters, a +the data contains ASCII characters, for a .Vt BMPString -two bytes per character in big endian format, and a +two bytes per character in big endian format, and for a .Vt UTF8String UTF-8 characters. .Pp @@ -291,12 +291,14 @@ returns an integer constant, for example .Xr ERR_get_error 3 .Sh HISTORY .Fn ASN1_STRING_cmp , -.Fn ASN1_STRING_data , .Fn ASN1_STRING_dup , -.Fn ASN1_STRING_set , +and +.Fn ASN1_STRING_set +first appeared in SSLeay 0.6.5. +.Fn ASN1_STRING_data and .Fn ASN1_STRING_type -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.8.0. .Fn ASN1_STRING_length first appeared in SSLeay 0.9.0. All these functions have been available since diff --git a/lib/libcrypto/man/ASN1_STRING_new.3 b/lib/libcrypto/man/ASN1_STRING_new.3 index 2072622706..07093eee51 100644 --- a/lib/libcrypto/man/ASN1_STRING_new.3 +++ b/lib/libcrypto/man/ASN1_STRING_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_STRING_new.3,v 1.14 2018/03/21 17:57:48 schwarze Exp $ +.\" $OpenBSD: ASN1_STRING_new.3,v 1.15 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Tue Mar 24 07:52:24 2015 -0400 .\" .\" Copyright (c) 2017 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ASN1_STRING_NEW 3 .Os .Sh NAME @@ -207,9 +207,6 @@ if an error occurs. .Xr d2i_ASN1_OCTET_STRING 3 , .Xr ERR_get_error 3 .Sh HISTORY -.Fn ASN1_STRING_new , -.Fn ASN1_STRING_type_new , -.Fn ASN1_STRING_free , .Fn ASN1_OCTET_STRING_new , .Fn ASN1_OCTET_STRING_free , .Fn ASN1_BIT_STRING_new , @@ -218,10 +215,6 @@ if an error occurs. .Fn ASN1_INTEGER_free , .Fn ASN1_IA5STRING_new , .Fn ASN1_IA5STRING_free , -.Fn ASN1_UNIVERSALSTRING_new , -.Fn ASN1_UNIVERSALSTRING_free , -.Fn ASN1_GENERALSTRING_new , -.Fn ASN1_GENERALSTRING_free , .Fn ASN1_T61STRING_new , .Fn ASN1_T61STRING_free , .Fn ASN1_PRINTABLESTRING_new , @@ -231,7 +224,18 @@ if an error occurs. .Fn ASN1_UTCTIME_new , and .Fn ASN1_UTCTIME_free -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.5.1. +.Fn ASN1_STRING_new , +.Fn ASN1_STRING_type_new , +and +.Fn ASN1_STRING_free +first appeared in SSLeay 0.6.5. +.Fn ASN1_UNIVERSALSTRING_new , +.Fn ASN1_UNIVERSALSTRING_free , +.Fn ASN1_GENERALSTRING_new , +and +.Fn ASN1_GENERALSTRING_free +first appeared in SSLeay 0.8.0. .Fn ASN1_BMPSTRING_new , .Fn ASN1_BMPSTRING_free , .Fn ASN1_GENERALIZEDTIME_new , diff --git a/lib/libcrypto/man/ASN1_STRING_print_ex.3 b/lib/libcrypto/man/ASN1_STRING_print_ex.3 index a246bbb93b..03d210084f 100644 --- a/lib/libcrypto/man/ASN1_STRING_print_ex.3 +++ b/lib/libcrypto/man/ASN1_STRING_print_ex.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_STRING_print_ex.3,v 1.12 2018/03/22 17:11:04 schwarze Exp $ +.\" $OpenBSD: ASN1_STRING_print_ex.3,v 1.14 2018/04/25 15:17:52 schwarze Exp $ .\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt ASN1_STRING_PRINT_EX 3 .Os .Sh NAME @@ -64,19 +64,19 @@ .Ft int .Fo ASN1_STRING_print_ex .Fa "BIO *out" -.Fa "ASN1_STRING *str" +.Fa "const ASN1_STRING *str" .Fa "unsigned long flags" .Fc .Ft int .Fo ASN1_STRING_print_ex_fp .Fa "FILE *fp" -.Fa "ASN1_STRING *str" +.Fa "const ASN1_STRING *str" .Fa "unsigned long flags" .Fc .Ft int .Fo ASN1_STRING_print .Fa "BIO *out" -.Fa "ASN1_STRING *str" +.Fa "const ASN1_STRING *str" .Fc .Ft const char * .Fo ASN1_tag2str @@ -223,7 +223,7 @@ returns a static string. .Xr X509_NAME_print_ex 3 .Sh HISTORY .Fn ASN1_STRING_print -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.6.5 and has been available since .Ox 2.4 . .Pp .Fn ASN1_tag2str diff --git a/lib/libcrypto/man/ASN1_TIME_set.3 b/lib/libcrypto/man/ASN1_TIME_set.3 index 3d218745b3..7437224cc5 100644 --- a/lib/libcrypto/man/ASN1_TIME_set.3 +++ b/lib/libcrypto/man/ASN1_TIME_set.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: ASN1_TIME_set.3,v 1.10 2018/03/23 23:18:17 schwarze Exp $ -.\" OpenSSL ASN1_TIME_set.pod cf37aaa3 Aug 4 11:24:03 2017 +1000 -.\" OpenSSL ASN1_TIME_set.pod e9b77246 Jan 20 19:58:49 2017 +0100 +.\" $OpenBSD: ASN1_TIME_set.3,v 1.13 2018/04/25 15:17:52 schwarze Exp $ +.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 +.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000 .\" .\" This file was written by Dr. Stephen Henson .\" and Todd Short . @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt ASN1_TIME_SET 3 .Os .Sh NAME @@ -158,7 +158,7 @@ .Fc .Ft ASN1_GENERALIZEDTIME * .Fo ASN1_TIME_to_generalizedtime -.Fa "ASN1_TIME *t" +.Fa "const ASN1_TIME *t" .Fa "ASN1_GENERALIZEDTIME **out" .Fc .Sh DESCRIPTION @@ -214,7 +214,7 @@ may change the type from .Vt ASN1_GENERALIZEDTIME to .Vt ASN1_UTCTIME -or vise-versa depending on the resulting year. +or vice versa depending on the resulting year. The functions .Fn ASN1_UTCTIME_adj and @@ -396,11 +396,12 @@ ASN1_STRING_free(tm); BIO_free(b); .Ed .Sh HISTORY -.Fn ASN1_UTCTIME_set , -.Fn ASN1_UTCTIME_check , +.Fn ASN1_UTCTIME_check and .Fn ASN1_UTCTIME_print -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.5.1. +.Fn ASN1_UTCTIME_set +first appeared in SSLeay 0.6.0. .Fn ASN1_UTCTIME_set_string first appeared in SSLeay 0.9.0. All these functions have been available since diff --git a/lib/libcrypto/man/ASN1_TYPE_get.3 b/lib/libcrypto/man/ASN1_TYPE_get.3 index aae3bc8ee4..b02c91580f 100644 --- a/lib/libcrypto/man/ASN1_TYPE_get.3 +++ b/lib/libcrypto/man/ASN1_TYPE_get.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_TYPE_get.3,v 1.6 2018/03/23 02:20:16 schwarze Exp $ +.\" $OpenBSD: ASN1_TYPE_get.3,v 1.8 2018/04/25 15:17:52 schwarze Exp $ .\" OpenSSL 99d63d46 Mon Jun 6 00:43:05 2016 -0400 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt ASN1_TYPE_GET 3 .Os .Sh NAME @@ -84,7 +84,7 @@ .Fn ASN1_TYPE_free "ASN1_TYPE *a" .Ft int .Fo ASN1_TYPE_get -.Fa "ASN1_TYPE *a" +.Fa "const ASN1_TYPE *a" .Fc .Ft void .Fo ASN1_TYPE_set @@ -100,8 +100,8 @@ .Fc .Ft int .Fo ASN1_TYPE_cmp -.Fa "ASN1_TYPE *a" -.Fa "ASN1_TYPE *b" +.Fa "const ASN1_TYPE *a" +.Fa "const ASN1_TYPE *b" .Fc .Sh DESCRIPTION .Vt ASN1_TYPE @@ -279,12 +279,15 @@ returns 0 for a match or non-zero for a mismatch. .Xr d2i_ASN1_TYPE 3 , .Xr OBJ_dup 3 .Sh HISTORY -.Fn ASN1_TYPE_new , -.Fn ASN1_TYPE_free , -.Fn ASN1_TYPE_get , +.Fn ASN1_TYPE_new +and +.Fn ASN1_TYPE_free +first appeared in SSLeay 0.5.1. +.Fn ASN1_TYPE_get and .Fn ASN1_TYPE_set -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Pp .Fn ASN1_TYPE_set1 @@ -292,5 +295,6 @@ first appeared in OpenSSL 0.9.8h and has been available since .Ox 4.5 . .Pp .Fn ASN1_TYPE_cmp -first appeared in OpenSSL 0.9.8zd and has been available since +first appeared in OpenSSL 0.9.8zd, 1.0.0p, and 1.0.1k +and has been available since .Ox 4.9 . diff --git a/lib/libcrypto/man/ASN1_generate_nconf.3 b/lib/libcrypto/man/ASN1_generate_nconf.3 index cc0e6fc060..87ff769f18 100644 --- a/lib/libcrypto/man/ASN1_generate_nconf.3 +++ b/lib/libcrypto/man/ASN1_generate_nconf.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_generate_nconf.3,v 1.10 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: ASN1_generate_nconf.3,v 1.11 2018/04/25 15:17:52 schwarze Exp $ .\" OpenSSL 05ea606a Fri May 20 20:52:46 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson. @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt ASN1_GENERATE_NCONF 3 .Os .Sh NAME @@ -60,12 +60,12 @@ .In openssl/asn1.h .Ft ASN1_TYPE * .Fo ASN1_generate_nconf -.Fa "char *str" +.Fa "const char *str" .Fa "CONF *nconf" .Fc .Ft ASN1_TYPE * .Fo ASN1_generate_v3 -.Fa "char *str" +.Fa "const char *str" .Fa "X509V3_CTX *cnf" .Fc .Sh DESCRIPTION diff --git a/lib/libcrypto/man/ASN1_item_d2i.3 b/lib/libcrypto/man/ASN1_item_d2i.3 index 1dce2d23c2..705deedd55 100644 --- a/lib/libcrypto/man/ASN1_item_d2i.3 +++ b/lib/libcrypto/man/ASN1_item_d2i.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_item_d2i.3,v 1.7 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: ASN1_item_d2i.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL doc/man3/d2i_X509.pod b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ASN1_ITEM_D2I 3 .Os .Sh NAME @@ -367,7 +367,7 @@ if (d2i_X509(&x, &p, len) == NULL) .Fn d2i_ASN1_TYPE and .Fn i2d_ASN1_TYPE -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn ASN1_item_d2i , diff --git a/lib/libcrypto/man/BF_set_key.3 b/lib/libcrypto/man/BF_set_key.3 index 7c75a17c69..7357f0cfc3 100644 --- a/lib/libcrypto/man/BF_set_key.3 +++ b/lib/libcrypto/man/BF_set_key.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BF_set_key.3,v 1.7 2018/03/21 05:49:43 schwarze Exp $ +.\" $OpenBSD: BF_set_key.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Jul 19 09:27:53 2016 -0400 .\" .\" This file was written by Richard Levitte . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BF_SET_KEY 3 .Os .Sh NAME @@ -258,7 +258,15 @@ Be aware that these functions take each 32-bit chunk in host-byte order, which is little-endian on little-endian platforms and big-endian on big-endian ones. .Sh HISTORY -This Blowfish implementation first appeared in SSLeay 0.6.6. +.Fn BF_set_key , +.Fn BF_encrypt , +.Fn BF_ecb_encrypt , +.Fn BF_cbc_encrypt , +.Fn BF_cfb64_encrypt , +.Fn BF_ofb64_encrypt , +and +.Fn BF_options +first appeared in SSLeay 0.6.6. .Fn BF_decrypt first appeared in SSLeay 0.9.0. All these functions have been available since diff --git a/lib/libcrypto/man/BIO_ctrl.3 b/lib/libcrypto/man/BIO_ctrl.3 index a32ed80da7..98c78be134 100644 --- a/lib/libcrypto/man/BIO_ctrl.3 +++ b/lib/libcrypto/man/BIO_ctrl.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_ctrl.3,v 1.13 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: BIO_ctrl.3,v 1.14 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b055fceb Thu Oct 20 09:56:18 2016 +0100 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BIO_CTRL 3 .Os .Sh NAME @@ -317,10 +317,11 @@ operation. .Fn BIO_eof , .Fn BIO_set_close , .Fn BIO_get_close , -.Fn BIO_pending , and +.Fn BIO_pending +first appeared in SSLeay 0.6.0. .Fn BIO_wpending -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.8.1. .Fn BIO_ptr_ctrl , .Fn BIO_int_ctrl , .Fn BIO_get_info_callback diff --git a/lib/libcrypto/man/BIO_f_base64.3 b/lib/libcrypto/man/BIO_f_base64.3 index f2c489e04b..291cabc5de 100644 --- a/lib/libcrypto/man/BIO_f_base64.3 +++ b/lib/libcrypto/man/BIO_f_base64.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_base64.3,v 1.8 2018/03/20 23:56:07 schwarze Exp $ +.\" $OpenBSD: BIO_f_base64.3,v 1.10 2018/05/02 16:04:35 schwarze Exp $ .\" OpenSSL fc1d88f0 Wed Jul 2 22:42:40 2014 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: May 2 2018 $ .Dt BIO_F_BASE64 3 .Os .Sh NAME @@ -58,7 +58,7 @@ .Sh SYNOPSIS .In openssl/bio.h .In openssl/evp.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_f_base64 .Fa void .Fc @@ -124,7 +124,7 @@ BIO_free_all(b64); .Xr BIO_new 3 .Sh HISTORY .Fn BIO_f_base64 -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.6.5 and has been available since .Ox 2.4 . .Sh BUGS The ambiguity of EOF in base64-encoded data can cause additional diff --git a/lib/libcrypto/man/BIO_f_buffer.3 b/lib/libcrypto/man/BIO_f_buffer.3 index d21089250c..21a6e9a5fe 100644 --- a/lib/libcrypto/man/BIO_f_buffer.3 +++ b/lib/libcrypto/man/BIO_f_buffer.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_buffer.3,v 1.8 2018/03/21 06:09:37 schwarze Exp $ +.\" $OpenBSD: BIO_f_buffer.3,v 1.10 2018/05/01 17:05:05 schwarze Exp $ .\" OpenSSL 9b86974e Mar 19 12:32:14 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_F_BUFFER 3 .Os .Sh NAME @@ -62,7 +62,7 @@ .Nd buffering BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_f_buffer .Fa void .Fc @@ -181,13 +181,16 @@ returns 1 if the data was set correctly or 0 if there was an error. .Xr BIO_pop 3 , .Xr BIO_reset 3 .Sh HISTORY -.Fn BIO_f_buffer , -.Fn BIO_get_buffer_num_lines , -.Fn BIO_set_read_buffer_size , -.Fn BIO_set_write_buffer_size , +.Fn BIO_f_buffer +first appeared in SSLeay 0.6.0. +.Fn BIO_get_buffer_num_lines and .Fn BIO_set_buffer_size -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.6.5. +.Fn BIO_set_read_buffer_size +and +.Fn BIO_set_write_buffer_size +first appeared in SSLeay 0.8.0. .Fn BIO_set_buffer_read_data first appeared in SSLeay 0.9.0. All these functions have been available since diff --git a/lib/libcrypto/man/BIO_f_cipher.3 b/lib/libcrypto/man/BIO_f_cipher.3 index 5e1ad82122..ccd374681f 100644 --- a/lib/libcrypto/man/BIO_f_cipher.3 +++ b/lib/libcrypto/man/BIO_f_cipher.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_cipher.3,v 1.8 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BIO_f_cipher.3,v 1.11 2018/08/24 19:32:26 tb Exp $ .\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: August 24 2018 $ .Dt BIO_F_CIPHER 3 .Os .Sh NAME @@ -61,11 +61,11 @@ .Sh SYNOPSIS .In openssl/bio.h .In openssl/evp.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_f_cipher .Fa void .Fc -.Ft void +.Ft int .Fo BIO_set_cipher .Fa "BIO *b" .Fa "const EVP_CIPHER *cipher" @@ -154,6 +154,8 @@ by preceding the cipher BIO with a buffering BIO. .Sh RETURN VALUES .Fn BIO_f_cipher returns the cipher BIO method. +.Fn BIO_set_cipher +returns 1 on success and 0 on error. .Pp .Fn BIO_get_cipher_status returns 1 for a successful decrypt and 0 for failure. @@ -167,7 +169,7 @@ currently always returns 1. .Fn BIO_set_cipher , and .Fn BIO_get_cipher_status -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.5 and have been available since .Ox 2.4 . .Pp .Fn BIO_get_cipher_ctx diff --git a/lib/libcrypto/man/BIO_f_md.3 b/lib/libcrypto/man/BIO_f_md.3 index 80f9cf434d..792d64abce 100644 --- a/lib/libcrypto/man/BIO_f_md.3 +++ b/lib/libcrypto/man/BIO_f_md.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_md.3,v 1.8 2018/03/20 23:56:07 schwarze Exp $ +.\" $OpenBSD: BIO_f_md.3,v 1.10 2018/05/02 16:04:35 schwarze Exp $ .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: May 2 2018 $ .Dt BIO_F_MD 3 .Os .Sh NAME @@ -61,7 +61,7 @@ .Sh SYNOPSIS .In openssl/bio.h .In openssl/evp.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_f_md .Fa void .Fc @@ -248,10 +248,12 @@ BIO_free_all(bio); .Sh HISTORY .Fn BIO_f_md , .Fn BIO_set_md , -.Fn BIO_get_md , and +.Fn BIO_get_md +first appeared in SSLeay 0.6.0. .Fn BIO_get_md_ctx -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.8.1. +These functions have been available since .Ox 2.4 . .Pp Before OpenSSL 1.0.0, the call to diff --git a/lib/libcrypto/man/BIO_f_null.3 b/lib/libcrypto/man/BIO_f_null.3 index 9b4ca7276b..755f37dae7 100644 --- a/lib/libcrypto/man/BIO_f_null.3 +++ b/lib/libcrypto/man/BIO_f_null.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_null.3,v 1.7 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_f_null.3,v 1.9 2018/05/01 17:05:05 schwarze Exp $ .\" OpenSSL e117a890 Sep 14 12:14:41 2000 +0000 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_F_NULL 3 .Os .Sh NAME @@ -56,7 +56,7 @@ .Nd null filter .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_f_null .Fa void .Fc @@ -76,5 +76,5 @@ returns the null filter BIO method. .Xr BIO_new 3 .Sh HISTORY .Fn BIO_f_null -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BIO_find_type.3 b/lib/libcrypto/man/BIO_find_type.3 index 4026d45dd3..99e93167a5 100644 --- a/lib/libcrypto/man/BIO_find_type.3 +++ b/lib/libcrypto/man/BIO_find_type.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_find_type.3,v 1.8 2018/03/22 17:11:04 schwarze Exp $ +.\" $OpenBSD: BIO_find_type.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BIO_FIND_TYPE 3 .Os .Sh NAME @@ -156,10 +156,11 @@ do { .Sh SEE ALSO .Xr BIO_new 3 .Sh HISTORY -.Fn BIO_find_type -and .Fn BIO_method_type -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.0. +.Fn BIO_find_type +first appeared in SSLeay 0.6.6. +Both functions have been available since .Ox 2.4 . .Pp .Fn BIO_next diff --git a/lib/libcrypto/man/BIO_get_ex_new_index.3 b/lib/libcrypto/man/BIO_get_ex_new_index.3 index ad7c5a308c..bf16e1c787 100644 --- a/lib/libcrypto/man/BIO_get_ex_new_index.3 +++ b/lib/libcrypto/man/BIO_get_ex_new_index.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_get_ex_new_index.3,v 1.8 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: BIO_get_ex_new_index.3,v 1.9 2018/04/18 03:39:22 schwarze Exp $ .\" full merge up to: OpenSSL a970b14f Jul 31 18:58:40 2017 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: April 18 2018 $ .Dt BIO_GET_EX_NEW_INDEX 3 .Os .Sh NAME @@ -149,6 +149,9 @@ and first appeared in OpenSSL 0.9.5 and have been available since .Ox 2.7 . .Pp +.Fn ENGINE_get_ex_new_index , +.Fn ENGINE_set_ex_data , +.Fn ENGINE_get_ex_data , .Fn UI_get_ex_new_index , .Fn UI_set_ex_data , and diff --git a/lib/libcrypto/man/BIO_meth_new.3 b/lib/libcrypto/man/BIO_meth_new.3 index 75d5ff23db..2159560596 100644 --- a/lib/libcrypto/man/BIO_meth_new.3 +++ b/lib/libcrypto/man/BIO_meth_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_meth_new.3,v 1.4 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: BIO_meth_new.3,v 1.5 2018/07/09 09:52:18 tb Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: July 9 2018 $ .Dt BIO_METH_NEW 3 .Os .Sh NAME @@ -104,56 +104,56 @@ .Fa "BIO_METHOD *biom" .Fc .Ft int -.Fn "(*BIO_meth_get_write(BIO_METHOD *biom))" "BIO *" "const char *" int +.Fn "(*BIO_meth_get_write(const BIO_METHOD *biom))" "BIO *" "const char *" int .Ft int .Fo BIO_meth_set_write .Fa "BIO_METHOD *biom" .Fa "int (*write)(BIO *, const char *, int)" .Fc .Ft int -.Fn "(*BIO_meth_get_read(BIO_METHOD *biom))" "BIO *" "char *" int +.Fn "(*BIO_meth_get_read(const BIO_METHOD *biom))" "BIO *" "char *" int .Ft int .Fo BIO_meth_set_read .Fa "BIO_METHOD *biom" .Fa "int (*read)(BIO *, char *, int)" .Fc .Ft int -.Fn "(*BIO_meth_get_puts(BIO_METHOD *biom))" "BIO *" "const char *" +.Fn "(*BIO_meth_get_puts(const BIO_METHOD *biom))" "BIO *" "const char *" .Ft int .Fo BIO_meth_set_puts .Fa "BIO_METHOD *biom" .Fa "int (*puts)(BIO *, const char *)" .Fc .Ft int -.Fn "(*BIO_meth_get_gets(BIO_METHOD *biom))" "BIO *" "char *" int +.Fn "(*BIO_meth_get_gets(const BIO_METHOD *biom))" "BIO *" "char *" int .Ft int .Fo BIO_meth_set_gets .Fa "BIO_METHOD *biom" .Fa "int (*gets)(BIO *, char *, int)" .Fc .Ft long -.Fn "(*BIO_meth_get_ctrl(BIO_METHOD *biom))" "BIO *" int long "void *" +.Fn "(*BIO_meth_get_ctrl(const BIO_METHOD *biom))" "BIO *" int long "void *" .Ft int .Fo BIO_meth_set_ctrl .Fa "BIO_METHOD *biom" .Fa "long (*ctrl)(BIO *, int, long, void *)" .Fc .Ft int -.Fn "(*BIO_meth_get_create(BIO_METHOD *biom))" "BIO *" +.Fn "(*BIO_meth_get_create(const BIO_METHOD *biom))" "BIO *" .Ft int .Fo BIO_meth_set_create .Fa "BIO_METHOD *biom" .Fa "int (*create)(BIO *)" .Fc .Ft int -.Fn "(*BIO_meth_get_destroy(BIO_METHOD *biom))" "BIO *" +.Fn "(*BIO_meth_get_destroy(const BIO_METHOD *biom))" "BIO *" .Ft int .Fo BIO_meth_set_destroy .Fa "BIO_METHOD *biom" .Fa "int (*destroy)(BIO *)" .Fc .Ft long -.Fo "(*BIO_meth_get_callback_ctrl(BIO_METHOD *biom))" +.Fo "(*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))" .Fa "BIO *" .Fa int .Fa "BIO_info_cb *" diff --git a/lib/libcrypto/man/BIO_new.3 b/lib/libcrypto/man/BIO_new.3 index 36acc3d9fe..2f8cf37e9f 100644 --- a/lib/libcrypto/man/BIO_new.3 +++ b/lib/libcrypto/man/BIO_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_new.3,v 1.14 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: BIO_new.3,v 1.16 2018/05/01 17:05:05 schwarze Exp $ .\" full merge up to: .\" OpenSSL man3/BIO_new.pod fb46be03 Feb 26 11:51:31 2016 +0000 .\" OpenSSL man7/bio.pod 631c37be Dec 12 16:56:50 2017 +0100 @@ -52,7 +52,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_NEW 3 .Os .Sh NAME @@ -67,7 +67,7 @@ .In openssl/bio.h .Ft BIO * .Fo BIO_new -.Fa "BIO_METHOD *type" +.Fa "const BIO_METHOD *type" .Fc .Ft int .Fo BIO_up_ref @@ -76,7 +76,7 @@ .Ft int .Fo BIO_set .Fa "BIO *a" -.Fa "BIO_METHOD *type" +.Fa "const BIO_METHOD *type" .Fc .Ft int .Fo BIO_free @@ -252,14 +252,13 @@ Create a memory BIO: .Xr BIO_set_callback 3 , .Xr BIO_should_retry 3 .Sh HISTORY -.Fn BIO_new +.Fn BIO_new , +.Fn BIO_set , and .Fn BIO_free first appeared in SSLeay 0.6.0. -.Fn BIO_set -and .Fn BIO_free_all -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.6.6. All these functions have been available since .Ox 2.4 . .Pp diff --git a/lib/libcrypto/man/BIO_push.3 b/lib/libcrypto/man/BIO_push.3 index d107e0d35f..768f4d8579 100644 --- a/lib/libcrypto/man/BIO_push.3 +++ b/lib/libcrypto/man/BIO_push.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_push.3,v 1.6 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_push.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL doc/man3/BIO_push.pod 76ed5a42 Jun 29 13:38:55 2014 +0100 .\" OpenSSL doc/man7/bio.pod a9c85cea Nov 11 09:33:55 2016 +0100 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BIO_PUSH 3 .Os .Sh NAME @@ -178,7 +178,8 @@ as before. .Xr BIO_read 3 .Sh HISTORY .Fn BIO_push -and +first appeared in SSLeay 0.6.0. .Fn BIO_pop -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.4. +Both functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BIO_read.3 b/lib/libcrypto/man/BIO_read.3 index 8551a96667..97514a610a 100644 --- a/lib/libcrypto/man/BIO_read.3 +++ b/lib/libcrypto/man/BIO_read.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_read.3,v 1.7 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_read.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BIO_READ 3 .Os .Sh NAME @@ -174,5 +174,5 @@ the application should retry the operation later. .Fn BIO_write , and .Fn BIO_puts -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BIO_s_accept.3 b/lib/libcrypto/man/BIO_s_accept.3 index a37db94564..4ead28b62f 100644 --- a/lib/libcrypto/man/BIO_s_accept.3 +++ b/lib/libcrypto/man/BIO_s_accept.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_accept.3,v 1.8 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BIO_s_accept.3,v 1.11 2018/05/12 20:12:17 schwarze Exp $ .\" OpenSSL c03726ca Thu Aug 27 12:28:08 2015 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 12 2018 $ .Dt BIO_S_ACCEPT 3 .Os .Sh NAME @@ -64,7 +64,7 @@ .Nd accept BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_accept .Fa void .Fc @@ -79,7 +79,7 @@ .Fc .Ft BIO * .Fo BIO_new_accept -.Fa "char *host_port" +.Fa "const char *host_port" .Fc .Ft long .Fo BIO_set_nbio_accept @@ -358,11 +358,12 @@ BIO_free(cbio2); .Fn BIO_s_accept , .Fn BIO_set_accept_port , .Fn BIO_new_accept , -.Fn BIO_set_nbio_accept , .Fn BIO_set_accept_bios , and .Fn BIO_do_accept -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.8.0. +.Fn BIO_set_nbio_accept +and .Fn BIO_get_accept_port first appeared in SSLeay 0.9.0. All these functions have been available since diff --git a/lib/libcrypto/man/BIO_s_bio.3 b/lib/libcrypto/man/BIO_s_bio.3 index f808939701..171207dfe1 100644 --- a/lib/libcrypto/man/BIO_s_bio.3 +++ b/lib/libcrypto/man/BIO_s_bio.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_bio.3,v 1.12 2018/03/22 17:11:04 schwarze Exp $ +.\" $OpenBSD: BIO_s_bio.3,v 1.13 2018/05/01 17:05:05 schwarze Exp $ .\" OpenSSL c03726ca Aug 27 12:28:08 2015 -0400 .\" .\" This file was written by @@ -53,7 +53,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_S_BIO 3 .Os .Sh NAME @@ -72,7 +72,7 @@ .Nd BIO pair BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_bio .Fa void .Fc diff --git a/lib/libcrypto/man/BIO_s_connect.3 b/lib/libcrypto/man/BIO_s_connect.3 index 66cfff0daa..7ddde85f53 100644 --- a/lib/libcrypto/man/BIO_s_connect.3 +++ b/lib/libcrypto/man/BIO_s_connect.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_connect.3,v 1.8 2018/03/21 06:09:37 schwarze Exp $ +.\" $OpenBSD: BIO_s_connect.3,v 1.11 2018/05/12 20:12:17 schwarze Exp $ .\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 12 2018 $ .Dt BIO_S_CONNECT 3 .Os .Sh NAME @@ -67,13 +67,13 @@ .Nd connect BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_connect .Fa void .Fc .Ft BIO * .Fo BIO_new_connect -.Fa "char *name" +.Fa "const char *name" .Fc .Ft long .Fo BIO_set_conn_hostname @@ -375,7 +375,7 @@ BIO_free(out); .Fn BIO_set_nbio , and .Fn BIO_do_connect -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.8.0. .Fn BIO_set_conn_hostname , .Fn BIO_set_conn_port , .Fn BIO_set_conn_ip , diff --git a/lib/libcrypto/man/BIO_s_fd.3 b/lib/libcrypto/man/BIO_s_fd.3 index 9bc492d79d..5ac33e77ee 100644 --- a/lib/libcrypto/man/BIO_s_fd.3 +++ b/lib/libcrypto/man/BIO_s_fd.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_fd.3,v 1.7 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_s_fd.3,v 1.9 2018/05/01 17:05:05 schwarze Exp $ .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_S_FD 3 .Os .Sh NAME @@ -59,7 +59,7 @@ .Nd file descriptor BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_fd .Fa "void" .Fc @@ -195,6 +195,12 @@ BIO_free(out); .Xr BIO_s_socket 3 , .Xr BIO_seek 3 .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier -and have been available since +.Fn BIO_s_fd , +.Fn BIO_set_fd , +and +.Fn BIO_get_fd +first appeared in SSLeay 0.6.0. +.Fn BIO_new_fd +first appeared in SSLeay 0.8.0. +All these functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BIO_s_file.3 b/lib/libcrypto/man/BIO_s_file.3 index ba4b714e9e..1cb357226a 100644 --- a/lib/libcrypto/man/BIO_s_file.3 +++ b/lib/libcrypto/man/BIO_s_file.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_file.3,v 1.8 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BIO_s_file.3,v 1.10 2018/07/09 09:54:08 tb Exp $ .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: July 9 2018 $ .Dt BIO_S_FILE 3 .Os .Sh NAME @@ -64,7 +64,7 @@ .Nd FILE BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_file .Fa void .Fc @@ -286,18 +286,18 @@ BIO_free(out); .Xr BIO_read 3 , .Xr BIO_seek 3 .Sh HISTORY -.Fn BIO_s_file -and -.Fn BIO_set_fp -first appeared in SSLeay 0.6.0. -.Fn BIO_new_file , -.Fn BIO_new_fp , +.Fn BIO_s_file , +.Fn BIO_set_fp , .Fn BIO_get_fp , .Fn BIO_read_filename , .Fn BIO_write_filename , and .Fn BIO_append_filename -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.6.0. +.Fn BIO_new_file +and +.Fn BIO_new_fp +first appeared in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . .Pp diff --git a/lib/libcrypto/man/BIO_s_mem.3 b/lib/libcrypto/man/BIO_s_mem.3 index 857dc85519..c27d38c45e 100644 --- a/lib/libcrypto/man/BIO_s_mem.3 +++ b/lib/libcrypto/man/BIO_s_mem.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: BIO_s_mem.3,v 1.9 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: BIO_s_mem.3,v 1.13 2018/05/12 20:12:17 schwarze Exp $ .\" full merge up to: OpenSSL 8711efb4 Mon Apr 20 11:33:12 2009 +0000 -.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 +.\" selective merge up to: OpenSSL 36359cec Mar 7 14:37:23 2018 +0100 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 12 2018 $ .Dt BIO_S_MEM 3 .Os .Sh NAME @@ -62,7 +62,7 @@ .Nd memory BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_mem .Fa "void" .Fc @@ -89,7 +89,7 @@ .Fc .Ft BIO * .Fo BIO_new_mem_buf -.Fa "void *buf" +.Fa "const void *buf" .Fa "int len" .Fc .Sh DESCRIPTION @@ -151,7 +151,7 @@ should be set to a negative value, typically -1. .Pp .Fn BIO_get_mem_data sets -.Fa pp +.Pf * Fa pp to a pointer to the start of the memory BIO's data and returns the total amount of data available. It is implemented as a macro. @@ -174,7 +174,7 @@ is a macro. places the underlying .Vt BUF_MEM structure in -.Fa pp . +.Pf * Fa pp . It is a macro. .Pp .Fn BIO_new_mem_buf @@ -251,11 +251,13 @@ BIO_free(mem); .Sh SEE ALSO .Xr BIO_new 3 .Sh HISTORY -.Fn BIO_s_mem , -.Fn BIO_set_mem_buf , +.Fn BIO_s_mem +first appeared in SSLeay 0.6.0. +.Fn BIO_set_mem_buf and .Fn BIO_get_mem_ptr -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.5. +These functions have been available since .Ox 2.4 . .Pp .Fn BIO_set_mem_eof_return diff --git a/lib/libcrypto/man/BIO_s_null.3 b/lib/libcrypto/man/BIO_s_null.3 index dcdcd8c4ab..c991bd7357 100644 --- a/lib/libcrypto/man/BIO_s_null.3 +++ b/lib/libcrypto/man/BIO_s_null.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_null.3,v 1.6 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_s_null.3,v 1.8 2018/05/01 17:05:05 schwarze Exp $ .\" OpenSSL e117a890 Sep 14 12:14:41 2000 +0000 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_S_NULL 3 .Os .Sh NAME @@ -56,7 +56,7 @@ .Nd null data sink .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_null .Fa void .Fc @@ -84,5 +84,5 @@ returns the null sink BIO method. .Xr BIO_new 3 .Sh HISTORY .Fn BIO_s_null -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.6.0 and has been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BIO_s_socket.3 b/lib/libcrypto/man/BIO_s_socket.3 index 3adc280a5e..63ab1deb4b 100644 --- a/lib/libcrypto/man/BIO_s_socket.3 +++ b/lib/libcrypto/man/BIO_s_socket.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_socket.3,v 1.7 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_s_socket.3,v 1.9 2018/05/01 17:05:05 schwarze Exp $ .\" OpenSSL bbdc9c98 Oct 19 22:02:21 2000 +0000 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_S_SOCKET 3 .Os .Sh NAME @@ -57,7 +57,7 @@ .Nd socket BIO .Sh SYNOPSIS .In openssl/bio.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fo BIO_s_socket .Fa void .Fc @@ -109,7 +109,8 @@ if an error occurred. .Xr BIO_new 3 .Sh HISTORY .Fn BIO_s_socket -and +first appeared in SSLeay 0.6.0. .Fn BIO_new_socket -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.8.0. +Both functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BIO_set_callback.3 b/lib/libcrypto/man/BIO_set_callback.3 index ed21ae3ad9..34b7c07a9f 100644 --- a/lib/libcrypto/man/BIO_set_callback.3 +++ b/lib/libcrypto/man/BIO_set_callback.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_set_callback.3,v 1.7 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_set_callback.3,v 1.9 2018/03/29 20:42:17 schwarze Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 29 2018 $ .Dt BIO_SET_CALLBACK 3 .Os .Sh NAME @@ -211,9 +211,9 @@ is called before the operation and .Fn callback b BIO_CB_GETS|BIO_CB_RETURN out outl 0L ret after. .It Fn BIO_puts b in -.Fn callback b BIO_CB_WRITE in 0 0L 1L +.Fn callback b BIO_CB_PUTS in 0 0L 1L is called before the operation and -.Fn callback b BIO_CB_WRITE|BIO_CB_RETURN in 0 0L ret +.Fn callback b BIO_CB_PUTS|BIO_CB_RETURN in 0 0L ret after. .It Fn BIO_ctrl b oper larg parg .Fn callback b BIO_CB_CTRL parg oper larg 1L @@ -257,6 +257,13 @@ Its source is in the file .Sh SEE ALSO .Xr BIO_new 3 .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier -and have been available since +.Fn BIO_set_callback , +.Fn BIO_get_callback , +.Fn BIO_set_callback_arg , +and +.Fn BIO_debug_callback +first appeared in SSLeay 0.6.0. +.Fn BIO_get_callback_arg +first appeared in SSLeay 0.8.0. +All these functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BIO_should_retry.3 b/lib/libcrypto/man/BIO_should_retry.3 index f37bfe2c67..85e313ee15 100644 --- a/lib/libcrypto/man/BIO_should_retry.3 +++ b/lib/libcrypto/man/BIO_should_retry.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_should_retry.3,v 1.7 2018/03/20 19:33:16 schwarze Exp $ +.\" $OpenBSD: BIO_should_retry.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 60e24554 Apr 6 14:45:18 2010 +0000 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BIO_SHOULD_RETRY 3 .Os .Sh NAME @@ -215,8 +215,18 @@ and use a timeout on the .Xr BIO_new 3 , .Xr BIO_read 3 .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier -and have been available since +.Fn BIO_should_read , +.Fn BIO_should_write , +.Fn BIO_retry_type , +and +.Fn BIO_should_retry +first appeared in SSLeay 0.6.0. +.Fn BIO_should_io_special , +.Fn BIO_get_retry_BIO , +and +.Fn BIO_get_retry_reason +first appeared in SSLeay 0.8.0. +All these functions have been available since .Ox 2.4 . .Sh BUGS The OpenSSL ASN.1 functions cannot gracefully deal with non-blocking I/O: diff --git a/lib/libcrypto/man/BN_CTX_new.3 b/lib/libcrypto/man/BN_CTX_new.3 index 2d721329a2..1d5fb0a396 100644 --- a/lib/libcrypto/man/BN_CTX_new.3 +++ b/lib/libcrypto/man/BN_CTX_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_CTX_new.3,v 1.7 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BN_CTX_new.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL aafbe1cc Jun 12 23:42:08 2013 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_CTX_NEW 3 .Os .Sh NAME @@ -136,7 +136,7 @@ and sets an error code that can be obtained by .Fn BN_CTX_new and .Fn BN_CTX_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn BN_CTX_init diff --git a/lib/libcrypto/man/BN_add.3 b/lib/libcrypto/man/BN_add.3 index 3fb9c8ab78..8a11d7c080 100644 --- a/lib/libcrypto/man/BN_add.3 +++ b/lib/libcrypto/man/BN_add.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_add.3,v 1.11 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: BN_add.3,v 1.13 2018/04/29 15:58:21 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: April 29 2018 $ .Dt BN_ADD 3 .Os .Sh NAME @@ -66,6 +66,13 @@ .Nm BN_mod_sqr , .Nm BN_exp , .Nm BN_mod_exp , +.\" The following are public, but intentionally undocumented for now: +.\" .Nm BN_mod_exp_mont_consttime , +.\" .Nm BN_mod_exp_mont , +.\" .Nm BN_mod_exp_mont_word , +.\" .Nm BN_mod_exp_recp , +.\" .Nm BN_mod_exp_simple , +.\" Maybe they should be deleted from . .Nm BN_gcd .Nd arithmetic operations on BIGNUMs .Sh SYNOPSIS @@ -245,6 +252,13 @@ and places the result in and the remainder in .Fa rem .Pq Li dv=a/d , rem=a%d . +If the flag +.Dv BN_FLG_CONSTTIME +is set on +.Fa a +or +.Fa d , +it operates in constant time. Either of .Fa dv and @@ -343,6 +357,11 @@ to the power modulo .Fa m .Pq Li r=(a^p)%m . +If the flag +.Dv BN_FLG_CONSTTIME +is set on +.Fa p , +it operates in constant time. This function uses less time and space than .Fn BN_exp . .Pp @@ -397,7 +416,7 @@ The error codes can be obtained by .Fn BN_mod_exp , and .Fn BN_gcd -appeared before SSLeay 0.8. +first appeared in SSLeay 0.5.1. .Fn BN_exp first appeared in SSLeay 0.9.0. All these functions have been available since @@ -417,3 +436,31 @@ and .Fn BN_mod_sqr first appeared in OpenSSL 0.9.7 and have been available since .Ox 3.2 . +.Sh BUGS +Even if the +.Dv BN_FLG_CONSTTIME +flag is set on +.Fa a +or +.Fa b , +.Fn BN_gcd +neither fails nor operates in constant time, potentially allowing +timing side-channel attacks. +.Pp +Even if the +.Dv BN_FLG_CONSTTIME +flag is set on +.Fa p , +if the modulus +.Fa m +is even, +.Fn BN_mod_exp +does not operate in constant time, potentially allowing +timing side-channel attacks. +.Pp +If +.Dv BN_FLG_CONSTTIME +is set on +.Fa p , +.Fn BN_exp +fails instead of operating in constant time. diff --git a/lib/libcrypto/man/BN_add_word.3 b/lib/libcrypto/man/BN_add_word.3 index 9bbc8104b4..cc5c682a2c 100644 --- a/lib/libcrypto/man/BN_add_word.3 +++ b/lib/libcrypto/man/BN_add_word.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_add_word.3,v 1.7 2018/03/21 06:26:31 schwarze Exp $ +.\" $OpenBSD: BN_add_word.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_ADD_WORD 3 .Os .Sh NAME @@ -155,12 +155,11 @@ if an error occurred. .Xr BN_new 3 , .Xr ERR_get_error 3 .Sh HISTORY -.Fn BN_add_word +.Fn BN_add_word , +.Fn BN_div_word , and .Fn BN_mod_word -appeared before SSLeay 0.8. -.Fn BN_div_word -first appeared in SSLeay 0.8. +first appeared in SSLeay 0.5.1. .Fn BN_sub_word and .Fn BN_mul_word diff --git a/lib/libcrypto/man/BN_bn2bin.3 b/lib/libcrypto/man/BN_bn2bin.3 index a12a33e301..d9cf3915f6 100644 --- a/lib/libcrypto/man/BN_bn2bin.3 +++ b/lib/libcrypto/man/BN_bn2bin.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_bn2bin.3,v 1.10 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: BN_bn2bin.3,v 1.11 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_BN2BIN 3 .Os .Sh NAME @@ -301,10 +301,11 @@ The error codes can be obtained by .Sh HISTORY .Fn BN_bn2bin , .Fn BN_bin2bn , -.Fn BN_print , and +.Fn BN_print +first appeared in SSLeay 0.5.1. .Fn BN_print_fp -appeared before SSLeay 0.8. +first appeared in SSLeay 0.6.0. .Fn BN_bn2hex , .Fn BN_bn2dec , .Fn BN_hex2bn , diff --git a/lib/libcrypto/man/BN_cmp.3 b/lib/libcrypto/man/BN_cmp.3 index 6be8fd4854..9e2baa2427 100644 --- a/lib/libcrypto/man/BN_cmp.3 +++ b/lib/libcrypto/man/BN_cmp.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_cmp.3,v 1.5 2018/03/20 20:26:23 schwarze Exp $ +.\" $OpenBSD: BN_cmp.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_CMP 3 .Os .Sh NAME @@ -144,8 +144,8 @@ return 1 if the condition is true, 0 otherwise. .Fn BN_is_one , and .Fn BN_is_word -appeared before SSLeay 0.8. +first appeared in SSLeay 0.5.1. .Fn BN_is_odd -first appeared in SSLeay 0.8. +first appeared in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BN_copy.3 b/lib/libcrypto/man/BN_copy.3 index addbaca5a3..956b368dec 100644 --- a/lib/libcrypto/man/BN_copy.3 +++ b/lib/libcrypto/man/BN_copy.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_copy.3,v 1.8 2018/03/22 22:07:12 schwarze Exp $ +.\" $OpenBSD: BN_copy.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_COPY 3 .Os .Sh NAME @@ -156,9 +156,10 @@ The error codes can be obtained by .Fn BN_copy and .Fn BN_dup -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn BN_with_flags -first appeared in OpenSSL 0.9.7h and has been available since +first appeared in OpenSSL 0.9.7h and 0.9.8a +and has been available since .Ox 4.0 . diff --git a/lib/libcrypto/man/BN_generate_prime.3 b/lib/libcrypto/man/BN_generate_prime.3 index 9dc922cd8a..e9adea80a4 100644 --- a/lib/libcrypto/man/BN_generate_prime.3 +++ b/lib/libcrypto/man/BN_generate_prime.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_generate_prime.3,v 1.13 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: BN_generate_prime.3,v 1.14 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400 .\" .\" This file was written by Ulf Moeller @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_GENERATE_PRIME 3 .Os .Sh NAME @@ -379,7 +379,7 @@ The error codes can be obtained by .Fn BN_generate_prime and .Fn BN_is_prime -appeared before SSLeay 0.8 and had their +first appeared in SSLeay 0.5.1 and had their .Fa cb_arg argument added in SSLeay 0.9.0. These two functions have been available since diff --git a/lib/libcrypto/man/BN_mod_inverse.3 b/lib/libcrypto/man/BN_mod_inverse.3 index 6fb371cf24..aa509b1ab6 100644 --- a/lib/libcrypto/man/BN_mod_inverse.3 +++ b/lib/libcrypto/man/BN_mod_inverse.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_mod_inverse.3,v 1.8 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BN_mod_inverse.3,v 1.10 2018/04/29 15:58:21 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 29 2018 $ .Dt BN_MOD_INVERSE 3 .Os .Sh NAME @@ -80,6 +80,14 @@ a new .Vt BIGNUM is created. .Pp +If the flag +.Dv BN_FLG_CONSTTIME +is set on +.Fa a +or +.Fa n , +it operates in constant time. +.Pp .Fa ctx is a previously allocated .Vt BN_CTX @@ -106,7 +114,7 @@ The error codes can be obtained by .Xr BN_set_flags 3 .Sh HISTORY .Fn BN_mod_inverse -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . .Pp The diff --git a/lib/libcrypto/man/BN_mod_mul_montgomery.3 b/lib/libcrypto/man/BN_mod_mul_montgomery.3 index 4f898fef16..8feed711cd 100644 --- a/lib/libcrypto/man/BN_mod_mul_montgomery.3 +++ b/lib/libcrypto/man/BN_mod_mul_montgomery.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.10 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.11 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_MOD_MUL_MONTGOMERY 3 .Os .Sh NAME @@ -225,7 +225,7 @@ The error codes can be obtained by .Fn BN_from_montgomery , and .Fn BN_to_montgomery -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.1 and have been available since .Ox 2.4 . .Pp .Fn BN_MONT_CTX_init diff --git a/lib/libcrypto/man/BN_mod_mul_reciprocal.3 b/lib/libcrypto/man/BN_mod_mul_reciprocal.3 index ef030e4c6f..9ace357652 100644 --- a/lib/libcrypto/man/BN_mod_mul_reciprocal.3 +++ b/lib/libcrypto/man/BN_mod_mul_reciprocal.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_mod_mul_reciprocal.3,v 1.9 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BN_mod_mul_reciprocal.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_MOD_MUL_RECIPROCAL 3 .Os .Sh NAME @@ -191,7 +191,7 @@ The error codes can be obtained by .Xr BN_new 3 .Sh HISTORY .Fn BN_mod_mul_reciprocal -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . .Pp .Vt BN_RECP_CTX diff --git a/lib/libcrypto/man/BN_new.3 b/lib/libcrypto/man/BN_new.3 index 4dd131a573..ed2910e645 100644 --- a/lib/libcrypto/man/BN_new.3 +++ b/lib/libcrypto/man/BN_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_new.3,v 1.12 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BN_new.3,v 1.14 2018/04/29 15:58:21 schwarze Exp $ .\" full merge up to: OpenSSL man3/BN_new 2457c19d Mar 6 08:43:36 2004 +0000 .\" selective merge up to: man3/BN_new 681acb31 Sep 29 13:10:34 2017 +0200 .\" full merge up to: OpenSSL man7/bn 05ea606a May 20 20:52:46 2016 -0400 @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 29 2018 $ .Dt BN_NEW 3 .Os .Sh NAME @@ -102,7 +102,11 @@ or accessed directly. .Fn BN_new allocates and initializes a .Vt BIGNUM -structure, in particular setting the value to zero. +structure, in particular setting the value to zero and the flags to +.Dv BN_FLG_MALLOCED . +The security-relevant flag +.Dv BN_FLG_CONSTTIME +is not set by default. .Pp .Fn BN_init initializes an existing uninitialized @@ -166,7 +170,7 @@ and sets an error code that can be obtained by .Fn BN_free , and .Fn BN_clear_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn BN_init diff --git a/lib/libcrypto/man/BN_num_bytes.3 b/lib/libcrypto/man/BN_num_bytes.3 index a95f47f9d9..ae32a8d8fa 100644 --- a/lib/libcrypto/man/BN_num_bytes.3 +++ b/lib/libcrypto/man/BN_num_bytes.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_num_bytes.3,v 1.6 2018/03/20 20:26:23 schwarze Exp $ +.\" $OpenBSD: BN_num_bytes.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_NUM_BYTES 3 .Os .Sh NAME @@ -120,5 +120,11 @@ The size. .Xr DSA_size 3 , .Xr RSA_size 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +.Fn BN_num_bytes +and +.Fn BN_num_bits +first appeared in SSLeay 0.5.1. +.Fn BN_num_bits_word +first appeared in SSLeay 0.5.2. +These functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BN_rand.3 b/lib/libcrypto/man/BN_rand.3 index 5e8ac5966c..fbfad03250 100644 --- a/lib/libcrypto/man/BN_rand.3 +++ b/lib/libcrypto/man/BN_rand.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_rand.3,v 1.10 2018/03/22 17:38:08 schwarze Exp $ +.\" $OpenBSD: BN_rand.3,v 1.11 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file was written by Ulf Moeller . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_RAND 3 .Os .Sh NAME @@ -139,7 +139,7 @@ The error codes can be obtained by .Xr RAND_bytes 3 .Sh HISTORY .Fn BN_rand -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . .Pp .Fn BN_pseudo_rand diff --git a/lib/libcrypto/man/BN_set_bit.3 b/lib/libcrypto/man/BN_set_bit.3 index edaa41d245..93bfda6747 100644 --- a/lib/libcrypto/man/BN_set_bit.3 +++ b/lib/libcrypto/man/BN_set_bit.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_set_bit.3,v 1.6 2018/03/20 20:26:23 schwarze Exp $ +.\" $OpenBSD: BN_set_bit.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_SET_BIT 3 .Os .Sh NAME @@ -212,5 +212,5 @@ The error codes can be obtained by .Fn BN_rshift , and .Fn BN_rshift1 -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/BN_set_flags.3 b/lib/libcrypto/man/BN_set_flags.3 index a998037534..9b1647cd31 100644 --- a/lib/libcrypto/man/BN_set_flags.3 +++ b/lib/libcrypto/man/BN_set_flags.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_set_flags.3,v 1.2 2018/03/21 09:03:49 schwarze Exp $ +.\" $OpenBSD: BN_set_flags.3,v 1.3 2018/04/29 15:58:21 schwarze Exp $ .\" .\" Copyright (c) 2017 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 29 2018 $ .Dt BN_SET_FLAGS 3 .Os .Sh NAME @@ -47,6 +47,8 @@ together: .It Dv BN_FLG_CONSTTIME If this flag is set on the divident .Fa a +or the divisor +.Fa d in .Xr BN_div 3 , on the exponent @@ -59,27 +61,14 @@ or the modulus .Fa n in .Xr BN_mod_inverse 3 , -these functions prefer algorithms with an execution time independent +these functions select algorithms with an execution time independent of the respective numbers, to avoid exposing sensitive information -to timing attacks. +to timing side-channel attacks. .Pp -If this flag is set on the exponent -.Fa p -in -.Xr BN_exp 3 -or if the modulus -.Fa m -is even for -.Xr BN_mod_exp 3 , -an error occurs. -.Pp -Various functions automatically set this flag on sensitive data. -For example, the default implementations of -.Xr DH_generate_key 3 , -.Xr DSA_generate_key 3 , -and -.Xr RSA_generate_key_ex 3 -set it on the generated private key. +This flag is off by default for +.Vt BIGNUM +objects created with +.Xr BN_new 3 . .It Dv BN_FLG_MALLOCED If this flag is set, .Xr BN_free 3 @@ -148,3 +137,31 @@ first appeared in SSLeay 0.9.1 and have been available since No public interface exists to clear a flag once it is set. So think twice before using .Fn BN_set_flags . +.Sh BUGS +Even if the +.Dv BN_FLG_CONSTTIME +flag is set on +.Fa a +or +.Fa b , +.Fn BN_gcd +neither fails nor operates in constant time, potentially allowing +timing side-channel attacks. +.Pp +Even if the +.Dv BN_FLG_CONSTTIME +flag is set on +.Fa p , +if the modulus +.Fa m +is even, +.Xr BN_mod_exp 3 +does not operate in constant time, potentially allowing +timing side-channel attacks. +.Pp +If +.Dv BN_FLG_CONSTTIME +is set on +.Fa p , +.Fn BN_exp +fails instead of operating in constant time. diff --git a/lib/libcrypto/man/BN_zero.3 b/lib/libcrypto/man/BN_zero.3 index 388c35fbc6..f3ca4cdfb1 100644 --- a/lib/libcrypto/man/BN_zero.3 +++ b/lib/libcrypto/man/BN_zero.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_zero.3,v 1.8 2018/03/20 20:26:23 schwarze Exp $ +.\" $OpenBSD: BN_zero.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" selective merge up to: OpenSSL b713c4ff Jan 22 14:41:09 2018 -0500 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BN_ZERO 3 .Os .Sh NAME @@ -131,20 +131,14 @@ returns the constant. .Sh HISTORY .Fn BN_zero , .Fn BN_one , +.Fn BN_value_one , and .Fn BN_set_word -appeared before SSLeay 0.8. -.Fn BN_value_one -and +first appeared in SSLeay 0.5.1. .Fn BN_get_word -first appeared in SSLeay 0.8. +first appeared in SSLeay 0.6.0. All these functions have been available since .Ox 2.4 . -.Pp -.Fn BN_value_one -was changed to return a true -.Vt const BIGNUM * -in OpenSSL 0.9.7. .Sh BUGS Someone might change the constant. .Pp diff --git a/lib/libcrypto/man/BUF_MEM_new.3 b/lib/libcrypto/man/BUF_MEM_new.3 index d51e3d3c92..60e12c53b5 100644 --- a/lib/libcrypto/man/BUF_MEM_new.3 +++ b/lib/libcrypto/man/BUF_MEM_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BUF_MEM_new.3,v 1.14 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: BUF_MEM_new.3,v 1.15 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL doc/crypto/buffer.pod 18edda0f Sep 20 03:28:54 2000 +0000 .\" not merged: 74924dcb, 58e3457a, 21b0fa91, 7644a9ae .\" OpenSSL doc/crypto/BUF_MEM_new.pod 53934822 Jun 9 16:39:19 2016 -0400 @@ -52,7 +52,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt BUF_MEM_NEW 3 .Os .Sh NAME @@ -190,9 +190,9 @@ return zero on error or the new size (i.e.\& .Fn BUF_MEM_free , and .Fn BUF_MEM_grow -appeared before SSLeay 0.8. +first appeared in SSLeay 0.6.0. .Fn BUF_strdup -first appeared in SSLeay 0.8. +first appeared in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . .Pp diff --git a/lib/libcrypto/man/CRYPTO_get_mem_functions.3 b/lib/libcrypto/man/CRYPTO_get_mem_functions.3 index ba6bcc6404..f02ec8fbb0 100644 --- a/lib/libcrypto/man/CRYPTO_get_mem_functions.3 +++ b/lib/libcrypto/man/CRYPTO_get_mem_functions.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: CRYPTO_get_mem_functions.3,v 1.4 2018/03/20 21:27:32 schwarze Exp $ +.\" $OpenBSD: CRYPTO_get_mem_functions.3,v 1.6 2018/08/24 19:17:38 tb Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: August 24 2018 $ .Dt CRYPTO_GET_MEM_FUNCTIONS 3 .Os .Sh NAME @@ -43,15 +43,15 @@ .Fo CRYPTO_mem_ctrl .Fa "int mode" .Fc -.Ft void +.Ft int .Fo CRYPTO_mem_leaks .Fa "BIO *b" .Fc -.Ft void +.Ft int .Fo CRYPTO_mem_leaks_fp .Fa "FILE *fp" .Fc -.Ft typedef void * +.Ft typedef int * .Fo CRYPTO_MEM_LEAK_CB .Fa "unsigned long" .Fa "const char *" @@ -59,7 +59,7 @@ .Fa int .Fa "void *" .Fc -.Ft void +.Ft int .Fo CRYPTO_mem_leaks_cb .Fa "CRYPTO_MEM_LEAK_CB *cb" .Fc @@ -90,7 +90,23 @@ always returns 0. .Fn CRYPTO_mem_ctrl always returns .Dv CRYPTO_MEM_CHECK_OFF . +.Pp +.Fn CRYPTO_mem_leaks , +.Fn CRYPTO_mem_leaks_fp , +and +.Fn CRYPTO_mem_leaks_cb +always return -1. .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier -and have been available since +.Fn CRYPTO_mem_ctrl , +.Fn CRYPTO_mem_leaks , +and +.Fn CRYPTO_mem_leaks_fp +first appeared in SSLeay 0.6.4. +.Fn CRYPTO_get_mem_functions +and +.Fn CRYPTO_set_mem_functions +first appeared in SSLeay 0.6.5. +.Fn CRYPTO_mem_leaks_cb +first appeared in SSLeay 0.6.6. +All these functions have all been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/CRYPTO_set_ex_data.3 b/lib/libcrypto/man/CRYPTO_set_ex_data.3 index 9de936d20a..ca5080dfb9 100644 --- a/lib/libcrypto/man/CRYPTO_set_ex_data.3 +++ b/lib/libcrypto/man/CRYPTO_set_ex_data.3 @@ -1,53 +1,7 @@ -.\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.9 2018/03/22 16:06:33 schwarze Exp $ -.\" OpenSSL CRYPTO_get_ex_new_index.pod 35cb565a Nov 19 15:49:30 2015 -0500 -.\" -.\" This file was written by Dr. Stephen Henson . -.\" Copyright (c) 2000, 2006 The OpenSSL Project. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" 3. All advertising materials mentioning features or use of this -.\" software must display the following acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" -.\" -.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to -.\" endorse or promote products derived from this software without -.\" prior written permission. For written permission, please contact -.\" openssl-core@openssl.org. -.\" -.\" 5. Products derived from this software may not be called "OpenSSL" -.\" nor may "OpenSSL" appear in their names without prior written -.\" permission of the OpenSSL Project. -.\" -.\" 6. Redistributions of any form whatsoever must retain the following -.\" acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY -.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR -.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -.\" OF THE POSSIBILITY OF SUCH DAMAGE. -.\" OpenSSL +.\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.10 2018/04/08 01:00:15 schwarze Exp $ +.\" full merge up to: +.\" OpenSSL CRYPTO_get_ex_new_index 9e183d22 Mar 11 08:56:44 2017 -0500 +.\" selective merge up to: a73d990e Feb 27 19:02:24 2018 +0100 .\" .\" This file was written by Dr. Stephen Henson .\" and by Rich Salz . @@ -98,7 +52,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: April 8 2018 $ .Dt CRYPTO_SET_EX_DATA 3 .Os .Sh NAME @@ -177,18 +131,20 @@ Several OpenSSL structures can have application specific data attached to them, known as "exdata". The specific structures are: .Bd -literal + BIO + DH + DSA + ECDH + ECDSA + ENGINE + RSA SSL SSL_CTX SSL_SESSION + UI X509 X509_STORE X509_STORE_CTX - DH - DSA - RSA - ENGINE - UI - BIO .Ed .Pp Each is identified by a diff --git a/lib/libcrypto/man/CRYPTO_set_locking_callback.3 b/lib/libcrypto/man/CRYPTO_set_locking_callback.3 index 364648c5ec..c00fb75dc2 100644 --- a/lib/libcrypto/man/CRYPTO_set_locking_callback.3 +++ b/lib/libcrypto/man/CRYPTO_set_locking_callback.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: CRYPTO_set_locking_callback.3,v 1.9 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: CRYPTO_set_locking_callback.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL doc/crypto/threads.pod fb552ac6 Sep 30 23:43:01 2009 +0000 .\" .\" This file was written by Ulf Moeller , @@ -51,7 +51,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt CRYPTO_SET_LOCKING_CALLBACK 3 .Os .Sh NAME @@ -369,10 +369,12 @@ shows examples of the callback functions on Solaris, Irix and Win32. .Fn CRYPTO_w_lock , .Fn CRYPTO_w_unlock , .Fn CRYPTO_r_lock , -.Fn CRYPTO_r_unlock , and +.Fn CRYPTO_r_unlock +first appeared in SSLeay 0.6.0. .Fn CRYPTO_add -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.2. +These functions have been available since .Ox 2.4 . .Pp .Fn CRYPTO_num_locks diff --git a/lib/libcrypto/man/DES_set_key.3 b/lib/libcrypto/man/DES_set_key.3 index d0f0fd3f62..c95dc5de27 100644 --- a/lib/libcrypto/man/DES_set_key.3 +++ b/lib/libcrypto/man/DES_set_key.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DES_set_key.3,v 1.11 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: DES_set_key.3,v 1.12 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: .\" OpenSSL man3/DES_random_key 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -115,7 +115,7 @@ .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DES_SET_KEY 3 .Os .Sh NAME @@ -786,48 +786,49 @@ ANSI X3.106 The DES library was initially written to be source code compatible with the MIT Kerberos library. .Sh HISTORY -Versions of .Fn DES_random_key , .Fn DES_set_key , .Fn DES_key_sched , .Fn DES_set_odd_parity , .Fn DES_is_weak_key , .Fn DES_ecb_encrypt , -.Fn DES_ecb2_encrypt , -.Fn DES_ecb3_encrypt , -.Fn DES_ncbc_encrypt , .Fn DES_cfb_encrypt , .Fn DES_ofb_encrypt , .Fn DES_pcbc_encrypt , .Fn DES_cfb64_encrypt , .Fn DES_ofb64_encrypt , -.Fn DES_xcbc_encrypt , -.Fn DES_ede2_cbc_encrypt , -.Fn DES_ede2_cfb64_encrypt , -.Fn DES_ede2_ofb64_encrypt , .Fn DES_ede3_cbc_encrypt , -.Fn DES_ede3_cfb64_encrypt , -.Fn DES_ede3_ofb64_encrypt , .Fn DES_cbc_cksum , .Fn DES_quad_cksum , .Fn DES_string_to_key , .Fn DES_string_to_2keys , -.Fn DES_fcrypt , .Fn DES_crypt , .Fn DES_enc_read , and .Fn DES_enc_write -with lower case names starting with -.Sy des_ -appeared in SSLeay 0.8.1b or earlier and have been available since +appeared in SSLeay 0.4 or earlier. +.Fn DES_ncbc_encrypt +first appeared in SSLeay 0.4.2. +.Fn DES_ede2_cbc_encrypt +first appeared in SSLeay 0.4.4. +.Fn DES_ecb2_encrypt , +.Fn DES_ecb3_encrypt , +.Fn DES_ede2_cfb64_encrypt , +.Fn DES_ede2_ofb64_encrypt , +.Fn DES_ede3_cfb64_encrypt , +and +.Fn DES_ede3_ofb64_encrypt +first appeared in SSLeay 0.5.1. +.Fn DES_xcbc_encrypt +first appeared in SSLeay 0.6.2. +.Fn DES_fcrypt +first appeared in SSLeay 0.6.5. +These functions have been available since .Ox 2.4 . .Pp -Versions of .Fn DES_set_key_checked and .Fn DES_set_key_unchecked -with lower case names starting with -.Sy des_ first appeared in OpenSSL 0.9.5 and have been available since .Ox 2.7 . .Pp diff --git a/lib/libcrypto/man/DH_generate_key.3 b/lib/libcrypto/man/DH_generate_key.3 index 74d3ec7052..2c44cf986f 100644 --- a/lib/libcrypto/man/DH_generate_key.3 +++ b/lib/libcrypto/man/DH_generate_key.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DH_generate_key.3,v 1.8 2018/03/20 22:22:10 schwarze Exp $ +.\" $OpenBSD: DH_generate_key.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DH_GENERATE_KEY 3 .Os .Sh NAME @@ -119,5 +119,5 @@ The error codes can be obtained by .Fn DH_generate_key and .Fn DH_compute_key -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/DH_generate_parameters.3 b/lib/libcrypto/man/DH_generate_parameters.3 index 477f65d01c..190ff098e0 100644 --- a/lib/libcrypto/man/DH_generate_parameters.3 +++ b/lib/libcrypto/man/DH_generate_parameters.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DH_generate_parameters.3,v 1.10 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: DH_generate_parameters.3,v 1.11 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DH_GENERATE_PARAMETERS 3 .Os .Sh NAME @@ -154,7 +154,7 @@ The error codes can be obtained by .Fn DH_check and .Fn DH_generate_parameters -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp The diff --git a/lib/libcrypto/man/DH_new.3 b/lib/libcrypto/man/DH_new.3 index 19ee49c1a8..3208e76701 100644 --- a/lib/libcrypto/man/DH_new.3 +++ b/lib/libcrypto/man/DH_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DH_new.3,v 1.6 2018/03/20 22:22:10 schwarze Exp $ +.\" $OpenBSD: DH_new.3,v 1.8 2018/04/18 01:11:45 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,17 +48,22 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: April 18 2018 $ .Dt DH_NEW 3 .Os .Sh NAME .Nm DH_new , +.Nm DH_up_ref , .Nm DH_free .Nd allocate and free DH objects .Sh SYNOPSIS .In openssl/dh.h .Ft DH* .Fn DH_new void +.Ft int +.Fo DH_up_ref +.Fa "DH *dh" +.Fc .Ft void .Fo DH_free .Fa "DH *dh" @@ -69,10 +74,19 @@ The DH functions implement the Diffie-Hellman key agreement protocol. .Fn DH_new allocates and initializes a .Vt DH -structure. +structure, setting the reference count to 1. +It is equivalent to +.Xr DH_new_method 3 +with a +.Dv NULL +argument. +.Pp +.Fn DH_up_ref +increments the reference count by 1. .Pp .Fn DH_free -frees the +decrements the reference count by 1. +If it reaches 0, it frees the .Vt DH structure and its components. The values are erased before the memory is returned to the system. @@ -89,6 +103,9 @@ returns and sets an error code that can be obtained by .Xr ERR_get_error 3 . Otherwise it returns a pointer to the newly allocated structure. +.Pp +.Fn DH_up_ref +returns 1 for success or 0 for failure. .Sh SEE ALSO .Xr BN_new 3 , .Xr d2i_DHparams 3 , @@ -106,5 +123,9 @@ Otherwise it returns a pointer to the newly allocated structure. .Fn DH_new and .Fn DH_free -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . +.Pp +.Fn DH_up_ref +first appeared in OpenSSL 0.9.7 and has been available since +.Ox 3.2 . diff --git a/lib/libcrypto/man/DH_set_method.3 b/lib/libcrypto/man/DH_set_method.3 index 77d1616445..9863cbaca9 100644 --- a/lib/libcrypto/man/DH_set_method.3 +++ b/lib/libcrypto/man/DH_set_method.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DH_set_method.3,v 1.6 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: DH_set_method.3,v 1.7 2018/04/18 01:09:01 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: April 18 2018 $ .Dt DH_SET_METHOD 3 .Os .Sh NAME @@ -84,53 +84,44 @@ .Sh DESCRIPTION A .Vt DH_METHOD -specifies the functions that OpenSSL uses for Diffie-Hellman operations. -By modifying the method, alternative implementations such as hardware -accelerators may be used. -See the -.Sx CAVEATS -section for how these DH API functions are affected by the use of -.Xr engine 3 -API calls. -.Pp -Initially, the default -.Vt DH_METHOD -is the OpenSSL internal implementation as returned by -.Fn DH_OpenSSL . +object contains pointers to the functions +used for Diffie-Hellman operations. +By default, the internal implementation returned by +.Fn DH_OpenSSL +is used. +By selecting another method, alternative implementations +such as hardware accelerators may be used. .Pp .Fn DH_set_default_method -makes +selects .Fa meth -the default method for all +as the default method for all .Vt DH structures created later. -.Sy NB : -This is true only whilst no +If any .Vt ENGINE -has been set as a default for DH, so this function is no longer -recommended. +was registered with +.Xr ENGINE_register_DH 3 +that can be successfully initialized, it overrides the default. .Pp .Fn DH_get_default_method -returns a pointer to the current default -.Vt DH_METHOD . -However, the meaningfulness of this result is dependent on whether the -.Xr engine 3 -API is being used, so this function is no longer recommended. +returns a pointer to the current default method, +even if it is actually overridded by an +.Vt ENGINE . .Pp .Fn DH_set_method selects .Fa meth to perform all operations using the key .Fa dh . -This will replace the +This replaces the .Vt DH_METHOD used by the .Fa dh key and if the previous method was supplied by an .Vt ENGINE , -the handle to that -.Vt ENGINE -will be released during the change. +.Xr ENGINE_finish 3 +is called on it. It is possible to have .Vt DH keys that only work with certain @@ -147,18 +138,16 @@ allocates and initializes a .Vt DH structure so that .Fa engine -will be used for the DH operations. +is used for the DH operations. If .Fa engine is .Dv NULL , -the default -.Vt ENGINE -for DH operations is used and, if no default -.Vt ENGINE -is set, the -.Vt DH_METHOD -controlled by +.Xr ENGINE_get_default_DH 3 +is used. +If that returns +.Dv NULL , +the default method controlled by .Fn DH_set_default_method is used. .Pp @@ -199,17 +188,11 @@ typedef struct dh_meth_st and .Fn DH_get_default_method return pointers to the respective -.Sy DH_METHOD Ns s. +.Vt DH_METHOD . .Pp .Fn DH_set_method -returns non-zero if the provided -.Fa meth -was successfully set as the method for -.Fa dh -(including unloading the -.Vt ENGINE -handle if the previous method was supplied by an -.Vt ENGINE ) . +returns 1 on success or 0 on failure. +Currently, it cannot fail. .Pp .Fn DH_new_method returns @@ -219,7 +202,10 @@ and sets an error code that can be obtained by if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. .Sh SEE ALSO -.Xr DH_new 3 +.Xr DH_new 3 , +.Xr ENGINE_get_default_DH 3 , +.Xr ENGINE_register_DH 3 , +.Xr ENGINE_set_default_DH 3 .Sh HISTORY .Fn DH_set_default_method , .Fn DH_get_default_method , @@ -229,20 +215,3 @@ and .Fn DH_OpenSSL first appeared in OpenSSL 0.9.5 and have been available since .Ox 2.7 . -.Sh CAVEATS -As of version 0.9.7, -.Vt DH_METHOD -implementations are grouped together with other algorithmic APIs -(e.g. RSA_METHOD, EVP_CIPHER) in -.Vt ENGINE -modules. -If a default -.Vt ENGINE -is specified for DH functionality using an -.Xr engine 3 -API function, that will override any DH defaults set using the DH API -.Pq i.e. Fn DH_set_default_method . -For this reason, the -.Xr engine 3 -API is the recommended way to control default implementations -for use in DH and other cryptographic algorithms. diff --git a/lib/libcrypto/man/DH_size.3 b/lib/libcrypto/man/DH_size.3 index 24ca50f8a5..be1f50990b 100644 --- a/lib/libcrypto/man/DH_size.3 +++ b/lib/libcrypto/man/DH_size.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DH_size.3,v 1.8 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: DH_size.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DH_SIZE 3 .Os .Sh NAME @@ -88,7 +88,7 @@ must not be .Xr DH_new 3 .Sh HISTORY .Fn DH_size -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . .Pp .Fn DH_bits diff --git a/lib/libcrypto/man/DSA_generate_key.3 b/lib/libcrypto/man/DSA_generate_key.3 index b830385625..9e565e05a5 100644 --- a/lib/libcrypto/man/DSA_generate_key.3 +++ b/lib/libcrypto/man/DSA_generate_key.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DSA_generate_key.3,v 1.7 2018/03/20 22:37:32 schwarze Exp $ +.\" $OpenBSD: DSA_generate_key.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DSA_GENERATE_KEY 3 .Os .Sh NAME @@ -82,5 +82,5 @@ The error codes can be obtained by .Xr RAND_bytes 3 .Sh HISTORY .Fn DSA_generate_key -first appeared in SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.0 and has been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/DSA_generate_parameters.3 b/lib/libcrypto/man/DSA_generate_parameters.3 index 3d124462ca..d942f7b384 100644 --- a/lib/libcrypto/man/DSA_generate_parameters.3 +++ b/lib/libcrypto/man/DSA_generate_parameters.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DSA_generate_parameters.3,v 1.9 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: DSA_generate_parameters.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 9b86974e Aug 7 22:14:47 2015 -0400 .\" .\" This file was written by Ulf Moeller , @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DSA_GENERATE_PARAMETERS 3 .Os .Sh NAME @@ -204,7 +204,7 @@ The error codes can be obtained by .Xr RAND_bytes 3 .Sh HISTORY .Fn DSA_generate_parameters -first appeared in SSLeay 0.8 and had its +first appeared in SSLeay 0.8.0 and had its .Fa cb_arg argument added in SSLeay 0.9.0. It has been available since diff --git a/lib/libcrypto/man/DSA_new.3 b/lib/libcrypto/man/DSA_new.3 index c763be54b8..357b113b0a 100644 --- a/lib/libcrypto/man/DSA_new.3 +++ b/lib/libcrypto/man/DSA_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DSA_new.3,v 1.8 2018/03/20 22:37:32 schwarze Exp $ +.\" $OpenBSD: DSA_new.3,v 1.10 2018/04/18 01:11:45 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,17 +48,22 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: April 18 2018 $ .Dt DSA_NEW 3 .Os .Sh NAME .Nm DSA_new , +.Nm DSA_up_ref , .Nm DSA_free .Nd allocate and free DSA objects .Sh SYNOPSIS .In openssl/dsa.h .Ft DSA* .Fn DSA_new void +.Ft int +.Fo DSA_up_ref +.Fa "DSA *dsa" +.Fc .Ft void .Fo DSA_free .Fa "DSA *dsa" @@ -69,12 +74,19 @@ The DSA functions implement the Digital Signature Algorithm. .Fn DSA_new allocates and initializes a .Vt DSA -structure. +structure, setting the reference count to 1. It is equivalent to calling -.Fn DSA_new_method NULL . +.Xr DSA_new_method 3 +with a +.Dv NULL +argument. +.Pp +.Fn DSA_up_ref +increments the reference count by 1. .Pp .Fn DSA_free -frees the +decrements the reference count by 1. +If it reaches 0, it frees the .Vt DSA structure and its components. The values are erased before the memory is returned to the system. @@ -91,6 +103,9 @@ returns and sets an error code that can be obtained by .Xr ERR_get_error 3 . Otherwise it returns a pointer to the newly allocated structure. +.Pp +.Fn DSA_up_ref +returns 1 for success or 0 for failure. .Sh SEE ALSO .Xr BN_new 3 , .Xr d2i_DSAPublicKey 3 , @@ -107,7 +122,6 @@ Otherwise it returns a pointer to the newly allocated structure. .Xr DSA_SIG_new 3 , .Xr DSA_sign 3 , .Xr DSA_size 3 , -.Xr engine 3 , .Xr ERR_get_error 3 , .Xr EVP_PKEY_set1_DSA 3 , .Xr RSA_new 3 @@ -118,5 +132,9 @@ Standard, DSS), ANSI X9.30 .Fn DSA_new and .Fn DSA_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . +.Pp +.Fn DSA_up_ref +first appeared in OpenSSL 0.9.7 and has been available since +.Ox 3.2 . diff --git a/lib/libcrypto/man/DSA_set_method.3 b/lib/libcrypto/man/DSA_set_method.3 index f54c392097..8221f856be 100644 --- a/lib/libcrypto/man/DSA_set_method.3 +++ b/lib/libcrypto/man/DSA_set_method.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DSA_set_method.3,v 1.8 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: DSA_set_method.3,v 1.9 2018/04/18 01:09:01 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: April 18 2018 $ .Dt DSA_SET_METHOD 3 .Os .Sh NAME @@ -60,7 +60,6 @@ .Nd select DSA method .Sh SYNOPSIS .In openssl/dsa.h -.In openssl/engine.h .Ft void .Fo DSA_set_default_method .Fa "const DSA_METHOD *meth" @@ -81,51 +80,41 @@ .Sh DESCRIPTION A .Vt DSA_METHOD -specifies the functions that OpenSSL uses for DSA operations. -By modifying the method, alternative implementations such as hardware -accelerators may be used. -See the -.Sx CAVEATS -section for how these DSA API functions are affected by the use of -.Xr engine 3 -API calls. -.Pp -Initially, the default -.Vt DSA_METHOD -is the OpenSSL internal implementation, as returned by -.Fn DSA_OpenSSL . +object contains pointers to the functions used for DSA operations. +By default, the internal implementation returned by +.Fn DSA_OpenSSL +is used. +By selecting another method, alternative implementations +such as hardware accelerators may be used. .Pp .Fn DSA_set_default_method -makes +selects .Fa meth -the default method for all +as the default method for all .Vt DSA structures created later. -.Sy Note : -this is true only whilst no +If any .Vt ENGINE -has been set as a default for DSA, so this function is no longer -recommended. +was registered with +.Xr ENGINE_register_DSA 3 +that can be successfully initialized, it overrides the default. .Pp .Fn DSA_get_default_method -returns a pointer to the current default -.Vt DSA_METHOD . -However, the meaningfulness of this result is dependent on whether the -.Xr engine 3 -API is being used, so this function is no longer recommended. +returns a pointer to the current default method, +even if it is actually overridded by an +.Vt ENGINE . .Pp .Fn DSA_set_method selects .Fa meth to perform all operations using the key .Fa dsa . -This will replace the +This replaces the .Vt DSA_METHOD used by the DSA key and if the previous method was supplied by an .Vt ENGINE , -the handle to that -.Vt ENGINE -will be released during the change. +.Xr ENGINE_finish 3 +is called on it. It is possible to have DSA keys that only work with certain .Vt DSA_METHOD implementations (e.g. from an @@ -140,17 +129,16 @@ allocates and initializes a .Vt DSA structure so that .Fa engine -will be used for the DSA operations. +is used for the DSA operations. If .Fa engine is .Dv NULL , -the default engine for DSA operations is used and, if no -default -.Vt ENGINE -is set, the -.Vt DSA_METHOD -controlled by +.Xr ENGINE_get_default_DSA 3 +is used. +If that returns +.Dv NULL , +the default method controlled by .Fn DSA_set_default_method is used. .Pp @@ -203,17 +191,11 @@ struct and .Fn DSA_get_default_method return pointers to the respective -.Vt DSA_METHOD Ns s . +.Vt DSA_METHOD . .Pp .Fn DSA_set_method -returns non-zero if the provided -.Fa meth -was successfully set as the method for -.Fa dsa -(including unloading the -.Vt ENGINE -handle if the previous method was supplied by an -.Vt ENGINE ) . +returns 1 on success or 0 on failure. +Currently, it cannot fail. .Pp .Fn DSA_new_method returns @@ -224,7 +206,10 @@ if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. .Sh SEE ALSO .Xr DSA_meth_new 3 , -.Xr DSA_new 3 +.Xr DSA_new 3 , +.Xr ENGINE_get_default_DSA 3 , +.Xr ENGINE_register_DSA 3 , +.Xr ENGINE_set_default_DSA 3 .Sh HISTORY .Fn DSA_set_default_method , .Fn DSA_get_default_method , @@ -234,18 +219,3 @@ and .Fn DSA_OpenSSL first appeared in OpenSSL 0.9.5 and have been available since .Ox 2.7 . -.Sh CAVEATS -As of version 0.9.7, DSA_METHOD implementations are grouped together -with other algorithmic APIs (e.g. RSA_METHOD, EVP_CIPHER) in -.Vt ENGINE -modules. -If a default -.Vt ENGINE -is specified for DSA functionality using an -.Xr engine 3 -API function, that will override any DSA defaults set using the DSA API -.Pq i.e. DSA_set_default_method . -For this reason, the -.Xr engine 3 -API is the recommended way to control default implementations for -use in DSA and other cryptographic algorithms. diff --git a/lib/libcrypto/man/DSA_sign.3 b/lib/libcrypto/man/DSA_sign.3 index 2a7e1fb490..460fb595cd 100644 --- a/lib/libcrypto/man/DSA_sign.3 +++ b/lib/libcrypto/man/DSA_sign.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DSA_sign.3,v 1.7 2018/03/20 22:37:32 schwarze Exp $ +.\" $OpenBSD: DSA_sign.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DSA_SIGN 3 .Os .Sh NAME @@ -168,8 +168,8 @@ Standard, DSS), ANSI X9.30 .Fn DSA_sign and .Fn DSA_verify -appeared before SSLeay 0.8. +first appeared in SSLeay 0.6.0. .Fn DSA_sign_setup -first appeared in SSLeay 0.8. +first appeared in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/DSA_size.3 b/lib/libcrypto/man/DSA_size.3 index 74f7d979b6..7e935e3a42 100644 --- a/lib/libcrypto/man/DSA_size.3 +++ b/lib/libcrypto/man/DSA_size.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DSA_size.3,v 1.6 2018/03/20 22:37:32 schwarze Exp $ +.\" $OpenBSD: DSA_size.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DSA_SIZE 3 .Os .Sh NAME @@ -77,5 +77,5 @@ The size in bytes. .Xr DSA_sign 3 .Sh HISTORY .Fn DSA_size -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.0 and has been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/EC_POINT_add.3 b/lib/libcrypto/man/EC_POINT_add.3 index c58f4016a9..7c3ecbb1ad 100644 --- a/lib/libcrypto/man/EC_POINT_add.3 +++ b/lib/libcrypto/man/EC_POINT_add.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EC_POINT_add.3,v 1.8 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: EC_POINT_add.3,v 1.11 2018/07/16 17:37:25 tb Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Matt Caswell . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: July 16 2018 $ .Dt EC_POINT_ADD 3 .Os .Sh NAME @@ -217,12 +217,30 @@ The value .Fa n may be .Dv NULL , -in which case the result is just q * m. +in which case the result is just .Pp +.Dl q * m. +.Pp +.Fn EC_POINTs_mul +only supports the values 0 and 1 for +.Fa num . +If it is 1, then .Fn EC_POINTs_mul calculates the value .Pp -.Dl generator * n + q[0] * m[0] + ... + q[num-1] * m[num-1] +.Dl generator * n + q[0] * m[0]. +.Pp +If +.Fa num +is 0 then +.Fa q +and +.Fa m +must be +.Dv NULL , +and the result is just +.Pp +.Dl generator * n . .Pp As for .Fn EC_POINT_mul , diff --git a/lib/libcrypto/man/EC_POINT_new.3 b/lib/libcrypto/man/EC_POINT_new.3 index 77023403b9..aee642f52c 100644 --- a/lib/libcrypto/man/EC_POINT_new.3 +++ b/lib/libcrypto/man/EC_POINT_new.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: EC_POINT_new.3,v 1.8 2018/03/23 00:09:11 schwarze Exp $ -.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" $OpenBSD: EC_POINT_new.3,v 1.9 2018/03/29 20:56:49 schwarze Exp $ +.\" full merge up to: OpenSSL ddc1caac Mar 6 14:00:24 2018 -0500 .\" .\" This file was written by Matt Caswell . .\" Copyright (c) 2013, 2016 The OpenSSL Project. All rights reserved. @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 29 2018 $ .Dt EC_POINT_NEW 3 .Os .Sh NAME @@ -302,6 +302,18 @@ coordinates for the point .Fa p defined over the curve given in .Fa group . +The functions +.Fn EC_POINT_get_affine_coordinates_GFp +and +.Fn EC_POINT_get_affine_coordinates_GF2m +set +.Fa x +and +.Fa y , +either of which may be +.Dv NULL , +to the corresponding coordinates of +.Fa p . .Pp As well as the affine coordinates, a point can alternatively be described in terms of its Jacobian projective coordinates (for Fp diff --git a/lib/libcrypto/man/ENGINE_add.3 b/lib/libcrypto/man/ENGINE_add.3 new file mode 100644 index 0000000000..4ae878b4f5 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_add.3 @@ -0,0 +1,243 @@ +.\" $OpenBSD: ENGINE_add.3,v 1.3 2018/04/18 03:39:22 schwarze Exp $ +.\" content checked up to: OpenSSL 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_ADD 3 +.Os +.Sh NAME +.Nm ENGINE_add , +.Nm ENGINE_set_id , +.Nm ENGINE_get_id , +.Nm ENGINE_set_name , +.Nm ENGINE_get_name , +.Nm ENGINE_remove , +.Nm ENGINE_cleanup , +.Nm ENGINE_get_first , +.Nm ENGINE_get_last , +.Nm ENGINE_get_next , +.Nm ENGINE_get_prev , +.Nm ENGINE_by_id +.Nd maintain a global list of ENGINE objects +.Sh SYNOPSIS +.In openssl/engine.h +.Ft int +.Fo ENGINE_add +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_id +.Fa "ENGINE *e" +.Fa "const char *id" +.Fc +.Ft const char * +.Fo ENGINE_get_id +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_name +.Fa "ENGINE *e" +.Fa "const char *name" +.Fc +.Ft const char * +.Fo ENGINE_get_name +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_remove +.Fa "ENGINE *e" +.Fc +.Ft void +.Fn ENGINE_cleanup void +.Ft ENGINE * +.Fn ENGINE_get_first void +.Ft ENGINE * +.Fn ENGINE_get_last void +.Ft ENGINE * +.Fo ENGINE_get_next +.Fa "ENGINE *e" +.Fc +.Ft ENGINE * +.Fo ENGINE_get_prev +.Fa "ENGINE *e" +.Fc +.Ft ENGINE * +.Fo ENGINE_by_id +.Fa "const char *id" +.Fc +.Sh DESCRIPTION +The crypto library maintains a global list of +.Vt ENGINE +objects. +.Pp +.Fn ENGINE_add +appends +.Fa e +to the end of the list +and increments its structural reference count by 1. +A unique identifier and a name of +.Fa e +have to be set with +.Fn ENGINE_set_id +and +.Fn ENGINE_set_name +before calling this function. +.Fn ENGINE_add +fails if the list already contains an +.Vt ENGINE +with the same identifier. +.Pp +.Fn ENGINE_remove +removes +.Fa e +from the list. +If successful, it calls +.Xr ENGINE_free 3 +on +.Fa e . +.Pp +.Fn ENGINE_cleanup +calls +.Xr ENGINE_finish 3 +on all +.Vt ENGINE +objects that were selected as default engines, for example using the +functions documented in the +.Xr ENGINE_set_default 3 +and +.Xr ENGINE_get_default_RSA 3 +manual pages, and it calls +.Fn ENGINE_remove +on all +.Vt ENGINE +objects that were added to the global list with +.Fn ENGINE_add . +Calling this function is required at the end of each program using +.Fn ENGINE_add , +even if no engines are explicitly registered or used. +.Pp +.Fn ENGINE_get_first +and +.Fn ENGINE_get_last +provide access to the first and last +.Vt ENGINE +object on the list, respectively. +Unless the list is empty, they increment the structural reference +count of the retrieved object by 1. +.Pp +.Fn ENGINE_get_next +and +.Fn ENGINE_get_prev +support iteration of the list. +They always call +.Xr ENGINE_free 3 +on +.Fa e . +Unless the end of the list is reached, they increment the structural +reference count of the retrieved object by 1. +.Pp +.Fn ENGINE_by_id +searches the list for an +.Vt ENGINE +object with a matching +.Fa id . +If found, it increments the structural reference count of the +retrieved object by 1. +If +.Dv ENGINE_FLAGS_BY_ID_COPY +was set on +.Fa e +with +.Xr ENGINE_set_flags 3 , +it returns a shallow copy of the object rather than incrementing +the reference count and returning a pointer to the original. +.Sh RETURN VALUES +.Fn ENGINE_add , +.Fn ENGINE_set_id , +.Fn ENGINE_set_name , +and +.Fn ENGINE_remove +return 1 on success or 0 on error. +.Fn ENGINE_set_id +and +.Fn ENGINE_set_name +can only fail if the supplied +.Fa id +or +.Fa name +is +.Dv NULL . +.Pp +.Fn ENGINE_get_id +and +.Fn ENGINE_get_name +return a pointer to an internal string +representing the identifier and the name of +.Fa e , +respectively. +.Pp +.Fn ENGINE_get_first +and +.Fn ENGINE_get_last +return an +.Vt ENGINE +object or +.Dv NULL +if the list is empty. +.Pp +.Fn ENGINE_get_next +and +.Fn ENGINE_get_prev +return an +.Vt ENGINE +object or +.Dv NULL +when the end of the list is reached. +.Pp +.Fn ENGINE_by_id +returns an +.Vt ENGINE +object or +.Dv NULL +if no matching object is found. +.Sh SEE ALSO +.Xr ENGINE_get_default_RSA 3 , +.Xr ENGINE_init 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_all_RSA 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_default 3 , +.Xr ENGINE_set_flags 3 , +.Xr ENGINE_unregister_RSA 3 +.Sh HISTORY +.Fn ENGINE_add , +.Fn ENGINE_set_id , +.Fn ENGINE_get_id , +.Fn ENGINE_set_name , +.Fn ENGINE_get_name , +.Fn ENGINE_remove , +.Fn ENGINE_get_first , +.Fn ENGINE_get_last , +.Fn ENGINE_get_next , +.Fn ENGINE_get_prev , +and +.Fn ENGINE_by_id +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 2.9 . +.Pp +.Fn ENGINE_cleanup +first appeared in OpenSSL 0.9.7 and has been available since +.Ox 3.2 . diff --git a/lib/libcrypto/man/ENGINE_ctrl.3 b/lib/libcrypto/man/ENGINE_ctrl.3 new file mode 100644 index 0000000000..c02e9b5a94 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_ctrl.3 @@ -0,0 +1,470 @@ +.\" $OpenBSD: ENGINE_ctrl.3,v 1.4 2018/04/19 18:43:58 schwarze Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 19 2018 $ +.Dt ENGINE_CTRL 3 +.Os +.Sh NAME +.Nm ENGINE_ctrl , +.Nm ENGINE_cmd_is_executable , +.Nm ENGINE_ctrl_cmd , +.Nm ENGINE_ctrl_cmd_string , +.Nm ENGINE_set_ctrl_function , +.Nm ENGINE_get_ctrl_function , +.Nm ENGINE_set_cmd_defns , +.Nm ENGINE_get_cmd_defns +.Nd control commands for ENGINE objects +.Sh SYNOPSIS +.In openssl/engine.h +.Ft int +.Fo ENGINE_ctrl +.Fa "ENGINE *e" +.Fa "int cmd" +.Fa "long i" +.Fa "void *p" +.Fa "void (*f)(void)" +.Fc +.Ft int +.Fo ENGINE_cmd_is_executable +.Fa "ENGINE *e" +.Fa "int cmd" +.Fc +.Ft int +.Fo ENGINE_ctrl_cmd +.Fa "ENGINE *e" +.Fa "const char *cmd_name" +.Fa "long i" +.Fa "void *p" +.Fa "void (*f)(void)" +.Fa "int cmd_optional" +.Fc +.Ft int +.Fo ENGINE_ctrl_cmd_string +.Fa "ENGINE *e" +.Fa "const char *cmd_name" +.Fa "const char *arg" +.Fa "int cmd_optional" +.Fc +.Ft typedef int +.Fo (*ENGINE_CTRL_FUNC_PTR) +.Fa "ENGINE *e" +.Fa "int cmd" +.Fa "long i" +.Fa "void *p" +.Fa "void (*f)(void)" +.Fc +.Ft int +.Fo ENGINE_set_ctrl_function +.Fa "ENGINE *e" +.Fa "ENGINE_CTRL_FUNC_PTR ctrl_f" +.Fc +.Ft ENGINE_CTRL_FUNC_PTR +.Fo ENGINE_get_ctrl_function +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_cmd_defns +.Fa "ENGINE *e" +.Fa "const ENGINE_CMD_DEFN *defns" +.Fc +.Ft const ENGINE_CMD_DEFN * +.Fo ENGINE_get_cmd_defns +.Fa "const ENGINE *e" +.Fc +.Sh DESCRIPTION +.Fn ENGINE_ctrl +calls the built-in or user-defined +.Fa cmd +for the engine +.Fa e , +passing the arguments +.Fa i +and +.Fa p . +.Pp +User-defined commands can be used before +.Xr ENGINE_init 3 +to provide data required for initialization +or at any time to modify the behaviour of an engine. +.Pp +Most built-in commands operate on user-defined commands installed with +.Fn ENGINE_set_cmd_defns , +either using the +.Fa p +argument to indicate the user-defined command with the command name +.Fa cmd_name +or using the +.Fa i +argument to indicate the user-defined command with the command number +.Fa cmd_num . +The +.Fa cmd +arguments to call the built-in commands are as follows: +.Bl -tag -width Ds +.It Dv ENGINE_CTRL_GET_CMD_FLAGS +Return the +.Fa cmd_flags +of the user-defined command with the number +.Fa i , +or a number less than or equal to 0 if an error occurs or +the command number does not exist. +A return value of 0 indicates failure if +.Fa e +is +.Dv NULL +or has a reference count of 0, or success if +.Fa e +is valid. +.It Dv ENGINE_CTRL_GET_CMD_FROM_NAME +Return the positive command number +of the user-defined command with the name +.Fa p , +or a number less than or equal to 0 if an error occurs or no +matching name is found. +.It Dv ENGINE_CTRL_GET_DESC_FROM_CMD +Copy the description of the user-defined command with the number +.Fa i +into the buffer +.Fa p +and NUL-terminate it. +It is the reponsability of the caller to make sure that the buffer +.Fa p +is large enough, either by calling +.Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD +first or using knowledge about the array passed to +.Fn ENGINE_set_cmd_defns . +The return value is the number of bytes written +.Em including +the terminating NUL byte, or a number less than or equal to 0 +if an error occurs. +.It Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD +Return the length in bytes +.Em excluding +the terminating NUL byte +of the description of the user-defined command with the number +.Fa i , +or a number less than or equal to 0 if an error occurs. +A return value of 0 indicates failure if +.Fa e +is +.Dv NULL +or has a reference count of 0, or success if +.Fa e +is valid. +.It Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE +Return the positive command number +of the first user-defined command installed with +.Fn ENGINE_set_cmd_defns +or a number less than or equal to 0 if an error occurs or no +user-defined command has been installed. +.It Dv ENGINE_CTRL_GET_NAME_FROM_CMD +Copy the name of the user-defined command with the number +.Fa i +into the buffer +.Fa p +and NUL-terminate it. +It is the reponsability of the caller to make sure that the buffer +.Fa p +is large enough, either by calling +.Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD +first or using knowledge about the array passed to +.Fn ENGINE_set_cmd_defns . +The return value is the number of bytes written +.Em including +the terminating NUL byte, or a number less than or equal to 0 +if an error occurs. +.It Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD +Return the length in bytes +.Em excluding +the terminating NULL byte +of the name of the user-defined command with the number +.Fa i , +or a number less than or equal to 0 if an error occurs. +A return value of 0 indicates failure if +.Fa e +is +.Dv NULL +or has a reference count of 0, or success if +.Fa e +is valid. +.It Dv ENGINE_CTRL_GET_NEXT_CMD_TYPE +Return the positive command number of the next user-defined command +after the user-defined command with the number +.Fa i , +or a number less than or equal to 0 if an error occurs or if +.Fa i +is the last user-defined command. +Together with +.Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE , +this can be used to iterate the user-defined commands installed with +.Fn ENGINE_set_cmd_defns . +.It Dv ENGINE_CTRL_HAS_CTRL_FUNCTION +Return 1 if +.Fa e +has its own +.Fa ctrl_f +installed with +.Fn ENGINE_set_ctrl_function +or 0 otherwise. +.El +.Pp +.Fn ENGINE_ctrl_cmd +translates the +.Fa cmd_name +of a user-defined command to a +.Fa cmd +number and calls +.Fn ENGINE_ctrl +on it. +If +.Fa cmd_optional +is non-zero, lack of a +.Fa ctrl_f +in +.Fa e +and translation failure with +.Dv ENGINE_CTRL_GET_CMD_FROM_NAME +are considered success, and the command has no effect. +Otherwise, these problems cause +.Fn ENGINE_ctrl_cmd +to fail. +.Pp +Neither +.Fn ENGINE_ctrl +nor +.Fn ENGINE_ctrl_cmd +ever call the +.Fa f +callback, but merely pass it on as an argument to the engine-specific +.Fa ctrl_f +control function. +It is up to +.Fa ctrl_f +how to use it, or alternatively to ignore it as well. +.Pp +.Fn ENGINE_ctrl_cmd_string +translates the +.Fa cmd_name +of a user-defined command to a +.Fa cmd +number. +If that command has the +.Dv ENGINE_CMD_FLAG_NO_INPUT +flag set, +.Fa arg +must be +.Dv NULL +and +.Fn ENGINE_ctrl +is called with +.Fa i +set to 0 and +.Fa p +set to +.Dv NULL . +Otherwise, +.Fa arg +must not be +.Dv NULL . +If the command accepts string input, +.Fa i +is set to 0 and +.Fa arg +is passed as the +.Fa p +argument to +.Fn ENGINE_ctrl . +Otherwise, +.Fa arg +is converted with +.Xr strtol 3 +and passed as the +.Fa i +argument to +.Fn ENGINE_ctrl , +setting +.Fa p +to +.Dv NULL . +.Pp +.Fn ENGINE_set_ctrl_function +installs +.Fa ctrl_f +as the engine-specific control function for +.Fa e . +Future calls to +.Fn ENGINE_ctrl +will call that function, passing on their arguments unchanged, if the +.Fa cmd +is not built-in to the library or if the +.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL +flag is set in +.Fa e . +Let the +.Fa ctrl_f +return positive values on success or negative values on failure. +Avoid return values of 0 because they cause dangerous ambiguity. +In particular, +.Fn ENGINE_ctrl_cmd +and +.Fn ENGINE_ctrl_cmd_string +cannot be used with user-defined commands +that may return 0 on success. +.Pp +.Fn ENGINE_set_cmd_defns +install an array of command definitions in +.Fa e . +.Pp +The structure +.Vt ENGINE_CMD_DEFN +has the following fields: +.Bl -tag -width Ds +.It Fa "unsigned int cmd_num" +A positive, unique, monotonically increasing command number. +Avoid using numbers below +.Dv ENGINE_CMD_BASE . +.It Fa "const char *cmd_name" +The unique name of the command. +.It Fa "const char *cmd_desc" +A short description of the command. +.It Fa "unsigned int cmd_flags" +The bitwise OR of zero or more of the following flags: +.Bl -tag -width Ds +.It Dv ENGINE_CMD_FLAG_NUMERIC +The command uses +.Fa i . +.It Dv ENGINE_CMD_FLAG_STRING +The command uses +.Fa p . +.It Dv ENGINE_CMD_FLAG_NO_INPUT +The command neither uses +.Fa i +nor +.Fa p . +.It Dv ENGINE_CMD_FLAG_INTERNAL +This flag has no effect and is only provided for compatibility. +.El +.El +.Pp +The last element of +.Fa defns +does not specify a command, but must have a +.Fa cmd_num +of 0 and a +.Fa cmd_name +of +.Dv NULL +to indicate the end of the array. +.Sh RETURN VALUES +For +.Fn ENGINE_ctrl , +positive return values indicate success and negative return values +indicate failure. +The meaning of a zero return value depends on the particular +.Fa cmd +and may indicate both success and failure, which is pathetic. +.Pp +Regardless of the +.Fa cmd , +.Fn ENGINE_ctrl +returns 0 if +.Fa e +is +.Dv NULL +or has a reference count of 0. +This is quite unfortunate for commands like +.Dv ENGINE_CTRL_GET_CMD_FLAGS +where 0 may indicate success, so make sure +.Fa e +is valid before issuing a control command. +.Pp +For built-in commands except +.Dv ENGINE_CTRL_HAS_CTRL_FUNCTION , +.Fn ENGINE_ctrl +returns \-1 if +.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL +is set but no +.Fa ctrl_f +has been installed with +.Fn ENGINE_set_ctrl_function . +.Pp +For commands that are not built in, +.Fn ENGINE_ctrl +returns 0 if no +.Fa ctrl_f +has been installed with +.Fn ENGINE_set_ctrl_function . +.Pp +.Fn ENGINE_cmd_is_executable +returns 1 if the user-defined +.Fa cmd +is executable and has at least one of the flags +.Dv ENGINE_CMD_FLAG_NUMERIC , +.Dv ENGINE_CMD_FLAG_STRING , +and +.Dv ENGINE_CMD_FLAG_NO_INPUT +set, or 0 otherwise. +.Pp +.Fn ENGINE_ctrl_cmd +and +.Fn ENGINE_ctrl_cmd_string +return 1 on success or 0 on error. +.Pp +.Fn ENGINE_set_ctrl_function +and +.Fn ENGINE_set_cmd_defns +always return 1. +.Pp +.Fn ENGINE_get_ctrl_function +returns a pointer to the function +.Fa ctrl_f +installed with +.Fn ENGINE_set_ctrl_function , +or +.Dv NULL +if none has been installed. +.Pp +.Fn ENGINE_get_cmd_defns +returns the array of command definitions installed in +.Fa e +or +.Dv NULL +if none is installed. +.Sh SEE ALSO +.Xr ENGINE_add 3 , +.Xr ENGINE_init 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_flags 3 , +.Xr ENGINE_set_RSA 3 +.Sh HISTORY +.Fn ENGINE_ctrl , +.Fn ENGINE_set_ctrl_function , +and +.Fn ENGINE_get_ctrl_function +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 2.9 . +.Pp +.Fn ENGINE_cmd_is_executable , +.Fn ENGINE_ctrl_cmd , +.Fn ENGINE_ctrl_cmd_string , +.Fn ENGINE_set_cmd_defns , +and +.Fn ENGINE_get_cmd_defns +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . diff --git a/lib/libcrypto/man/ENGINE_get_default_RSA.3 b/lib/libcrypto/man/ENGINE_get_default_RSA.3 new file mode 100644 index 0000000000..b04d42c18f --- /dev/null +++ b/lib/libcrypto/man/ENGINE_get_default_RSA.3 @@ -0,0 +1,160 @@ +.\" $OpenBSD: ENGINE_get_default_RSA.3,v 1.2 2018/04/18 03:39:22 schwarze Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_GET_DEFAULT_RSA 3 +.Os +.Sh NAME +.Nm ENGINE_get_default_RSA , +.Nm ENGINE_get_default_DSA , +.Nm ENGINE_get_default_ECDH , +.Nm ENGINE_get_default_ECDSA , +.Nm ENGINE_get_default_DH , +.Nm ENGINE_get_default_RAND , +.Nm ENGINE_get_cipher_engine , +.Nm ENGINE_get_digest_engine , +.Nm ENGINE_set_table_flags , +.Nm ENGINE_get_table_flags +.Nd retrieve the default ENGINE for an algorithm +.Sh SYNOPSIS +.In openssl/engine.h +.Ft ENGINE * +.Fn ENGINE_get_default_RSA void +.Ft ENGINE * +.Fn ENGINE_get_default_DSA void +.Ft ENGINE * +.Fn ENGINE_get_default_ECDH void +.Ft ENGINE * +.Fn ENGINE_get_default_ECDSA void +.Ft ENGINE * +.Fn ENGINE_get_default_DH void +.Ft ENGINE * +.Fn ENGINE_get_default_RAND void +.Ft ENGINE * +.Fo ENGINE_get_cipher_engine +.Fa "int nid" +.Fc +.Ft ENGINE * +.Fo ENGINE_get_digest_engine +.Fa "int nid" +.Fc +.Ft void +.Fo ENGINE_set_table_flags +.Fa "unsigned int flags" +.Fc +.Ft unsigned int +.Fn ENGINE_get_table_flags void +.Sh DESCRIPTION +These functions retrieve the current default +.Vt ENGINE +implementing the respective algorithm. +.Pp +If a default engine was previously selected, +.Xr ENGINE_init 3 +is called on it again and it is used. +Otherwise, these functions inspect the engines registered +with the functions documented in +.Xr ENGINE_register_RSA 3 +in the order of the table for the respective algorithm. +If an inspected engine is already successfully initialized, +.Xr ENGINE_init 3 +is called on it again and it is used as the new default. +Otherwise, unless the global flag +.Dv ENGINE_TABLE_FLAG_NOINIT +is set, +.Xr ENGINE_init 3 +is tried on it. +If it succeeds, that engine is used as the new default. +If it fails or if +.Dv ENGINE_TABLE_FLAG_NOINIT +is set, inspection continues with the next engine. +.Pp +The global flag can be set by calling +.Fn ENGINE_set_table_flags +with an argument of +.Dv ENGINE_TABLE_FLAG_NOINIT +or cleared by calling it with an argument of 0. +By default, the flag is not set. +.Pp +While all the other functions operate on exactly one algorithm, +.Fn ENGINE_get_cipher_engine +and +.Fn ENGINE_get_digest_engine +are special in so far as they can handle multiple algorithms, +identified by the given +.Fa nid . +The default engine is remembered separately for each algorithm. +.Pp +Application programs rarely need to call these functions because +they are called automatically when needed, in particular from +.Xr RSA_new 3 , +.Xr DSA_new 3 , +.Fn ECDH_set_method , +.Fn ECDH_compute_key , +.Xr ECDSA_set_method 3 , +.Xr ECDSA_do_sign_ex 3 , +.Xr ECDSA_do_verify 3 , +.Xr DH_new 3 , +.Xr EVP_CipherInit_ex 3 , +and +.Xr EVP_DigestInit_ex 3 . +.Sh RETURN VALUES +These functions return a functional reference to an +.Vt ENGINE +object or +.Dv NULL +on failure, in particular when no engine implementing the algorithm +is available, when +.Xr ENGINE_init 3 +fails for all implementations, +or when insufficient memory is available. +Even when these functions fail, the application may still be able +to use the algorithm in question because the built-in implementation +is used in that case, if one is available. +.Pp +.Fn ENGINE_get_table_flags +returns +.Dv ENGINE_TABLE_FLAG_NOINIT +if the global flag is set or 0 otherwise. +.Sh SEE ALSO +.Xr ENGINE_init 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_default 3 +.Sh HISTORY +.Fn ENGINE_get_default_RSA , +.Fn ENGINE_get_default_DSA , +.Fn ENGINE_get_default_DH , +and +.Fn ENGINE_get_default_RAND +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 2.9 . +.Pp +.Fn ENGINE_get_cipher_engine , +.Fn ENGINE_get_digest_engine , +.Fn ENGINE_set_table_flags , +and +.Fn ENGINE_get_table_flags +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . +.Pp +.Fn ENGINE_get_default_ECDH +and +.Fn ENGINE_get_default_ECDSA +first appeared in OpenSSL 0.9.8 and have been available since +.Ox 4.5 . diff --git a/lib/libcrypto/man/ENGINE_init.3 b/lib/libcrypto/man/ENGINE_init.3 new file mode 100644 index 0000000000..d41d98a2f1 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_init.3 @@ -0,0 +1,134 @@ +.\" $OpenBSD: ENGINE_init.3,v 1.2 2018/04/18 03:39:22 schwarze Exp $ +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_INIT 3 +.Os +.Sh NAME +.Nm ENGINE_init , +.Nm ENGINE_finish , +.Nm ENGINE_set_init_function , +.Nm ENGINE_set_finish_function , +.Nm ENGINE_get_init_function , +.Nm ENGINE_get_finish_function +.Nd initialize ENGINE objects +.Sh SYNOPSIS +.In openssl/engine.h +.Ft int +.Fo ENGINE_init +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_finish +.Fa "ENGINE *e" +.Fc +.Ft typedef int +.Fo (*ENGINE_GEN_INT_FUNC_PTR) +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_init_function +.Fa "ENGINE *e" +.Fa "ENGINE_GEN_INT_FUNC_PTR init_f" +.Fc +.Ft int +.Fo ENGINE_set_finish_function +.Fa "ENGINE *e" +.Fa "ENGINE_GEN_INT_FUNC_PTR finish_f" +.Fc +.Ft ENGINE_GEN_INT_FUNC_PTR +.Fo ENGINE_get_init_function +.Fa "const ENGINE *e" +.Fc +.Ft ENGINE_GEN_INT_FUNC_PTR +.Fo ENGINE_get_finish_function +.Fa "const ENGINE *e" +.Fc +.Sh DESCRIPTION +.Fn ENGINE_init +initializes +.Fa e +by calling the +.Fa init_f +previously installed with +.Fn ENGINE_set_init_function , +if any. +In case of success, it also increments both the structural +and the functional reference count by 1. +If no +.Fa init_f +was installed, +.Fn ENGINE_init +always succeeds. +Calling +.Fn ENGINE_init +again after it already succeeded always succeeds, but has no effect +except that it increments both the structural and the functional +reference count by 1. +.Pp +.Fn ENGINE_finish +decrements the functional reference count by 1. +When it reaches 0, it calls the +.Fa finish_f +previously installed with +.Fn ENGINE_set_finish_function , +if any. +If no +.Fa finish_f +was installed, +.Fn ENGINE_finish +always succeeds. +Unless +.Fa finish_f +fails, +.Fn ENGINE_finish +also calls +.Xr ENGINE_free 3 . +.Pp +.Fn ENGINE_init +is internally called by the functions documented in the +.Xr ENGINE_get_default_RSA 3 +manual page. +.Sh RETURN VALUES +.Fn ENGINE_init +and +.Fn ENGINE_finish +return 1 on success or 0 on error. +.Pp +.Fn ENGINE_set_init_function +and +.Fn ENGINE_set_finish_function +always return 1. +.Pp +.Fn ENGINE_get_init_function +and +.Fn ENGINE_get_finish_function +return a function pointer to the respective callback, or +.Dv NULL +if none is installed. +.Sh SEE ALSO +.Xr ENGINE_add 3 , +.Xr ENGINE_ctrl 3 , +.Xr ENGINE_get_default_RSA 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_default 3 , +.Xr ENGINE_set_flags 3 , +.Xr ENGINE_set_RSA 3 , +.Xr ENGINE_unregister_RSA 3 +.Sh HISTORY +These functions first appeared in OpenSSL 0.9.7 +and have been available since +.Ox 2.9 . diff --git a/lib/libcrypto/man/ENGINE_new.3 b/lib/libcrypto/man/ENGINE_new.3 new file mode 100644 index 0000000000..f1218b1708 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_new.3 @@ -0,0 +1,189 @@ +.\" $OpenBSD: ENGINE_new.3,v 1.3 2018/04/18 03:39:22 schwarze Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_NEW 3 +.Os +.Sh NAME +.Nm ENGINE_new , +.Nm ENGINE_up_ref , +.Nm ENGINE_free , +.Nm ENGINE_set_destroy_function , +.Nm ENGINE_get_destroy_function +.Nd create and destroy ENGINE objects +.Sh SYNOPSIS +.In openssl/engine.h +.Ft ENGINE * +.Fn ENGINE_new void +.Ft int +.Fo ENGINE_up_ref +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_free +.Fa "ENGINE *e" +.Fc +.Ft typedef int +.Fo (*ENGINE_GEN_INT_FUNC_PTR) +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_destroy_function +.Fa "ENGINE *e" +.Fa "ENGINE_GEN_INT_FUNC_PTR destroy_f" +.Fc +.Ft ENGINE_GEN_INT_FUNC_PTR +.Fo ENGINE_get_destroy_function +.Fa "const ENGINE *e" +.Fc +.Sh DESCRIPTION +.Vt ENGINE +objects can be used to provide alternative implementations of +cryptographic algorithms, to support additional algorithms, to +support cryptographic hardware, and to switch among alternative +implementations of algorithms at run time. +LibreSSL generally avoids engines and prefers providing +cryptographic functionality in the crypto library itself. +.Pp +.Fn ENGINE_new +allocates and initializes an empty +.Vt ENGINE +object and sets its structural reference count to 1 +and its functional reference count to 0. +For more information about the functional reference count, see the +.Xr ENGINE_init 3 +manual page. +.Pp +Many functions increment the structural reference count by 1 +when successful. +Some of them, including +.Xr ENGINE_get_first 3 , +.Xr ENGINE_get_last 3 , +.Xr ENGINE_get_next 3 , +.Xr ENGINE_get_prev 3 , +and +.Xr ENGINE_by_id 3 , +do so because they return a structural reference to the user. +Other functions, including +.Xr ENGINE_add 3 , +.Xr ENGINE_init 3 , +.Xr ENGINE_get_cipher_engine 3 , +.Xr ENGINE_get_digest_engine 3 , +and the +.Xr ENGINE_get_default_RSA 3 +and +.Xr ENGINE_set_default 3 +families of functions +do so when they store a structural refence internally. +.Pp +.Fn ENGINE_up_ref +explicitly increment the structural reference count by 1. +.Pp +.Fn ENGINE_free +decrements the structural reference count by 1, +and if it reaches 0, the optional +.Fa destroy_f +previously installed with +.Fn ENGINE_set_destroy_function +is called, if one is installed, and both the memory used internally by +.Fa e +and +.Fa e +itself are freed. +If +.Fa e +is a +.Dv NULL +pointer, no action occurs. +.Pp +Many functions internally call the equivalent of +.Fn ENGINE_free . +Some of them, including +.Xr ENGINE_get_next 3 +and +.Xr ENGINE_get_prev 3 , +thus invalidate the structural reference passed in by the user. +Other functions, including +.Xr ENGINE_finish 3 , +.Xr ENGINE_remove 3 , +and the +.Xr ENGINE_set_default 3 +family of functions +do so when an internally stored structural reference is no longer needed. +.Pp +.Fn ENGINE_set_destroy_function +installs a callback function that will be called by +.Fn ENGINE_free , +but only when +.Fa e +actually gets destroyed, +not when only its reference count gets decremented. +The value returned from the +.Fa destroy_f +will be ignored. +.Sh RETURN VALUES +.Fn ENGINE_new +returns a structural reference to the new +.Vt ENGINE +object or +.Dv NULL +if an error occurs. +.Pp +.Fn ENGINE_up_ref +returns 0 if +.Fa e +is +.Dv NULL +and 1 otherwise. +.Pp +.Fn ENGINE_free +and +.Fn ENGINE_set_destroy_function +always return 1. +.Pp +.Fn ENGINE_get_destroy_function +returns a function pointer to the callback, or +.Dv NULL +if none is installed. +.Sh SEE ALSO +.Xr ENGINE_add 3 , +.Xr ENGINE_ctrl 3 , +.Xr ENGINE_get_default_RSA 3 , +.Xr ENGINE_init 3 , +.Xr ENGINE_register_all_RSA 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_default 3 , +.Xr ENGINE_set_flags 3 , +.Xr ENGINE_set_RSA 3 , +.Xr ENGINE_unregister_RSA 3 +.Sh HISTORY +.Fn ENGINE_new +and +.Fn ENGINE_free +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 2.9 . +.Pp +.Fn ENGINE_set_destroy_function +and +.Fn ENGINE_get_destroy_function +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . +.Pp +.Fn ENGINE_up_ref +first appeared in OpenSSL 0.9.7 and has been available since +.Ox 3.4 . diff --git a/lib/libcrypto/man/ENGINE_register_RSA.3 b/lib/libcrypto/man/ENGINE_register_RSA.3 new file mode 100644 index 0000000000..5c63729cfc --- /dev/null +++ b/lib/libcrypto/man/ENGINE_register_RSA.3 @@ -0,0 +1,142 @@ +.\" $OpenBSD: ENGINE_register_RSA.3,v 1.2 2018/04/18 03:39:22 schwarze Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_REGISTER_RSA 3 +.Os +.Sh NAME +.Nm ENGINE_register_RSA , +.Nm ENGINE_register_DSA , +.Nm ENGINE_register_ECDH , +.Nm ENGINE_register_ECDSA , +.Nm ENGINE_register_DH , +.Nm ENGINE_register_RAND , +.Nm ENGINE_register_STORE , +.Nm ENGINE_register_ciphers , +.Nm ENGINE_register_digests , +.Nm ENGINE_register_complete +.Nd register an ENGINE as implementing an algorithm +.Sh SYNOPSIS +.In openssl/engine.h +.Ft int +.Fo ENGINE_register_RSA +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_DSA +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_ECDH +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_ECDSA +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_DH +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_RAND +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_STORE +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_ciphers +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_digests +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_register_complete +.Fa "ENGINE *e" +.Fc +.Sh DESCRIPTION +In addition to the global table described in +.Xr ENGINE_add 3 , +the crypto library maintains several tables containing references to +.Vt ENGINE +objects implementing one specific cryptographic algorithm. +.Pp +The functions listed in the present manual page append +.Fa e +to the end of the table for the respective algorithm. +.Pp +If +.Fa e +does not contain a method for the requested algorithm, +these functions succeed without having any effect. +.Pp +If +.Fa e +is already registered for the given algorithm, +they move it to the end of the respective table. +.Pp +.Fn ENGINE_register_ciphers +and +.Fn ENGINE_register_digests +are special in so far as an engine may implement +more than one cipher or more than one digest. +In that case, +.Fa e +is registered for all the ciphers or digests it implements. +.Pp +.Fn ENGINE_register_complete +registers +.Fa e +for all algorithms it implements by calling all the other functions. +.Sh RETURN VALUES +These functions return 1 on success or 0 on error. +They only fail if insufficient memory is available. +.Sh SEE ALSO +.Xr ENGINE_add 3 , +.Xr ENGINE_get_default_RSA 3 , +.Xr ENGINE_init 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_all_RSA 3 , +.Xr ENGINE_set_default 3 , +.Xr ENGINE_set_RSA 3 , +.Xr ENGINE_unregister_RSA 3 +.Sh HISTORY +.Fn ENGINE_register_RSA , +.Fn ENGINE_register_DSA , +.Fn ENGINE_register_DH , +.Fn ENGINE_register_RAND , +.Fn ENGINE_register_ciphers , +.Fn ENGINE_register_digests , +and +.Fn ENGINE_register_complete +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . +.Pp +.Fn ENGINE_register_ECDH , +.Fn ENGINE_register_ECDSA , +and +.Fn ENGINE_register_STORE +first appeared in OpenSSL 0.9.8 and have been available since +.Ox 4.5 . +.Sh BUGS +.Fn ENGINE_register_complete +ignores all errors, even memory allocation failure, and always returns 1. diff --git a/lib/libcrypto/man/ENGINE_register_all_RSA.3 b/lib/libcrypto/man/ENGINE_register_all_RSA.3 new file mode 100644 index 0000000000..3016eec3d4 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_register_all_RSA.3 @@ -0,0 +1,123 @@ +.\" $OpenBSD: ENGINE_register_all_RSA.3,v 1.3 2018/04/18 03:39:22 schwarze Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_REGISTER_ALL_RSA 3 +.Os +.Sh NAME +.Nm ENGINE_register_all_RSA , +.Nm ENGINE_register_all_DSA , +.Nm ENGINE_register_all_ECDH , +.Nm ENGINE_register_all_ECDSA , +.Nm ENGINE_register_all_DH , +.Nm ENGINE_register_all_RAND , +.Nm ENGINE_register_all_STORE , +.Nm ENGINE_register_all_ciphers , +.Nm ENGINE_register_all_digests , +.Nm ENGINE_register_all_complete , +.Nm ENGINE_load_builtin_engines , +.Nm ENGINE_load_dynamic +.Nd register all engines as implementing an algorithm +.Sh SYNOPSIS +.In openssl/engine.h +.Ft void +.Fn ENGINE_register_all_RSA void +.Ft void +.Fn ENGINE_register_all_DSA void +.Ft void +.Fn ENGINE_register_all_ECDH void +.Ft void +.Fn ENGINE_register_all_ECDSA void +.Ft void +.Fn ENGINE_register_all_DH void +.Ft void +.Fn ENGINE_register_all_RAND void +.Ft void +.Fn ENGINE_register_all_STORE void +.Ft void +.Fn ENGINE_register_all_ciphers void +.Ft void +.Fn ENGINE_register_all_digests void +.Ft int +.Fn ENGINE_register_all_complete void +.Ft void +.Fn ENGINE_load_builtin_engines void +.Ft void +.Fn ENGINE_load_dynamic void +.Sh DESCRIPTION +These functions loop over all the +.Vt ENGINE +objects contained in the global table described in the +.Xr ENGINE_add 3 +manual page. +They register each object for the respective algorithm +by calling the corresponding function described in +.Xr ENGINE_register_RSA 3 . +.Pp +.Fn ENGINE_register_all_complete +calls +.Fn ENGINE_register_complete +in this way, except that it skips those +.Vt ENGINE +objects that have the +.Dv ENGINE_FLAGS_NO_REGISTER_ALL +flag set with +.Xr ENGINE_set_flags 3 . +.Pp +.Fn ENGINE_load_builtin_engines +calls +.Xr OPENSSL_init_crypto 3 +with no options, loads any built-in engines +that are enabled by default, and calls +.Fn ENGINE_register_all_complete . +Currently, LibreSSL does not provide any engines. +.Sy GOST +and +.Sy aesni +support is provided by the crypto library itself +and does not require any engines, not even built-in ones. +.Pp +.Fn ENGINE_load_dynamic +has no effect and is only provided for compatibility. +.Sh SEE ALSO +.Xr ENGINE_add 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_flags 3 , +.Xr OPENSSL_config 3 , +.Xr OPENSSL_init_crypto 3 +.Sh HISTORY +.Fn ENGINE_register_all_RSA , +.Fn ENGINE_register_all_DSA , +.Fn ENGINE_register_all_DH , +.Fn ENGINE_register_all_RAND , +.Fn ENGINE_register_all_ciphers , +.Fn ENGINE_register_all_digests , +.Fn ENGINE_register_all_complete , +.Fn ENGINE_load_builtin_engines , +and +.Fn ENGINE_load_dynamic +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . +.Pp +.Fn ENGINE_register_all_ECDH , +.Fn ENGINE_register_all_ECDSA , +and +.Fn ENGINE_register_all_STORE +first appeared in OpenSSL 0.9.8 and have been available since +.Ox 4.5 . diff --git a/lib/libcrypto/man/ENGINE_set_RSA.3 b/lib/libcrypto/man/ENGINE_set_RSA.3 new file mode 100644 index 0000000000..acf4285e54 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_set_RSA.3 @@ -0,0 +1,325 @@ +.\" $OpenBSD: ENGINE_set_RSA.3,v 1.3 2018/05/17 07:21:32 jmc Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: May 17 2018 $ +.Dt ENGINE_SET_RSA 3 +.Os +.Sh NAME +.Nm ENGINE_set_RSA , +.Nm ENGINE_get_RSA , +.Nm ENGINE_set_DSA , +.Nm ENGINE_get_DSA , +.Nm ENGINE_set_ECDH , +.Nm ENGINE_get_ECDH , +.Nm ENGINE_set_ECDSA , +.Nm ENGINE_get_ECDSA , +.Nm ENGINE_set_DH , +.Nm ENGINE_get_DH , +.Nm ENGINE_set_RAND , +.Nm ENGINE_get_RAND , +.Nm ENGINE_set_STORE , +.Nm ENGINE_get_STORE , +.Nm ENGINE_set_ciphers , +.Nm ENGINE_get_ciphers , +.Nm ENGINE_get_cipher , +.Nm ENGINE_set_digests , +.Nm ENGINE_get_digests , +.Nm ENGINE_get_digest +.Nd install and retrieve function tables of crypto engines +.Sh SYNOPSIS +.In openssl/engine.h +.Ft int +.Fo ENGINE_set_RSA +.Fa "ENGINE *e" +.Fa "const RSA_METHOD *rsa_meth" +.Fc +.Ft const RSA_METHOD * +.Fo ENGINE_get_RSA +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_DSA +.Fa "ENGINE *e" +.Fa "const DSA_METHOD *dsa_meth" +.Fc +.Ft const DSA_METHOD * +.Fo ENGINE_get_DSA +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_ECDH +.Fa "ENGINE *e" +.Fa "const ECDH_METHOD *dh_meth" +.Fc +.Ft const ECDH_METHOD * +.Fo ENGINE_get_ECDH +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_ECDSA +.Fa "ENGINE *e" +.Fa "const ECDSA_METHOD *dh_meth" +.Fc +.Ft const ECDSA_METHOD * +.Fo ENGINE_get_ECDSA +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_DH +.Fa "ENGINE *e" +.Fa "const DH_METHOD *dh_meth" +.Fc +.Ft const DH_METHOD * +.Fo ENGINE_get_DH +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_RAND +.Fa "ENGINE *e" +.Fa "const RAND_METHOD *rand_meth" +.Fc +.Ft const RAND_METHOD * +.Fo ENGINE_get_RAND +.Fa "const ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_STORE +.Fa "ENGINE *e" +.Fa "const STORE_METHOD *rand_meth" +.Fc +.Ft const STORE_METHOD * +.Fo ENGINE_get_STORE +.Fa "const ENGINE *e" +.Fc +.Ft typedef int +.Fo (*ENGINE_CIPHERS_PTR) +.Fa "ENGINE *e" +.Fa "const EVP_CIPHER **impl" +.Fa "const int **nids" +.Fa "int nid" +.Fc +.Ft int +.Fo ENGINE_set_ciphers +.Fa "ENGINE *e" +.Fa "ENGINE_CIPHERS_PTR f" +.Fc +.Ft ENGINE_CIPHERS_PTR +.Fo ENGINE_get_ciphers +.Fa "const ENGINE *e" +.Fc +.Ft const EVP_CIPHER * +.Fo ENGINE_get_cipher +.Fa "ENGINE *e" +.Fa "int nid" +.Fc +.Ft typedef int +.Fo (*ENGINE_DIGESTS_PTR) +.Fa "ENGINE *e" +.Fa "const EVP_MD **impl" +.Fa "const int **nids" +.Fa "int nid" +.Fc +.Ft int +.Fo ENGINE_set_digests +.Fa "ENGINE *e" +.Fa "ENGINE_DIGESTS_PTR f" +.Fc +.Ft ENGINE_DIGESTS_PTR +.Fo ENGINE_get_digests +.Fa "const ENGINE *e" +.Fc +.Ft const EVP_MD * +.Fo ENGINE_get_digest +.Fa "ENGINE *e" +.Fa "int nid" +.Fc +.Sh DESCRIPTION +The +.Fn ENGINE_set_* +functions install a table of function pointers +implementing the respective algorithm in +.Fa e . +Partial information about the various method objects is available from +.Xr RSA_meth_new 3 , +.Xr RSA_get_default_method 3 , +.Xr DSA_meth_new 3 , +.Xr DSA_get_default_method 3 , +.Fn ECDH_get_default_method , +.Xr ECDSA_get_default_method 3 , +.Xr DH_get_default_method 3 , +.Xr RAND_get_rand_method 3 , +.Xr EVP_get_cipherbynid 3 , +and +.Xr EVP_get_digestbynid 3 . +.Vt STORE_METHOD +is an incomplete type, and the pointers to it are not used for anything. +For complete descriptions of these types, +refer to the respective header files. +.Pp +The functions described in the +.Xr ENGINE_register_RSA 3 +and +.Xr ENGINE_set_default 3 +manual pages only have an effect after function pointers +were installed using the functions described here. +.Pp +.Fn ENGINE_set_ciphers +and +.Fn ENGINE_set_digests +are special in so far as the +.Vt ENGINE +structure does not provide fields to store function pointers +implementing ciphers or digests. +Instead, these two functions only install a callback to +retrieve implementations. +Where the pointers to the implementations are stored internally, +how they get initialized, and how the +.Vt ENGINE_CIPHERS_PTR +and +.Vt ENGINE_DIGESTS_PTR +callbacks retrieve them +is up to the implementation of each individual engine. +.Pp +If the +.Vt ENGINE_CIPHERS_PTR +and +.Vt ENGINE_DIGESTS_PTR +callbacks are called with a non-zero +.Fa nid , +they retrieve the implementation of that cipher or digest, +respectively. +In this case, a +.Dv NULL +pointer can be passed as the +.Fa nids +argument. +.Fn ENGINE_get_cipher +and +.Fn ENGINE_get_digest +call the callbacks installed in +.Fa e +in this way. +.Pp +If 0 is passed as the +.Fa nid +argument, an internal pointer +to the array of implementations available in +.Fa e +is returned in +.Pf * Fa impl , +and an internal pointer +to the array of corresponding identifiers in +.Pf * Fa nids . +The return value of the callback indicates +the number of implementations returned. +.Pp +The +.Fn ENGINE_get_* +functions retrieve the previously installed function tables. +They are used when constructing basic cryptographic objects +as shown in the following table: +.Bl -column "ENGINE_get_digestMM" +.It Accessor: Ta Called by: +.It Fn ENGINE_get_RSA Ta Xr RSA_new_method 3 , Xr RSA_new 3 +.It Fn ENGINE_get_DSA Ta Xr DSA_new_method 3 , Xr DSA_new 3 +.It Fn ENGINE_get_ECDH Ta Fn ECDH_set_method , Fn ECDH_compute_key +.It Fn ENGINE_get_ECDSA Ta Xr ECDSA_set_method 3 , Xr ECDSA_sign_setup 3 , +.Xr ECDSA_do_sign_ex 3 , Xr ECDSA_do_verify 3 +.It Fn ENGINE_get_DH Ta Xr DH_new_method 3 , Xr DH_new 3 +.It Fn ENGINE_get_RAND Ta unused +.It Fn ENGINE_get_STORE Ta unused +.It Fn ENGINE_get_cipher Ta Xr EVP_CipherInit_ex 3 +.It Fn ENGINE_get_digest Ta Xr EVP_DigestInit_ex 3 +.El +.Sh RETURN VALUES +The +.Fn ENGINE_set_* +functions return 1 on success or 0 on error. +Currently, they cannot fail. +.Pp +The +.Fn ENGINE_get_* +functions return a method object for the respective algorithm, or +.Dv NULL +if none is installed. +.Pp +.Fn ENGINE_get_ciphers +and +.Fn ENGINE_get_digests +return a function pointer to the respective callback, or +.Dv NULL +if none is installed. +.Pp +.Fn ENGINE_get_cipher +returns an +.Vt EVP_CIPHER +object implementing the cipher +.Fa nid +or +.Dv NULL +if +.Fa e +does not implement that cipher. +.Pp +.Fn ENGINE_get_digest +returns an +.Vt EVP_MD +object implementing the digest +.Fa nid +or +.Dv NULL +if +.Fa e +does not implement that digest. +.Sh SEE ALSO +.Xr ENGINE_ctrl 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_default 3 , +.Xr ENGINE_set_flags 3 +.Sh HISTORY +.Fn ENGINE_set_RSA , +.Fn ENGINE_get_RSA , +.Fn ENGINE_set_DSA , +.Fn ENGINE_get_DSA , +.Fn ENGINE_set_DH , +.Fn ENGINE_get_DH , +.Fn ENGINE_set_RAND , +.Fn ENGINE_get_RAND , +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 2.9 . +.Pp +.Fn ENGINE_set_ciphers , +.Fn ENGINE_get_ciphers , +.Fn ENGINE_get_cipher , +.Fn ENGINE_set_digests , +.Fn ENGINE_get_digests , +and +.Fn ENGINE_get_digest +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . +.Pp +.Fn ENGINE_set_ECDH , +.Fn ENGINE_get_ECDH , +.Fn ENGINE_set_ECDSA , +.Fn ENGINE_get_ECDSA , +.Fn ENGINE_set_STORE , +and +.Fn ENGINE_get_STORE +first appeared in OpenSSL 0.9.8 and have been available since +.Ox 4.5 . diff --git a/lib/libcrypto/man/ENGINE_set_default.3 b/lib/libcrypto/man/ENGINE_set_default.3 new file mode 100644 index 0000000000..d63dc2f390 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_set_default.3 @@ -0,0 +1,185 @@ +.\" $OpenBSD: ENGINE_set_default.3,v 1.3 2018/04/18 12:56:50 jmc Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE 3 +.Os +.Sh NAME +.Nm ENGINE_set_default , +.Nm ENGINE_set_default_string , +.Nm ENGINE_set_default_RSA , +.Nm ENGINE_set_default_DSA , +.Nm ENGINE_set_default_ECDH , +.Nm ENGINE_set_default_ECDSA , +.Nm ENGINE_set_default_DH , +.Nm ENGINE_set_default_RAND , +.Nm ENGINE_set_default_ciphers , +.Nm ENGINE_set_default_digests +.Nd register an ENGINE as the default for an algorithm +.Sh SYNOPSIS +.Ft int +.Fo ENGINE_set_default_RSA +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default_DSA +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default_ECDH +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default_ECDSA +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default_DH +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default_RAND +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default_ciphers +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default_digests +.Fa "ENGINE *e" +.Fc +.Ft int +.Fo ENGINE_set_default +.Fa "ENGINE *e" +.Fa "unsigned int flags" +.Fc +.Ft int +.Fo ENGINE_set_default_string +.Fa "ENGINE *e" +.Fa "const char *list" +.Fc +.Sh DESCRIPTION +These functions register +.Fa e +as implementing the respective algorithm +like the functions described in the +.Xr ENGINE_register_RSA 3 +manual page do it. +In addition, they call +.Xr ENGINE_init 3 +on +.Fa e +and select +.Fa e +as the default implementation of the respective algorithm to be +returned by the functions described in +.Xr ENGINE_get_default_RSA 3 +in the future. +If another engine was previously selected +as the default implementation of the respective algorithm, +.Xr ENGINE_finish 3 +is called on that previous engine. +.Pp +If +.Fa e +implements more than one cipher or digest, +.Fn ENGINE_set_default_ciphers +and +.Fn ENGINE_set_default_digests +register and select it for all these ciphers and digests, respectively. +.Pp +.Fn ENGINE_set_default +registers +.Fa e +as the default implementation of all algorithms specified by the +.Fa flags +by calling the appropriate ones among the other functions. +Algorithms can be selected by combining any number of the +following constants with bitwise OR: +.Dv ENGINE_METHOD_ALL , +.Dv ENGINE_METHOD_RSA , +.Dv ENGINE_METHOD_DSA , +.Dv ENGINE_METHOD_ECDH , +.Dv ENGINE_METHOD_ECDSA , +.Dv ENGINE_METHOD_DH , +.Dv ENGINE_METHOD_RAND , +.Dv ENGINE_METHOD_CIPHERS , +.Dv ENGINE_METHOD_DIGESTS , +.Dv ENGINE_METHOD_PKEY_METHS , +and +.Dv ENGINE_METHOD_PKEY_ASN1_METHS . +.Pp +.Fn ENGINE_set_default_string +is similar except that it selects the algorithms according to the string +.Fa def_list , +which contains an arbitrary number of comma-separated keywords from +the following list: ALL, RSA, DSA, ECDH, ECDSA, DH, RAND, CIPHERS, +DIGESTS, PKEY_CRYPTO, PKEY_ASN1, and PKEY. +PKEY_CRYPTO corresponds to +.Dv ENGINE_METHOD_PKEY_METHS , +PKEY_ASN1 to +.Dv ENGINE_METHOD_PKEY_ASN1_METHS , +and PKEY selects both. +.Sh RETURN VALUES +These functions return 1 on success or 0 on error. +They fail if +.Xr ENGINE_init 3 +fails or if insufficient memory is available. +.Sh SEE ALSO +.Xr ENGINE_get_default_RSA 3 , +.Xr ENGINE_init 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_RSA 3 , +.Xr ENGINE_unregister_RSA 3 +.Sh HISTORY +.Fn ENGINE_set_default , +.Fn ENGINE_set_default_RSA , +.Fn ENGINE_set_default_DSA , +.Fn ENGINE_set_default_DH , +and +.Fn ENGINE_set_default_RAND +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 2.9 . +.Pp +.Fn ENGINE_set_default_string , +.Fn ENGINE_set_default_ciphers , +and +.Fn ENGINE_set_default_digests +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . +.Pp +.Fn ENGINE_set_default_ECDH +and +.Fn ENGINE_set_default_ECDSA +first appeared in OpenSSL 0.9.8 and have been available since +.Ox 4.5 . +.Sh CAVEATS +Failure of +.Xr ENGINE_finish 3 +is ignored. +.Sh BUGS +Even when +.Fn ENGINE_set_default +or +.Fn ENGINE_set_default_string +fail, they typically still register +.Fa e +for some algorithms, but usually not for all it could be registered +for by calling the individual functions. diff --git a/lib/libcrypto/man/ENGINE_set_flags.3 b/lib/libcrypto/man/ENGINE_set_flags.3 new file mode 100644 index 0000000000..33e8f333ce --- /dev/null +++ b/lib/libcrypto/man/ENGINE_set_flags.3 @@ -0,0 +1,92 @@ +.\" $OpenBSD: ENGINE_set_flags.3,v 1.2 2018/04/18 03:39:22 schwarze Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_SET_FLAGS 3 +.Os +.Sh NAME +.Nm ENGINE_set_flags , +.Nm ENGINE_get_flags +.Nd modify the behaviour of an ENGINE object +.Sh SYNOPSIS +.In openssl/engine.h +.Ft int +.Fo ENGINE_set_flags +.Fa "ENGINE *e" +.Fa "int flags" +.Fc +.Ft int +.Fo ENGINE_get_flags +.Fa "const ENGINE *e" +.Fc +.Sh DESCRIPTION +.Fn ENGINE_set_flags +sets the flags attribute of +.Fa e +to the new +.Fa flags . +The previous state of the flags attribute is overwritten. +Flags that were previously set are cleared +unless they are also present in the new +.Fa flags . +.Pp +The +.Fa flags +argument can be the bitwise OR of zero or more +of the following constants: +.Bl -tag -width Ds +.It Dv ENGINE_FLAGS_BY_ID_COPY +.Xr ENGINE_by_id 3 +returns a shallow copy of the +.Vt ENGINE +object it found rather than incrementing the reference count +and returning a pointer to the original. +.It Dv ENGINE_FLAGS_MANUAL_CMD_CTRL +.Xr ENGINE_ctrl 3 +lets the function installed with +.Xr ENGINE_set_ctrl_function 3 +handle all commands except +.Dv ENGINE_CTRL_HAS_CTRL_FUNCTION , +even the builtin commands. +.It Dv ENGINE_FLAGS_NO_REGISTER_ALL +.Xr ENGINE_register_all_complete 3 +skips +.Fa e . +.El +.Sh RETURN VALUES +.Fn ENGINE_set_flags +always returns 1. +.Pp +.Fn ENGINE_get_flags +returns the +.Fa flags +attribute of +.Fa e . +.Sh SEE ALSO +.Xr ENGINE_by_id 3 , +.Xr ENGINE_ctrl 3 , +.Xr ENGINE_init 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_all_complete 3 , +.Xr ENGINE_set_RSA 3 +.Sh HISTORY +.Fn ENGINE_set_flags +and +.Fn ENGINE_get_flags +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . diff --git a/lib/libcrypto/man/ENGINE_unregister_RSA.3 b/lib/libcrypto/man/ENGINE_unregister_RSA.3 new file mode 100644 index 0000000000..d037306382 --- /dev/null +++ b/lib/libcrypto/man/ENGINE_unregister_RSA.3 @@ -0,0 +1,119 @@ +.\" $OpenBSD: ENGINE_unregister_RSA.3,v 1.3 2018/04/18 03:39:22 schwarze Exp $ +.\" content checked up to: +.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: April 18 2018 $ +.Dt ENGINE_UNREGISTER_RSA 3 +.Os +.Sh NAME +.Nm ENGINE_unregister_RSA , +.Nm ENGINE_unregister_DSA , +.Nm ENGINE_unregister_ECDH , +.Nm ENGINE_unregister_ECDSA , +.Nm ENGINE_unregister_DH , +.Nm ENGINE_unregister_RAND , +.Nm ENGINE_unregister_STORE , +.Nm ENGINE_unregister_ciphers , +.Nm ENGINE_unregister_digests +.Nd revoke the registration of an ENGINE object +.Sh SYNOPSIS +.In openssl/engine.h +.Ft void +.Fo ENGINE_unregister_RSA +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_DSA +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_ECDH +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_ECDSA +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_DH +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_RAND +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_STORE +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_ciphers +.Fa "ENGINE *e" +.Fc +.Ft void +.Fo ENGINE_unregister_digests +.Fa "ENGINE *e" +.Fc +.Sh DESCRIPTION +These functions remove +.Fa e +from the list of +.Vt ENGINE +objects that were previously registered for the respective algorithm +with the functions described in +.Xr ENGINE_register_RSA 3 . +.Pp +If +.Fa e +is currently used as the default engine for the algorithm +as described in the +.Fn ENGINE_set_default 3 +and +.Fn ENGINE_get_default_RSA 3 +manual pages, +.Xr ENGINE_finish 3 +is also called. +.Pp +.Fn ENGINE_unregister_ciphers +and +.Fn ENGINE_unregister_digests +unregister +.Fa e +for all ciphers or digests, respectively. +.Sh SEE ALSO +.Xr ENGINE_cleanup 3 , +.Xr ENGINE_finish 3 , +.Xr ENGINE_new 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_default 3 +.Sh HISTORY +.Fn ENGINE_unregister_RSA , +.Fn ENGINE_unregister_DSA , +.Fn ENGINE_unregister_DH , +.Fn ENGINE_unregister_RAND , +.Fn ENGINE_unregister_ciphers , +and +.Fn ENGINE_unregister_digests +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . +.Pp +.Fn ENGINE_unregister_ECDH , +.Fn ENGINE_unregister_ECDSA , +and +.Fn ENGINE_unregister_STORE +first appeared in OpenSSL 0.9.8 and have been available since +.Ox 4.5 . diff --git a/lib/libcrypto/man/ERR_GET_LIB.3 b/lib/libcrypto/man/ERR_GET_LIB.3 index b43f731ba8..bc14f0e2ac 100644 --- a/lib/libcrypto/man/ERR_GET_LIB.3 +++ b/lib/libcrypto/man/ERR_GET_LIB.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_GET_LIB.3,v 1.6 2018/03/20 22:56:38 schwarze Exp $ +.\" $OpenBSD: ERR_GET_LIB.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL doc/man3/ERR_GET_LIB.pod 3dfda1a6 Dec 12 11:14:40 2016 -0500 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_GET_LIB 3 .Os .Sh NAME @@ -122,5 +122,5 @@ returns non-zero if the error is fatal or 0 otherwise. .Fn ERR_GET_REASON , and .Fn ERR_FATAL_ERROR -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.4.4 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/ERR_clear_error.3 b/lib/libcrypto/man/ERR_clear_error.3 index 89d4f320a4..54f563e166 100644 --- a/lib/libcrypto/man/ERR_clear_error.3 +++ b/lib/libcrypto/man/ERR_clear_error.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_clear_error.3,v 1.4 2018/03/20 22:56:38 schwarze Exp $ +.\" $OpenBSD: ERR_clear_error.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_CLEAR_ERROR 3 .Os .Sh NAME @@ -66,5 +66,5 @@ empties the current thread's error queue. .Xr ERR_get_error 3 .Sh HISTORY .Fn ERR_clear_error -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.4.4 and has been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/ERR_error_string.3 b/lib/libcrypto/man/ERR_error_string.3 index 1587be1bbd..60f9132859 100644 --- a/lib/libcrypto/man/ERR_error_string.3 +++ b/lib/libcrypto/man/ERR_error_string.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_error_string.3,v 1.6 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: ERR_error_string.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_ERROR_STRING 3 .Os .Sh NAME @@ -168,7 +168,7 @@ if none is registered for the error code. .Fn ERR_func_error_string , and .Fn ERR_reason_error_string -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.4.4 and have been available since .Ox 2.4 . .Pp .Fn ERR_error_string_n diff --git a/lib/libcrypto/man/ERR_get_error.3 b/lib/libcrypto/man/ERR_get_error.3 index a8ab16b713..f3bcc09cbc 100644 --- a/lib/libcrypto/man/ERR_get_error.3 +++ b/lib/libcrypto/man/ERR_get_error.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_get_error.3,v 1.7 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: ERR_get_error.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_GET_ERROR 3 .Os .Sh NAME @@ -168,12 +168,14 @@ The error code, or 0 if there is no error in the queue. .Xr ERR_error_string 3 , .Xr ERR_GET_LIB 3 .Sh HISTORY -.Fn ERR_get_error , -.Fn ERR_peek_error , -.Fn ERR_get_error_line , +.Fn ERR_get_error +and +.Fn ERR_peek_error +first appeared in SSLeay 0.4.4. +.Fn ERR_get_error_line and .Fn ERR_peek_error_line -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.6.0. .Fn ERR_get_error_line_data and .Fn ERR_peek_error_line_data diff --git a/lib/libcrypto/man/ERR_load_crypto_strings.3 b/lib/libcrypto/man/ERR_load_crypto_strings.3 index 2f1af112c3..5421781bcc 100644 --- a/lib/libcrypto/man/ERR_load_crypto_strings.3 +++ b/lib/libcrypto/man/ERR_load_crypto_strings.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_load_crypto_strings.3,v 1.6 2018/03/20 20:26:23 schwarze Exp $ +.\" $OpenBSD: ERR_load_crypto_strings.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_LOAD_CRYPTO_STRINGS 3 .Os .Sh NAME @@ -119,12 +119,15 @@ frees all previously loaded error strings. .Xr ERR 3 , .Xr ERR_error_string 3 .Sh HISTORY -.Fn ERR_load_crypto_strings , -.Fn ERR_free_strings , -.Fn ERR_load_BN_strings , +.Fn ERR_load_crypto_strings and .Fn SSL_load_error_strings -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.4.4. +.Fn ERR_free_strings +and +.Fn ERR_load_BN_strings +first appeared in SSLeay 0.5.1. +These functions been available since .Ox 2.4 . .Sh BUGS Even though the error strings are already compiled into the object diff --git a/lib/libcrypto/man/ERR_load_strings.3 b/lib/libcrypto/man/ERR_load_strings.3 index a4470be735..44fde08c90 100644 --- a/lib/libcrypto/man/ERR_load_strings.3 +++ b/lib/libcrypto/man/ERR_load_strings.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_load_strings.3,v 1.6 2018/03/21 06:44:51 schwarze Exp $ +.\" $OpenBSD: ERR_load_strings.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_LOAD_STRINGS 3 .Os .Sh NAME @@ -110,7 +110,7 @@ returns a new library number. .Fn ERR_load_strings and .Fn ERR_PACK -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.4.4. .Fn ERR_get_next_error_library first appeared in SSLeay 0.9.0. These functions have been available since diff --git a/lib/libcrypto/man/ERR_print_errors.3 b/lib/libcrypto/man/ERR_print_errors.3 index cf65d2384b..a6fdbc0cdb 100644 --- a/lib/libcrypto/man/ERR_print_errors.3 +++ b/lib/libcrypto/man/ERR_print_errors.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_print_errors.3,v 1.6 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: ERR_print_errors.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller , @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_PRINT_ERRORS 3 .Os .Sh NAME @@ -116,9 +116,10 @@ return no values. .Xr SSL_load_error_strings 3 .Sh HISTORY .Fn ERR_print_errors -and +first appeared in SSLeay 0.4.5. .Fn ERR_print_errors_fp -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.0. +Both functions have been available since .Ox 2.4 . .Pp .Fn ERR_print_errors_cb diff --git a/lib/libcrypto/man/ERR_put_error.3 b/lib/libcrypto/man/ERR_put_error.3 index 3651503144..142d2eb2bd 100644 --- a/lib/libcrypto/man/ERR_put_error.3 +++ b/lib/libcrypto/man/ERR_put_error.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_put_error.3,v 1.8 2018/03/23 05:48:56 schwarze Exp $ +.\" $OpenBSD: ERR_put_error.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_PUT_ERROR 3 .Os .Sh NAME @@ -147,10 +147,10 @@ macro. .Xr ERR_load_strings 3 .Sh HISTORY .Fn ERR_put_error -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.4.4. .Fn ERR_add_error_data first appeared in SSLeay 0.9.0. -These functions have been available since +Both functions have been available since .Ox 2.4 . .Pp .Fn ERR_add_error_vdata diff --git a/lib/libcrypto/man/ERR_remove_state.3 b/lib/libcrypto/man/ERR_remove_state.3 index c667bd5eea..0a87978227 100644 --- a/lib/libcrypto/man/ERR_remove_state.3 +++ b/lib/libcrypto/man/ERR_remove_state.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_remove_state.3,v 1.5 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: ERR_remove_state.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" .\" This file was written by Ulf Moeller and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt ERR_REMOVE_STATE 3 .Os .Sh NAME @@ -101,7 +101,7 @@ return no value. .Xr ERR 3 .Sh HISTORY .Fn ERR_remove_state -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.6.1 and has been available since .Ox 2.4 . .Pp It was deprecated in OpenSSL 1.0.0 and diff --git a/lib/libcrypto/man/EVP_BytesToKey.3 b/lib/libcrypto/man/EVP_BytesToKey.3 index 9aafc84f4b..1178c77ad8 100644 --- a/lib/libcrypto/man/EVP_BytesToKey.3 +++ b/lib/libcrypto/man/EVP_BytesToKey.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_BytesToKey.3,v 1.6 2018/03/20 23:56:07 schwarze Exp $ +.\" $OpenBSD: EVP_BytesToKey.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt EVP_BYTESTOKEY 3 .Os .Sh NAME @@ -140,5 +140,5 @@ returns the size of the derived key in bytes or 0 on error. .Xr RAND_bytes 3 .Sh HISTORY .Fn EVP_BytesToKey -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/EVP_DigestInit.3 b/lib/libcrypto/man/EVP_DigestInit.3 index 98a06183d3..5ed639e51f 100644 --- a/lib/libcrypto/man/EVP_DigestInit.3 +++ b/lib/libcrypto/man/EVP_DigestInit.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_DigestInit.3,v 1.14 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: EVP_DigestInit.3,v 1.15 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000 .\" selective merge up to: OpenSSL a95d7574 Jul 2 12:16:38 2017 -0400 .\" @@ -51,7 +51,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt EVP_DIGESTINIT 3 .Os .Sh NAME @@ -623,21 +623,28 @@ main(int argc, char *argv[]) .Fn EVP_DigestUpdate , .Fn EVP_DigestFinal , .Dv EVP_MAX_MD_SIZE , -.Fn EVP_MD_type , -.Fn EVP_MD_pkey_type , -.Fn EVP_MD_size , +.Fn EVP_md5 , +and +.Fn EVP_sha1 +first appeared in SSLeay 0.5.1. +.Fn EVP_dss +and +.Fn EVP_dss1 +first appeared in SSLeay 0.6.0. +.Fn EVP_MD_size +first appeared in SSLeay 0.6.6. .Fn EVP_MD_CTX_size , .Fn EVP_MD_CTX_type , .Fn EVP_md_null , -.Fn EVP_md5 , -.Fn EVP_sha1 , -.Fn EVP_dss , -.Fn EVP_dss1 , -.Fn EVP_get_digestbyname , +and +.Fn EVP_get_digestbyname +first appeared in SSLeay 0.8.0. +.Fn EVP_MD_type , +.Fn EVP_MD_pkey_type , .Fn EVP_get_digestbynid , and .Fn EVP_get_digestbyobj -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.8.1. .Fn EVP_MD_block_size , .Fn EVP_MD_CTX_size , .Fn EVP_MD_CTX_block_size , @@ -673,7 +680,8 @@ first appeared in OpenSSL 0.9.7 and have been available since .Fn EVP_sha384 , and .Fn EVP_sha512 -first appeared in OpenSSL 0.8.7h and have been available since +first appeared in OpenSSL 0.9.7h and 0.9.8a +and have been available since .Ox 4.0 . .Pp .Fn EVP_MD_CTX_ctrl diff --git a/lib/libcrypto/man/EVP_DigestVerifyInit.3 b/lib/libcrypto/man/EVP_DigestVerifyInit.3 index 91a8ca8f33..5138e784f4 100644 --- a/lib/libcrypto/man/EVP_DigestVerifyInit.3 +++ b/lib/libcrypto/man/EVP_DigestVerifyInit.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_DigestVerifyInit.3,v 1.5 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: EVP_DigestVerifyInit.3,v 1.6 2018/05/13 14:00:22 schwarze Exp $ .\" OpenSSL fb552ac6 Sep 30 23:43:01 2009 +0000 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt EVP_DIGESTVERIFYINIT 3 .Os .Sh NAME @@ -76,7 +76,7 @@ .Ft int .Fo EVP_DigestVerifyFinal .Fa "EVP_MD_CTX *ctx" -.Fa "unsigned char *sig" +.Fa "const unsigned char *sig" .Fa "size_t siglen" .Fc .Sh DESCRIPTION diff --git a/lib/libcrypto/man/EVP_EncodeInit.3 b/lib/libcrypto/man/EVP_EncodeInit.3 index 8ab5485adb..bf9ed71ac3 100644 --- a/lib/libcrypto/man/EVP_EncodeInit.3 +++ b/lib/libcrypto/man/EVP_EncodeInit.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_EncodeInit.3,v 1.3 2018/03/20 23:56:07 schwarze Exp $ +.\" $OpenBSD: EVP_EncodeInit.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL f430ba31 Jun 19 19:39:01 2016 +0200 .\" .\" This file was written by Matt Caswell . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt EVP_ENCODEINIT 3 .Os .Sh NAME @@ -294,6 +294,6 @@ returns the length of the data decoded or -1 on error. .Sh SEE ALSO .Xr evp 3 .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier +These functions first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/EVP_EncryptInit.3 b/lib/libcrypto/man/EVP_EncryptInit.3 index 775b9c4214..436b1e47e6 100644 --- a/lib/libcrypto/man/EVP_EncryptInit.3 +++ b/lib/libcrypto/man/EVP_EncryptInit.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: EVP_EncryptInit.3,v 1.19 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: EVP_EncryptInit.3,v 1.25 2018/09/12 15:09:22 jmc Exp $ .\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800 -.\" selective merge up to: OpenSSL 5c5eb286 Dec 5 00:36:43 2017 +0100 +.\" selective merge up to: OpenSSL 16cfc2c9 Mar 8 22:30:28 2018 +0100 .\" .\" This file was written by Dr. Stephen Henson .\" and Richard Levitte . @@ -51,7 +51,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: September 12 2018 $ .Dt EVP_ENCRYPTINIT 3 .Os .Sh NAME @@ -94,6 +94,8 @@ .Nm EVP_CIPHER_CTX_block_size , .Nm EVP_CIPHER_CTX_key_length , .Nm EVP_CIPHER_CTX_iv_length , +.Nm EVP_CIPHER_CTX_get_iv , +.Nm EVP_CIPHER_CTX_set_iv , .Nm EVP_CIPHER_CTX_get_app_data , .Nm EVP_CIPHER_CTX_set_app_data , .Nm EVP_CIPHER_CTX_type , @@ -183,8 +185,8 @@ .Fa "EVP_CIPHER_CTX *ctx" .Fa "const EVP_CIPHER *type" .Fa "ENGINE *impl" -.Fa "unsigned char *key" -.Fa "unsigned char *iv" +.Fa "const unsigned char *key" +.Fa "const unsigned char *iv" .Fc .Ft int .Fo EVP_EncryptUpdate @@ -205,8 +207,8 @@ .Fa "EVP_CIPHER_CTX *ctx" .Fa "const EVP_CIPHER *type" .Fa "ENGINE *impl" -.Fa "unsigned char *key" -.Fa "unsigned char *iv" +.Fa "const unsigned char *key" +.Fa "const unsigned char *iv" .Fc .Ft int .Fo EVP_DecryptUpdate @@ -227,8 +229,8 @@ .Fa "EVP_CIPHER_CTX *ctx" .Fa "const EVP_CIPHER *type" .Fa "ENGINE *impl" -.Fa "unsigned char *key" -.Fa "unsigned char *iv" +.Fa "const unsigned char *key" +.Fa "const unsigned char *iv" .Fa "int enc" .Fc .Ft int @@ -236,7 +238,7 @@ .Fa "EVP_CIPHER_CTX *ctx" .Fa "unsigned char *out" .Fa "int *outl" -.Fa "unsigned char *in" +.Fa "const unsigned char *in" .Fa "int inl" .Fc .Ft int @@ -249,8 +251,8 @@ .Fo EVP_EncryptInit .Fa "EVP_CIPHER_CTX *ctx" .Fa "const EVP_CIPHER *type" -.Fa "unsigned char *key" -.Fa "unsigned char *iv" +.Fa "const unsigned char *key" +.Fa "const unsigned char *iv" .Fc .Ft int .Fo EVP_EncryptFinal @@ -262,8 +264,8 @@ .Fo EVP_DecryptInit .Fa "EVP_CIPHER_CTX *ctx" .Fa "const EVP_CIPHER *type" -.Fa "unsigned char *key" -.Fa "unsigned char *iv" +.Fa "const unsigned char *key" +.Fa "const unsigned char *iv" .Fc .Ft int .Fo EVP_DecryptFinal @@ -275,8 +277,8 @@ .Fo EVP_CipherInit .Fa "EVP_CIPHER_CTX *ctx" .Fa "const EVP_CIPHER *type" -.Fa "unsigned char *key" -.Fa "unsigned char *iv" +.Fa "const unsigned char *key" +.Fa "const unsigned char *iv" .Fa "int enc" .Fc .Ft int @@ -367,6 +369,18 @@ .Fo EVP_CIPHER_CTX_iv_length .Fa "const EVP_CIPHER_CTX *ctx" .Fc +.Ft int +.Fo EVP_CIPHER_CTX_get_iv +.Fa "const EVP_CIPHER_CTX *ctx" +.Fa "u_char *iv" +.Fa "size_t len" +.Fc +.Ft int +.Fo EVP_CIPHER_CTX_set_iv +.Fa "EVP_CIPHER_CTX *ctx" +.Fa "const u_char *iv" +.Fa "size_t len" +.Fc .Ft void * .Fo EVP_CIPHER_CTX_get_app_data .Fa "const EVP_CIPHER_CTX *ctx" @@ -651,6 +665,15 @@ The constant .Dv EVP_MAX_IV_LENGTH is the maximum IV length for all ciphers. .Pp +.Fn EVP_CIPHER_CTX_get_iv +and +.Fn EVP_CIPHER_CTX_set_iv +will respectively retrieve and set the IV for an +.Vt EVP_CIPHER_CTX . +In both cases, the specified IV length must exactly equal the expected +IV length for the context as returned by +.Fn EVP_CIPHER_CTX_iv_length . +.Pp .Fn EVP_CIPHER_block_size and .Fn EVP_CIPHER_CTX_block_size @@ -804,6 +827,8 @@ for failure. .Pp .Fn EVP_CIPHER_CTX_reset , .Fn EVP_CIPHER_CTX_cleanup , +.Fn EVP_CIPHER_CTX_get_iv , +.Fn EVP_CIPHER_CTX_set_iv , .Fn EVP_EncryptInit_ex , .Fn EVP_EncryptUpdate , .Fn EVP_EncryptFinal_ex , @@ -1089,7 +1114,7 @@ Sets the CCM L value. If not set, a default is used (8 for AES). .It Fn EVP_CIPHER_CTX_ctrl ctx EVP_CTRL_CCM_SET_IVLEN ivlen NULL Sets the CCM nonce (IV) length: this call can only be made before -specifying an nonce value. +specifying a nonce value. The nonce length is given by 15 - L so it is 7 by default for AES. .El .Sh EXAMPLES @@ -1204,7 +1229,6 @@ do_crypt(FILE *in, FILE *out, int do_encrypt) .Sh SEE ALSO .Xr evp 3 .Sh HISTORY -.Fn EVP_CIPHER_CTX_cleanup , .Fn EVP_EncryptInit , .Fn EVP_EncryptUpdate , .Fn EVP_EncryptFinal , @@ -1215,20 +1239,6 @@ do_crypt(FILE *in, FILE *out, int do_encrypt) .Fn EVP_CipherUpdate , .Fn EVP_CipherFinal , .Fn EVP_get_cipherbyname , -.Fn EVP_get_cipherbynid , -.Fn EVP_get_cipherbyobj , -.Fn EVP_CIPHER_nid , -.Fn EVP_CIPHER_block_size , -.Fn EVP_CIPHER_key_length , -.Fn EVP_CIPHER_iv_length , -.Fn EVP_CIPHER_CTX_cipher , -.Fn EVP_CIPHER_CTX_nid , -.Fn EVP_CIPHER_CTX_block_size , -.Fn EVP_CIPHER_CTX_key_length , -.Fn EVP_CIPHER_CTX_iv_length , -.Fn EVP_CIPHER_CTX_get_app_data , -.Fn EVP_CIPHER_CTX_set_app_data , -.Fn EVP_enc_null , .Fn EVP_des_cbc , .Fn EVP_des_ecb , .Fn EVP_des_cfb , @@ -1241,22 +1251,49 @@ do_crypt(FILE *in, FILE *out, int do_encrypt) .Fn EVP_des_ede3 , .Fn EVP_des_ede3_ofb , .Fn EVP_des_ede3_cfb , -.Fn EVP_desx_cbc , .Fn EVP_rc4 , .Fn EVP_idea_cbc , .Fn EVP_idea_ecb , .Fn EVP_idea_cfb , -.Fn EVP_idea_ofb , +and +.Fn EVP_idea_ofb +first appeared in SSLeay 0.5.1. .Fn EVP_rc2_cbc , .Fn EVP_rc2_ecb , .Fn EVP_rc2_cfb , -.Fn EVP_rc2_ofb , +and +.Fn EVP_rc2_ofb +first appeared in SSLeay 0.5.2. +.Fn EVP_desx_cbc +first appeared in SSLeay 0.6.2. +.Fn EVP_CIPHER_block_size , +.Fn EVP_CIPHER_key_length , +.Fn EVP_CIPHER_iv_length , +.Fn EVP_CIPHER_type , +.Fn EVP_CIPHER_CTX_block_size , +.Fn EVP_CIPHER_CTX_key_length , +.Fn EVP_CIPHER_CTX_iv_length , +and +.Fn EVP_CIPHER_CTX_type +first appeared in SSLeay 0.6.5. .Fn EVP_bf_cbc , .Fn EVP_bf_ecb , .Fn EVP_bf_cfb , and .Fn EVP_bf_ofb -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.6.6. +.Fn EVP_CIPHER_CTX_cleanup , +.Fn EVP_get_cipherbyobj , +.Fn EVP_CIPHER_nid , +.Fn EVP_CIPHER_CTX_cipher , +.Fn EVP_CIPHER_CTX_nid , +.Fn EVP_CIPHER_CTX_get_app_data , +.Fn EVP_CIPHER_CTX_set_app_data , +and +.Fn EVP_enc_null +first appeared in SSLeay 0.8.0. +.Fn EVP_get_cipherbynid +first appeared in SSLeay 0.8.1. .Fn EVP_CIPHER_CTX_init , .Fn EVP_CIPHER_param_to_asn1 , and @@ -1269,7 +1306,7 @@ All these functions have been available since first appeared in SSL_eay 0.9.1. .Fn EVP_CIPHER_CTX_type first appeared in OpenSSL 0.9.3. -These functions and have been available since +These functions have been available since .Ox 2.6 . .Pp .Fn EVP_CIPHER_CTX_set_key_length , @@ -1318,6 +1355,12 @@ first appeared in OpenSSL 1.0.1 and have been available since .Fn EVP_CIPHER_CTX_reset first appeared in OpenSSL 1.1.0 and has been available since .Ox 6.3 . +.Pp +.Fn EVP_CIPHER_CTX_get_iv +and +.Fn EVP_CIPHER_CTX_set_iv +first appeared in LibreSSL 2.8.1 and has been available since +.Ox 6.4 . .Sh BUGS .Dv EVP_MAX_KEY_LENGTH and diff --git a/lib/libcrypto/man/EVP_OpenInit.3 b/lib/libcrypto/man/EVP_OpenInit.3 index 99dc7f28da..d2a723abb6 100644 --- a/lib/libcrypto/man/EVP_OpenInit.3 +++ b/lib/libcrypto/man/EVP_OpenInit.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_OpenInit.3,v 1.6 2018/03/20 23:56:07 schwarze Exp $ +.\" $OpenBSD: EVP_OpenInit.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt EVP_OPENINIT 3 .Os .Sh NAME @@ -151,5 +151,5 @@ returns 0 if the decrypt failed or 1 for success. .Fn EVP_OpenUpdate , and .Fn EVP_OpenFinal -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 b/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 index 5e3901e601..576a2935cb 100644 --- a/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 +++ b/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.2 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.3 2018/05/13 16:42:21 schwarze Exp $ .\" full merge up to: OpenSSL 751148e2 Oct 27 00:11:11 2017 +0200 .\" .\" This file was written by Richard Levitte . @@ -48,12 +48,13 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt EVP_PKEY_ASN1_GET_COUNT 3 .Os .Sh NAME .Nm EVP_PKEY_asn1_get_count , .Nm EVP_PKEY_asn1_get0 , +.Nm EVP_PKEY_get0_asn1 , .Nm EVP_PKEY_asn1_find , .Nm EVP_PKEY_asn1_find_str , .Nm EVP_PKEY_asn1_get0_info @@ -67,6 +68,10 @@ .Fa "int idx" .Fc .Ft const EVP_PKEY_ASN1_METHOD * +.Fo EVP_PKEY_get0_asn1 +.Fa "const EVP_PKEY *pkey" +.Fc +.Ft const EVP_PKEY_ASN1_METHOD * .Fo EVP_PKEY_asn1_find .Fa "ENGINE **pe" .Fa "int type" @@ -152,11 +157,15 @@ if .Fa idx is out of range. .Pp +.Fn EVP_PKEY_get0_asn1 +returns the public key method used by +.Fa pkey . +.Pp .Fn EVP_PKEY_asn1_get0_info returns 1 on success or 0 on failure. .Sh SEE ALSO -.Xr EVP_PKEY_asn1_add0 3 , -.Xr EVP_PKEY_asn1_new 3 +.Xr EVP_PKEY_asn1_new 3 , +.Xr EVP_PKEY_base_id 3 .Sh HISTORY These functions first appeared in OpenSSL 1.0.0 and have been available since diff --git a/lib/libcrypto/man/EVP_PKEY_asn1_new.3 b/lib/libcrypto/man/EVP_PKEY_asn1_new.3 index a0839bd16a..2af7a8248f 100644 --- a/lib/libcrypto/man/EVP_PKEY_asn1_new.3 +++ b/lib/libcrypto/man/EVP_PKEY_asn1_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_asn1_new.3,v 1.2 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_asn1_new.3,v 1.3 2018/05/13 15:53:30 schwarze Exp $ .\" selective merge up to: .\" OpenSSL man3/EVP_PKEY_ASN1_METHOD b0004708 Nov 1 00:45:24 2017 +0800 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt EVP_PKEY_ASN1_METHOD 3 .Os .Sh NAME @@ -256,8 +256,8 @@ It is called by The .Fn pkey_bits method returns the key size in bits. -It's called by -.Fn EVP_PKEY_bits . +It is called by +.Xr EVP_PKEY_bits 3 . .Bd -unfilled .Ft int Fo (*param_decode) .Fa "EVP_PKEY *pkey" diff --git a/lib/libcrypto/man/EVP_PKEY_cmp.3 b/lib/libcrypto/man/EVP_PKEY_cmp.3 index 28484c9022..f4a7d8ea9f 100644 --- a/lib/libcrypto/man/EVP_PKEY_cmp.3 +++ b/lib/libcrypto/man/EVP_PKEY_cmp.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_cmp.3,v 1.8 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_cmp.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt EVP_PKEY_CMP 3 .Os .Sh NAME @@ -148,7 +148,7 @@ are different and -2 if the operation is not supported. .Fn EVP_PKEY_missing_parameters and .Fn EVP_PKEY_copy_parameters -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.8.0. .Fn EVP_PKEY_cmp_parameters first appeared in SSLeay 0.9.0. These functions have been available since diff --git a/lib/libcrypto/man/EVP_PKEY_new.3 b/lib/libcrypto/man/EVP_PKEY_new.3 index ed286ecb31..fade3d5cd2 100644 --- a/lib/libcrypto/man/EVP_PKEY_new.3 +++ b/lib/libcrypto/man/EVP_PKEY_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_new.3,v 1.7 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_new.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 99d63d42 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt EVP_PKEY_NEW 3 .Os .Sh NAME @@ -114,7 +114,7 @@ returns 1 for success or 0 for failure. .Fn EVP_PKEY_new and .Fn EVP_PKEY_free -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . .Pp .Fn EVP_PKEY_up_ref diff --git a/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 b/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 index 6682ea5154..1d79584b25 100644 --- a/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 +++ b/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.12 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.14 2018/05/13 16:44:57 schwarze Exp $ .\" full merge up to: OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt EVP_PKEY_SET1_RSA 3 .Os .Sh NAME @@ -69,8 +69,8 @@ .Nm EVP_PKEY_assign_DSA , .Nm EVP_PKEY_assign_DH , .Nm EVP_PKEY_assign_EC_KEY , -.Nm EVP_PKEY_id , .Nm EVP_PKEY_base_id , +.Nm EVP_PKEY_id , .Nm EVP_PKEY_type .Nd EVP_PKEY assignment functions .Sh SYNOPSIS @@ -148,11 +148,11 @@ .Fa "EC_KEY *key" .Fc .Ft int -.Fo EVP_PKEY_id +.Fo EVP_PKEY_base_id .Fa "EVP_PKEY *pkey" .Fc .Ft int -.Fo EVP_PKEY_base_id +.Fo EVP_PKEY_id .Fa "EVP_PKEY *pkey" .Fc .Ft int @@ -294,6 +294,7 @@ on error. .Xr DH_new 3 , .Xr DSA_new 3 , .Xr EC_KEY_new 3 , +.Xr EVP_PKEY_get0_asn1 3 , .Xr EVP_PKEY_new 3 , .Xr RSA_new 3 .Sh HISTORY @@ -302,7 +303,7 @@ on error. .Fn EVP_PKEY_assign_DH , and .Fn EVP_PKEY_type -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn EVP_PKEY_set1_RSA , diff --git a/lib/libcrypto/man/EVP_SealInit.3 b/lib/libcrypto/man/EVP_SealInit.3 index d8d2b5719a..11db229455 100644 --- a/lib/libcrypto/man/EVP_SealInit.3 +++ b/lib/libcrypto/man/EVP_SealInit.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_SealInit.3,v 1.6 2018/03/20 23:56:07 schwarze Exp $ +.\" $OpenBSD: EVP_SealInit.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt EVP_SEALINIT 3 .Os .Sh NAME @@ -182,7 +182,7 @@ return 1 for success and 0 for failure. .Fn EVP_SealUpdate , and .Fn EVP_SealFinal -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn EVP_SealFinal diff --git a/lib/libcrypto/man/EVP_SignInit.3 b/lib/libcrypto/man/EVP_SignInit.3 index 1c75e332aa..284684104a 100644 --- a/lib/libcrypto/man/EVP_SignInit.3 +++ b/lib/libcrypto/man/EVP_SignInit.3 @@ -1,5 +1,6 @@ -.\" $OpenBSD: EVP_SignInit.3,v 1.7 2018/03/22 21:08:22 schwarze Exp $ -.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" $OpenBSD: EVP_SignInit.3,v 1.11 2018/07/09 09:56:05 tb Exp $ +.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" selective merge up to: OpenSSL 79b49fb0 Mar 20 10:03:10 2018 +1000 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000-2002, 2005, 2006, 2014-2016 The OpenSSL Project. @@ -49,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: July 9 2018 $ .Dt EVP_SIGNINIT 3 .Os .Sh NAME @@ -57,7 +58,8 @@ .Nm EVP_SignUpdate , .Nm EVP_SignFinal , .Nm EVP_SignInit , -.Nm EVP_PKEY_size +.Nm EVP_PKEY_size , +.Nm EVP_PKEY_bits .Nd EVP signing functions .Sh SYNOPSIS .In openssl/evp.h @@ -87,7 +89,11 @@ .Fc .Ft int .Fo EVP_PKEY_size -.Fa "EVP_PKEY *pkey" +.Fa "const EVP_PKEY *pkey" +.Fc +.Ft int +.Fo EVP_PKEY_bits +.Fa "const EVP_PKEY *pkey" .Fc .Sh DESCRIPTION The EVP signature routines are a high level interface to digital @@ -154,11 +160,6 @@ used in preference to the low level interfaces. This is because the code then becomes transparent to the algorithm used and much more flexible. .Pp -Due to the link between message digests and public key algorithms the -correct digest algorithm must be used with the correct public key type. -A list of algorithms and associated public key algorithms appears in -.Xr EVP_DigestInit 3 . -.Pp The call to .Fn EVP_SignFinal internally finalizes a copy of the digest context. @@ -182,6 +183,10 @@ return 1 for success and 0 for failure. .Fn EVP_PKEY_size returns the maximum size of a signature in bytes. .Pp +.Fn EVP_PKEY_bits +returns the number of significant bits in the key +or 0 if an error occurs. +.Pp The error codes can be obtained by .Xr ERR_get_error 3 . .Sh SEE ALSO @@ -193,10 +198,14 @@ The error codes can be obtained by .Sh HISTORY .Fn EVP_SignInit , .Fn EVP_SignUpdate , -.Fn EVP_SignFinal , and +.Fn EVP_SignFinal +first appeared in SSLeay 0.5.1. .Fn EVP_PKEY_size -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.0. +.Fn EVP_PKEY_bits +first appeared in SSLeay 0.9.0. +These functions have been available since .Ox 2.4 . .Pp .Fn EVP_SignInit_ex diff --git a/lib/libcrypto/man/EVP_VerifyInit.3 b/lib/libcrypto/man/EVP_VerifyInit.3 index 701054479d..a3cac95455 100644 --- a/lib/libcrypto/man/EVP_VerifyInit.3 +++ b/lib/libcrypto/man/EVP_VerifyInit.3 @@ -1,5 +1,6 @@ -.\" $OpenBSD: EVP_VerifyInit.3,v 1.6 2018/03/22 21:08:22 schwarze Exp $ -.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" $OpenBSD: EVP_VerifyInit.3,v 1.8 2018/03/29 21:26:51 schwarze Exp $ +.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" selective merge up to: OpenSSL 79b49fb0 Mar 20 10:03:10 2018 +1000 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000, 2001, 2006, 2016 The OpenSSL Project. @@ -49,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 29 2018 $ .Dt EVP_VERIFYINIT 3 .Os .Sh NAME @@ -133,11 +134,6 @@ used in preference to the low level interfaces. This is because the code then becomes transparent to the algorithm used and much more flexible. .Pp -Due to the link between message digests and public key algorithms, the -correct digest algorithm must be used with the correct public key type. -A list of algorithms and associated public key algorithms appears in -.Xr EVP_DigestInit 3 . -.Pp The call to .Fn EVP_VerifyFinal internally finalizes a copy of the digest context. @@ -173,7 +169,7 @@ The error codes can be obtained by .Fn EVP_VerifyUpdate , and .Fn EVP_VerifyFinal -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn EVP_VerifyInit_ex diff --git a/lib/libcrypto/man/MD5.3 b/lib/libcrypto/man/MD5.3 index d216c84803..1e4a628591 100644 --- a/lib/libcrypto/man/MD5.3 +++ b/lib/libcrypto/man/MD5.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: MD5.3,v 1.7 2018/03/22 17:11:04 schwarze Exp $ +.\" $OpenBSD: MD5.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt MD5 3 .Os .Sh NAME @@ -184,7 +184,7 @@ RFC 1320, RFC 1321 .Fn MD5_Update , and .Fn MD5_Final -appeared in SSLeay 0.8.1b or earlier and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Pp .Fn MD4 , diff --git a/lib/libcrypto/man/Makefile b/lib/libcrypto/man/Makefile index 1dd11c8469..15719701a1 100644 --- a/lib/libcrypto/man/Makefile +++ b/lib/libcrypto/man/Makefile @@ -1,9 +1,10 @@ -# $OpenBSD: Makefile,v 1.138 2018/03/18 13:06:36 schwarze Exp $ +# $OpenBSD: Makefile,v 1.142 2018/07/08 23:00:17 schwarze Exp $ .include MAN= \ ACCESS_DESCRIPTION_new.3 \ + ASN1_INTEGER_get.3 \ ASN1_OBJECT_new.3 \ ASN1_STRING_length.3 \ ASN1_STRING_new.3 \ @@ -97,6 +98,17 @@ MAN= \ EC_KEY_new.3 \ EC_POINT_add.3 \ EC_POINT_new.3 \ + ENGINE_add.3 \ + ENGINE_ctrl.3 \ + ENGINE_get_default_RSA.3 \ + ENGINE_init.3 \ + ENGINE_new.3 \ + ENGINE_register_RSA.3 \ + ENGINE_register_all_RSA.3 \ + ENGINE_set_RSA.3 \ + ENGINE_set_default.3 \ + ENGINE_set_flags.3 \ + ENGINE_unregister_RSA.3 \ ERR.3 \ ERR_GET_LIB.3 \ ERR_asprintf_error_data.3 \ @@ -291,7 +303,6 @@ MAN= \ d2i_X509_REQ.3 \ d2i_X509_SIG.3 \ des_read_pw.3 \ - engine.3 \ evp.3 \ get_rfc3526_prime_8192.3 \ i2d_PKCS7_bio_stream.3 \ diff --git a/lib/libcrypto/man/OBJ_nid2obj.3 b/lib/libcrypto/man/OBJ_nid2obj.3 index 68ad643549..f8c395baf9 100644 --- a/lib/libcrypto/man/OBJ_nid2obj.3 +++ b/lib/libcrypto/man/OBJ_nid2obj.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OBJ_nid2obj.3,v 1.10 2018/03/21 21:18:08 schwarze Exp $ +.\" $OpenBSD: OBJ_nid2obj.3,v 1.12 2018/04/25 15:17:52 schwarze Exp $ .\" OpenSSL c264592d May 14 11:28:00 2006 +0000 .\" .\" This file is a derived work. @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt OBJ_NID2OBJ 3 .Os .Sh NAME @@ -149,7 +149,7 @@ .Fo i2t_ASN1_OBJECT .Fa "char *buf" .Fa "int buf_len" -.Fa "ASN1_OBJECT *a" +.Fa "const ASN1_OBJECT *a" .Fc .Sh DESCRIPTION The ASN.1 object utility functions process @@ -378,10 +378,11 @@ obj = OBJ_txt2obj("1.2.3.4", 1); .Fn OBJ_sn2nid , .Fn OBJ_txt2nid , .Fn OBJ_cmp , -.Fn OBJ_dup , and +.Fn OBJ_dup +first appeared in SSLeay 0.5.1. .Fn OBJ_cleanup -appeared in SSLeay 0.8.1b or earlier. +first appeared in SSLeay 0.8.0. .Fn OBJ_create and .Fn i2t_ASN1_OBJECT diff --git a/lib/libcrypto/man/OCSP_CRLID_new.3 b/lib/libcrypto/man/OCSP_CRLID_new.3 index 0eebec5f92..ff0819166e 100644 --- a/lib/libcrypto/man/OCSP_CRLID_new.3 +++ b/lib/libcrypto/man/OCSP_CRLID_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OCSP_CRLID_new.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: OCSP_CRLID_new.3,v 1.6 2018/05/13 14:36:05 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt OCSP_CRLID_NEW 3 .Os .Sh NAME @@ -30,7 +30,7 @@ .Fn OCSP_CRLID_free "OCSP_CRLID *crlid" .Ft X509_EXTENSION * .Fo OCSP_crlID_new -.Fa "char *url" +.Fa "const char *url" .Fa "long *number" .Fa "char *time" .Fc @@ -102,7 +102,7 @@ Status Protocol, section 4.4.2: CRL References .Fn OCSP_CRLID_free , and .Fn OCSP_crlID_new -first appeared in OpenSSL 0.9.7 and has been available since +first appeared in OpenSSL 0.9.7 and have been available since .Ox 3.2 . .Sh CAVEATS The function names diff --git a/lib/libcrypto/man/OCSP_SERVICELOC_new.3 b/lib/libcrypto/man/OCSP_SERVICELOC_new.3 index 6900493f0e..febd71699b 100644 --- a/lib/libcrypto/man/OCSP_SERVICELOC_new.3 +++ b/lib/libcrypto/man/OCSP_SERVICELOC_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OCSP_SERVICELOC_new.3,v 1.6 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: OCSP_SERVICELOC_new.3,v 1.7 2018/05/13 14:36:05 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt OCSP_SERVICELOC_NEW 3 .Os .Sh NAME @@ -31,7 +31,7 @@ .Ft X509_EXTENSION * .Fo OCSP_url_svcloc_new .Fa "X509_NAME *issuer" -.Fa "char **urls" +.Fa "const char **urls" .Fc .Sh DESCRIPTION Due to restrictions of network routing, a client may be unable to diff --git a/lib/libcrypto/man/OCSP_cert_to_id.3 b/lib/libcrypto/man/OCSP_cert_to_id.3 index 0ccb4412df..2b8c23715f 100644 --- a/lib/libcrypto/man/OCSP_cert_to_id.3 +++ b/lib/libcrypto/man/OCSP_cert_to_id.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OCSP_cert_to_id.3,v 1.7 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: OCSP_cert_to_id.3,v 1.9 2018/08/24 20:04:10 tb Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: August 24 2018 $ .Dt OCSP_CERT_TO_ID 3 .Os .Sh NAME @@ -86,15 +86,15 @@ .Ft OCSP_CERTID * .Fo OCSP_cert_to_id .Fa "const EVP_MD *dgst" -.Fa "X509 *subject" -.Fa "X509 *issuer" +.Fa "const X509 *subject" +.Fa "const X509 *issuer" .Fc .Ft OCSP_CERTID * .Fo OCSP_cert_id_new .Fa "const EVP_MD *dgst" -.Fa "X509_NAME *issuerName" -.Fa "ASN1_BIT_STRING *issuerKey" -.Fa "ASN1_INTEGER *serialNumber" +.Fa "const X509_NAME *issuerName" +.Fa "const ASN1_BIT_STRING *issuerKey" +.Fa "const ASN1_INTEGER *serialNumber" .Fc .Ft int .Fo OCSP_id_issuer_cmp diff --git a/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3 b/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3 index 46f8083ab3..77bb6d4554 100644 --- a/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3 +++ b/lib/libcrypto/man/OPENSSL_VERSION_NUMBER.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OPENSSL_VERSION_NUMBER.3,v 1.9 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: OPENSSL_VERSION_NUMBER.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 1f13ad31 Dec 25 17:50:39 2017 +0800 .\" .\" This file is a derived work. @@ -68,7 +68,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt OPENSSL_VERSION_NUMBER 3 .Os .Sh NAME @@ -248,7 +248,7 @@ return pointers to static strings. .Fn SSLeay_version , and .Dv SSLEAY_VERSION_NUMBER -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . .Pp .Dv OPENSSL_VERSION_NUMBER @@ -257,7 +257,8 @@ and has been available since .Ox 2.6 . .Pp .Dv SSLEAY_DIR -was added in OpenSSL 0.9.7. +first appeared in OpenSSL 0.9.7 and have been available since +.Ox 3.2 . .Pp .Dv LIBRESSL_VERSION_NUMBER first appeared in LibreSSL 2.0.0 and diff --git a/lib/libcrypto/man/OPENSSL_config.3 b/lib/libcrypto/man/OPENSSL_config.3 index 3114e6c086..c2b5b38e11 100644 --- a/lib/libcrypto/man/OPENSSL_config.3 +++ b/lib/libcrypto/man/OPENSSL_config.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OPENSSL_config.3,v 1.10 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: OPENSSL_config.3,v 1.12 2018/04/07 20:47:40 jmc Exp $ .\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: April 7 2018 $ .Dt OPENSSL_CONFIG 3 .Os .Sh NAME @@ -104,9 +104,13 @@ Further calls to have no effect. .Pp .Fn OPENSSL_no_config -has no effect except that later calls to +suppresses the loading of any configuration file, so that any +future calls to .Fn OPENSSL_config -will be ignored. +or to +.Xr OPENSSL_init_crypto 3 +will ensure the library is initialized but no configuration +file will be loaded. .Pp Calling these functions is optional. All required initialization of the crypto libraries happens diff --git a/lib/libcrypto/man/OPENSSL_malloc.3 b/lib/libcrypto/man/OPENSSL_malloc.3 index ae5e9c904f..1b2ec55cf3 100644 --- a/lib/libcrypto/man/OPENSSL_malloc.3 +++ b/lib/libcrypto/man/OPENSSL_malloc.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OPENSSL_malloc.3,v 1.7 2018/03/23 02:20:16 schwarze Exp $ +.\" $OpenBSD: OPENSSL_malloc.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt OPENSSL_MALLOC 3 .Os .Sh NAME @@ -91,7 +91,7 @@ standard functions. .Fn CRYPTO_realloc , and .Fn CRYPTO_free -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.4 and have been available since .Ox 2.4 . .Pp .Fn OPENSSL_malloc , diff --git a/lib/libcrypto/man/OPENSSL_sk_new.3 b/lib/libcrypto/man/OPENSSL_sk_new.3 index e625f3398e..ff199d4ab2 100644 --- a/lib/libcrypto/man/OPENSSL_sk_new.3 +++ b/lib/libcrypto/man/OPENSSL_sk_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OPENSSL_sk_new.3,v 1.7 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: OPENSSL_sk_new.3,v 1.10 2018/08/08 18:21:02 tb Exp $ .\" .\" Copyright (c) 2018 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: August 8 2018 $ .Dt OPENSSL_SK_NEW 3 .Os .Sh NAME @@ -147,7 +147,7 @@ are not type safe but only handle function arguments and return values. .Pp OpenSSL also provides a fragile, unusually complicated system of -macro-generates wrappers that offers superficial type safety at the +macro-generated wrappers that offers superficial type safety at the expense of extensive obfuscation, implemented using large amounts of autogenerated code involving exceedingly ugly, nested .Xr cpp 1 @@ -279,8 +279,9 @@ or successfuly calling .Fn sk_push , .Fn sk_unshift , -or .Fn sk_insert , +or +.Fn sk_set , or changing the comparison function sets the state to unsorted. If a comparison function is installed, calling .Fn sk_sort , @@ -527,8 +528,6 @@ if it is not found. .Sh HISTORY .Fn sk_new_null , .Fn sk_new , -.Fn sk_set_cmp_func , -.Fn sk_dup , .Fn sk_free , .Fn sk_pop_free , .Fn sk_num , @@ -540,10 +539,15 @@ if it is not found. .Fn sk_pop , .Fn sk_shift , .Fn sk_delete , -.Fn sk_delete_ptr , +and +.Fn sk_delete_ptr +first appeared in SSLeay 0.5.1. +.Fn sk_set_cmp_func , +.Fn sk_dup , and .Fn sk_zero -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Pp .Fn sk_set @@ -553,10 +557,6 @@ first appeared in OpenSSL 0.9.4. Both functions have been available since .Ox 2.6 . .Pp -.Fn sk_new_null -first appeared in OpenSSL 0.9.6 and has been available since -.Ox 2.9 . -.Pp .Fn sk_is_sorted first appeared in OpenSSL 0.9.7e and has been available since .Ox 3.8 . @@ -565,15 +565,6 @@ first appeared in OpenSSL 0.9.7e and has been available since first appeared in OpenSSL 0.9.8 and has been available since .Ox 4.5 . .Sh BUGS -.Fn sk_set -does not set the state of the -.Fa stack -to unsorted. -This can cause wrong results from subsequent -.Fn sk_find -and -.Fn sk_find_ex . -.Pp Even if a comparison function is installed, empty stacks and stacks containing a single pointer are sometimes considered sorted and sometimes considered unsorted. diff --git a/lib/libcrypto/man/OpenSSL_add_all_algorithms.3 b/lib/libcrypto/man/OpenSSL_add_all_algorithms.3 index 6cc4a2770c..aa884d8eff 100644 --- a/lib/libcrypto/man/OpenSSL_add_all_algorithms.3 +++ b/lib/libcrypto/man/OpenSSL_add_all_algorithms.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.6 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt OPENSSL_ADD_ALL_ALGORITHMS 3 .Os .Sh NAME @@ -105,7 +105,7 @@ and precursor functions .Fn SSLeay_add_all_ciphers , and .Fn SSLeay_add_all_digests -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn OpenSSL_add_all_algorithms , diff --git a/lib/libcrypto/man/PEM_read.3 b/lib/libcrypto/man/PEM_read.3 index f234bc6588..48ff4157c7 100644 --- a/lib/libcrypto/man/PEM_read.3 +++ b/lib/libcrypto/man/PEM_read.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: PEM_read.3,v 1.4 2018/03/21 00:37:32 schwarze Exp $ +.\" $OpenBSD: PEM_read.3,v 1.6 2018/05/13 14:44:14 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Viktor Dukhovni @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt PEM_READ 3 .Os .Sh NAME @@ -65,17 +65,17 @@ .Ft int .Fo PEM_write .Fa "FILE *fp" -.Fa "char *name" -.Fa "char *header" -.Fa "unsigned char *data" +.Fa "const char *name" +.Fa "const char *header" +.Fa "const unsigned char *data" .Fa "long len" .Fc .Ft int .Fo PEM_write_bio .Fa "BIO *bp" .Fa "const char *name" -.Fa "char *header" -.Fa "unsigned char *data" +.Fa "const char *header" +.Fa "ocnst unsigned char *data" .Fa "long len" .Fc .Ft int @@ -283,6 +283,16 @@ is likely meaningless if these functions fail. .Xr PEM_bytes_read_bio 3 , .Xr PEM_read_bio_PrivateKey 3 .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier -and have been available since +.Fn PEM_write , +.Fn PEM_read , +and +.Fn PEM_do_header +appeared in SSLeay 0.4 or earlier. +.Fn PEM_get_EVP_CIPHER_INFO +first appeared in SSLeay 0.5.1. +.Fn PEM_write_bio +and +.Fn PEM_read_bio +first appeared in SSLeay 0.6.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 b/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 index 0dc167929c..1fa4d75ead 100644 --- a/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 +++ b/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.12 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.13 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt PEM_READ_BIO_PRIVATEKEY 3 .Os .Sh NAME @@ -1217,48 +1217,59 @@ pass_cb(char *buf, int size, int rwflag, void *u) .Xr PEM_bytes_read_bio 3 , .Xr PEM_read 3 .Sh HISTORY +.Fn PEM_read_X509 +and +.Fn PEM_write_X509 +appeared in SSLeay 0.4 or earlier. +.Fn PEM_read_X509_REQ , +.Fn PEM_write_X509_REQ , +.Fn PEM_read_X509_CRL , +and +.Fn PEM_write_X509_CRL +first appeared in SSLeay 0.4.4. +.Fn PEM_read_RSAPrivateKey , +.Fn PEM_write_RSAPrivateKey , +.Fn PEM_read_DHparams , +.Fn PEM_write_DHparams , +.Fn PEM_read_PKCS7 , +and +.Fn PEM_write_PKCS7 +first appeared in SSLeay 0.5.1. .Fn PEM_read_bio_PrivateKey , .Fn PEM_read_PrivateKey , -.Fn PEM_write_bio_PrivateKey , -.Fn PEM_write_PrivateKey , .Fn PEM_read_bio_RSAPrivateKey , -.Fn PEM_read_RSAPrivateKey , .Fn PEM_write_bio_RSAPrivateKey , -.Fn PEM_write_RSAPrivateKey , -.Fn PEM_read_bio_RSAPublicKey , -.Fn PEM_read_RSAPublicKey , -.Fn PEM_write_bio_RSAPublicKey , -.Fn PEM_write_RSAPublicKey , .Fn PEM_read_bio_DSAPrivateKey , .Fn PEM_read_DSAPrivateKey , .Fn PEM_write_bio_DSAPrivateKey , .Fn PEM_write_DSAPrivateKey , -.Fn PEM_read_bio_DSAparams , -.Fn PEM_read_DSAparams , -.Fn PEM_write_bio_DSAparams , -.Fn PEM_write_DSAparams , .Fn PEM_read_bio_DHparams , -.Fn PEM_read_DHparams , .Fn PEM_write_bio_DHparams , -.Fn PEM_write_DHparams , .Fn PEM_read_bio_X509 , -.Fn PEM_read_X509 , .Fn PEM_write_bio_X509 , -.Fn PEM_write_X509 , .Fn PEM_read_bio_X509_REQ , -.Fn PEM_read_X509_REQ , .Fn PEM_write_bio_X509_REQ , -.Fn PEM_write_X509_REQ , .Fn PEM_read_bio_X509_CRL , -.Fn PEM_read_X509_CRL , .Fn PEM_write_bio_X509_CRL , -.Fn PEM_write_X509_CRL , .Fn PEM_read_bio_PKCS7 , -.Fn PEM_read_PKCS7 , -.Fn PEM_write_bio_PKCS7 , and -.Fn PEM_write_PKCS7 -appeared in SSLeay 0.8.1b or earlier and have been available since +.Fn PEM_write_bio_PKCS7 +first appeared in SSLeay 0.6.0. +.Fn PEM_write_bio_PrivateKey , +.Fn PEM_write_PrivateKey , +.Fn PEM_read_bio_DSAparams , +.Fn PEM_read_DSAparams , +.Fn PEM_write_bio_DSAparams , +and +.Fn PEM_write_DSAparams +first appeared in SSLeay 0.8.0. +.Fn PEM_read_bio_RSAPublicKey , +.Fn PEM_read_RSAPublicKey , +.Fn PEM_write_bio_RSAPublicKey , +and +.Fn PEM_write_RSAPublicKey +first appeared in SSLeay 0.8.1. +All these functions have been available since .Ox 2.4 . .Pp .Fn PEM_write_bio_PKCS8PrivateKey , @@ -1275,7 +1286,7 @@ appeared in SSLeay 0.8.1b or earlier and have been available since .Fn PEM_read_NETSCAPE_CERT_SEQUENCE , .Fn PEM_write_bio_NETSCAPE_CERT_SEQUENCE , and -.Fn PEM_write_NETSCAPE_CERT_SEQUENCE , +.Fn PEM_write_NETSCAPE_CERT_SEQUENCE first appeared in OpenSSL 0.9.4 and have been available since .Ox 2.6 . .Pp diff --git a/lib/libcrypto/man/PKCS12_create.3 b/lib/libcrypto/man/PKCS12_create.3 index 1241655ad5..67c814182c 100644 --- a/lib/libcrypto/man/PKCS12_create.3 +++ b/lib/libcrypto/man/PKCS12_create.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: PKCS12_create.3,v 1.6 2018/03/21 17:57:48 schwarze Exp $ +.\" $OpenBSD: PKCS12_create.3,v 1.7 2018/05/13 14:52:23 schwarze Exp $ .\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt PKCS12_CREATE 3 .Os .Sh NAME @@ -59,8 +59,8 @@ .In openssl/pkcs12.h .Ft PKCS12 * .Fo PKCS12_create -.Fa "char *pass" -.Fa "char *name" +.Fa "const char *pass" +.Fa "const char *name" .Fa "EVP_PKEY *pkey" .Fa "X509 *cert" .Fa "STACK_OF(X509) *ca" diff --git a/lib/libcrypto/man/PKCS7_new.3 b/lib/libcrypto/man/PKCS7_new.3 index 7094b08345..8d1c01edcd 100644 --- a/lib/libcrypto/man/PKCS7_new.3 +++ b/lib/libcrypto/man/PKCS7_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: PKCS7_new.3,v 1.3 2018/03/21 00:54:31 schwarze Exp $ +.\" $OpenBSD: PKCS7_new.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt PKCS7_NEW 3 .Os .Sh NAME @@ -254,6 +254,6 @@ frees .Sh STANDARDS RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5 .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier +These functions first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/RAND_add.3 b/lib/libcrypto/man/RAND_add.3 index 7fd955dde6..5404f696a3 100644 --- a/lib/libcrypto/man/RAND_add.3 +++ b/lib/libcrypto/man/RAND_add.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RAND_add.3,v 1.9 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: RAND_add.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ .\" content checked up to: OpenSSL c16de9d8 Aug 31 23:16:22 2017 +0200 .\" .\" Copyright (c) 2014 Miod Vallat @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RAND_ADD 3 .Os .Sh NAME @@ -59,7 +59,7 @@ always return 1. .Fn RAND_cleanup and .Fn RAND_seed -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn RAND_add diff --git a/lib/libcrypto/man/RAND_bytes.3 b/lib/libcrypto/man/RAND_bytes.3 index 29dcc0aaa2..19427a82df 100644 --- a/lib/libcrypto/man/RAND_bytes.3 +++ b/lib/libcrypto/man/RAND_bytes.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RAND_bytes.3,v 1.5 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: RAND_bytes.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RAND_BYTES 3 .Os .Sh NAME @@ -98,7 +98,7 @@ returns 1. returns 1. .Sh HISTORY .Fn RAND_bytes -appeared in SSLeay 0.8.1b or earlier and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . It has a return value since OpenSSL 0.9.5 and .Ox 2.7 . diff --git a/lib/libcrypto/man/RAND_load_file.3 b/lib/libcrypto/man/RAND_load_file.3 index 2378b79a21..9227e2721b 100644 --- a/lib/libcrypto/man/RAND_load_file.3 +++ b/lib/libcrypto/man/RAND_load_file.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RAND_load_file.3,v 1.5 2018/03/21 01:02:06 schwarze Exp $ +.\" $OpenBSD: RAND_load_file.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RAND_LOAD_FILE 3 .Os .Sh NAME @@ -115,5 +115,5 @@ on error. .Fn RAND_write_file , and .Fn RAND_file_name -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/RC4.3 b/lib/libcrypto/man/RC4.3 index 4c73a02110..b8a5cc2120 100644 --- a/lib/libcrypto/man/RC4.3 +++ b/lib/libcrypto/man/RC4.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RC4.3,v 1.5 2018/03/21 01:05:25 schwarze Exp $ +.\" $OpenBSD: RC4.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RC4 3 .Os .Sh NAME @@ -124,7 +124,7 @@ do not return values. .Fn RC4_set_key and .Fn RC4 -appeared in SSLeay 0.8.1b or earlier and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Sh BUGS This cipher is broken and should no longer be used. diff --git a/lib/libcrypto/man/RSA_generate_key.3 b/lib/libcrypto/man/RSA_generate_key.3 index 3461b86512..3ac3885f13 100644 --- a/lib/libcrypto/man/RSA_generate_key.3 +++ b/lib/libcrypto/man/RSA_generate_key.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_generate_key.3,v 1.10 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: RSA_generate_key.3,v 1.11 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL RSA_generate_key.pod bb6c5e7f Feb 5 10:29:22 2017 -0500 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RSA_GENERATE_KEY 3 .Os .Sh NAME @@ -147,7 +147,7 @@ The error codes can be obtained by .Xr RSA_new 3 .Sh HISTORY .Fn RSA_generate_key -appeared before SSLeay 0.8 and had its +appeared in SSLeay 0.4 or earlier and had its .Fa cb_arg argument added in SSLeay 0.9.0. It has been available since diff --git a/lib/libcrypto/man/RSA_meth_new.3 b/lib/libcrypto/man/RSA_meth_new.3 index ae3ca88adb..137e0cad87 100644 --- a/lib/libcrypto/man/RSA_meth_new.3 +++ b/lib/libcrypto/man/RSA_meth_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_meth_new.3,v 1.1 2018/03/18 13:06:36 schwarze Exp $ +.\" $OpenBSD: RSA_meth_new.3,v 1.3 2018/09/12 15:09:22 jmc Exp $ .\" selective merge up to: OpenSSL a970b14f Jul 31 18:58:40 2017 -0400 .\" .\" This file is a derived work. @@ -65,13 +65,15 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 18 2018 $ +.Dd $Mdocdate: September 12 2018 $ .Dt RSA_METH_NEW 3 .Os .Sh NAME .Nm RSA_meth_new , -.Nm RSA_meth_free , .Nm RSA_meth_dup , +.Nm RSA_meth_free , +.Nm RSA_meth_get_finish , +.Nm RSA_meth_set1_name , .Nm RSA_meth_set_finish , .Nm RSA_meth_set_priv_enc , .Nm RSA_meth_set_priv_dec @@ -83,15 +85,22 @@ .Fa "const char *name" .Fa "int flags" .Fc +.Ft RSA_METHOD * +.Fo RSA_meth_dup +.Fa "const RSA_METHOD *meth" +.Fc .Ft void .Fo RSA_meth_free .Fa "RSA_METHOD *meth" .Fc -.Ft RSA_METHOD * -.Fo RSA_meth_dup -.Fa "const RSA_METHOD *meth" +.Ft int +.Fo RSA_meth_set1_name +.Fa "RSA_METHOD *meth" +.Fa "const char *name" .Fc .Ft int +.Fn "(*RSA_meth_get_finish(const RSA_METHOD *meth))" "RSA *rsa" +.Ft int .Fo RSA_meth_set_finish .Fa "RSA_METHOD *meth" .Fa "int (*finish)(RSA *rsa)" @@ -142,8 +151,18 @@ destroys .Fa meth and frees any memory associated with it. .Pp +.Fn RSA_meth_set1_name +Stores a copy of the NUL-terminated +.Fa name +in the +.Vt RSA_METHOD +object after freeing the previously stored +.Fa name . +.Pp +.Fn RSA_meth_get_finish +and .Fn RSA_meth_set_finish -sets an optional function for destroying an +get and set an optional function for destroying an .Vt RSA object. Unless @@ -180,7 +199,7 @@ object or on failure. .Pp All -.Fn RSA_meth_set_* +.Fn RSA_meth_set* functions return 1 on success or 0 on failure. .Sh SEE ALSO .Xr RSA_new 3 , @@ -188,6 +207,11 @@ functions return 1 on success or 0 on failure. .Xr RSA_private_encrypt 3 , .Xr RSA_set_method 3 .Sh HISTORY -These functions first appeared in OpenSSL 1.1.0 -and have been available since +These functions first appeared in OpenSSL 1.1.0. +.Fn RSA_meth_get_finish +and +.Fn RSA_meth_set1_name +have been available since +.Ox 6.4 , +all the other functions since .Ox 6.3 . diff --git a/lib/libcrypto/man/RSA_new.3 b/lib/libcrypto/man/RSA_new.3 index 58ddf5a773..0b6bcf9740 100644 --- a/lib/libcrypto/man/RSA_new.3 +++ b/lib/libcrypto/man/RSA_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_new.3,v 1.7 2018/03/21 01:27:25 schwarze Exp $ +.\" $OpenBSD: RSA_new.3,v 1.10 2018/04/18 01:11:45 schwarze Exp $ .\" OpenSSL doc/man3/RSA_new.pod 99d63d46 Oct 26 13:56:48 2016 -0400 .\" OpenSSL doc/crypto/rsa.pod 35d2e327 Jun 3 16:19:49 2016 -0400 .\" @@ -49,17 +49,22 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 18 2018 $ .Dt RSA_NEW 3 .Os .Sh NAME .Nm RSA_new , +.Nm RSA_up_ref , .Nm RSA_free .Nd allocate and free RSA objects .Sh SYNOPSIS .In openssl/rsa.h .Ft RSA * .Fn RSA_new void +.Ft int +.Fo RSA_up_ref +.Fa "RSA *rsa" +.Fc .Ft void .Fo RSA_free .Fa "RSA *rsa" @@ -71,12 +76,19 @@ as defined in PKCS #1 v2.0 (RFC 2437). .Fn RSA_new allocates and initializes an .Vt RSA -structure. +structure, setting the reference count to 1. It is equivalent to calling -.Fn RSA_new_method NULL . +.Xr RSA_new_method 3 +with a +.Dv NULL +argument. +.Pp +.Fn RSA_up_ref +increments the reference count by 1. .Pp .Fn RSA_free -frees the +decrements the reference count by 1. +If it reaches 0, it frees the .Vt RSA structure and its components. The key is erased before the memory is returned to the system. @@ -93,7 +105,7 @@ structure consists of several components. It can contain public as well as private RSA keys: .Bd -literal -typdef struct { +typedef struct { BIGNUM *n; // public modulus BIGNUM *e; // public exponent BIGNUM *d; // private exponent @@ -149,12 +161,14 @@ returns and sets an error code that can be obtained by .Xr ERR_get_error 3 . Otherwise it returns a pointer to the newly allocated structure. +.Pp +.Fn RSA_up_ref +returns 1 for success or 0 for failure. .Sh SEE ALSO .Xr BN_new 3 , .Xr d2i_RSAPublicKey 3 , .Xr DH_new 3 , .Xr DSA_new 3 , -.Xr engine 3 , .Xr ERR_get_error 3 , .Xr EVP_PKEY_set1_RSA 3 , .Xr RSA_blinding_on 3 , @@ -179,5 +193,9 @@ RSA was covered by a US patent which expired in September 2000. .Fn RSA_new and .Fn RSA_free -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . +.Pp +.Fn RSA_up_ref +first appeared in OpenSSL 0.9.7 and has been available since +.Ox 3.2 . diff --git a/lib/libcrypto/man/RSA_print.3 b/lib/libcrypto/man/RSA_print.3 index 4368242e6b..1a8dc86f0c 100644 --- a/lib/libcrypto/man/RSA_print.3 +++ b/lib/libcrypto/man/RSA_print.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_print.3,v 1.7 2018/03/20 22:22:10 schwarze Exp $ +.\" $OpenBSD: RSA_print.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RSA_PRINT 3 .Os .Sh NAME @@ -128,17 +128,16 @@ These functions return 1 on success or 0 on error. .Xr RSA_get0_key 3 , .Xr RSA_new 3 .Sh HISTORY -.Fn RSA_print , +.Fn RSA_print +and +.Fn DHparams_print +first appeared in SSLeay 0.5.1. .Fn RSA_print_fp , .Fn DSA_print , -.Fn DSA_print_fp , -.Fn DHparams_print , and .Fn DHparams_print_fp -appeared before SSLeay 0.8. -.Fn DSAparams_print -and -.Fn DSAparams_print_fp -first appeared in SSLeay 0.8. +first appeared in SSLeay 0.6.0. +.Fn DSA_print_fp +first appeared in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/RSA_private_encrypt.3 b/lib/libcrypto/man/RSA_private_encrypt.3 index 34c0535ddc..524986b03f 100644 --- a/lib/libcrypto/man/RSA_private_encrypt.3 +++ b/lib/libcrypto/man/RSA_private_encrypt.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_private_encrypt.3,v 1.8 2018/03/21 01:27:25 schwarze Exp $ +.\" $OpenBSD: RSA_private_encrypt.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL RSA_private_encrypt.pod b41f6b64 Mar 10 15:49:04 2017 +0000 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RSA_PRIVATE_ENCRYPT 3 .Os .Sh NAME @@ -144,11 +144,8 @@ On error, -1 is returned; the error codes can be obtained by .Fn RSA_private_encrypt and .Fn RSA_public_decrypt -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Pp -The -.Fa padding -argument was added in SSLeay 0.8. .Dv RSA_NO_PADDING is available since SSLeay 0.9.0. diff --git a/lib/libcrypto/man/RSA_public_encrypt.3 b/lib/libcrypto/man/RSA_public_encrypt.3 index de62d816b2..97d325ff29 100644 --- a/lib/libcrypto/man/RSA_public_encrypt.3 +++ b/lib/libcrypto/man/RSA_public_encrypt.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_public_encrypt.3,v 1.10 2018/03/21 01:27:25 schwarze Exp $ +.\" $OpenBSD: RSA_public_encrypt.3,v 1.11 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL RSA_public_encrypt.pod 1e3f62a3 Jul 17 16:47:13 2017 +0200 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RSA_PUBLIC_ENCRYPT 3 .Os .Sh NAME @@ -152,12 +152,9 @@ SSL, PKCS #1 v2.0 .Fn RSA_public_encrypt and .Fn RSA_private_decrypt -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Pp -The -.Fa padding -argument was added in SSLeay 0.8. .Dv RSA_NO_PADDING is available since SSLeay 0.9.0. OAEP was added in OpenSSL 0.9.2b. diff --git a/lib/libcrypto/man/RSA_set_method.3 b/lib/libcrypto/man/RSA_set_method.3 index e54e7b5d7e..b4724e3e6d 100644 --- a/lib/libcrypto/man/RSA_set_method.3 +++ b/lib/libcrypto/man/RSA_set_method.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_set_method.3,v 1.10 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: RSA_set_method.3,v 1.12 2018/04/18 01:07:38 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: April 18 2018 $ .Dt RSA_SET_METHOD 3 .Os .Sh NAME @@ -59,7 +59,6 @@ .Nm RSA_set_method , .Nm RSA_get_method , .Nm RSA_PKCS1_SSLeay , -.Nm RSA_null_method , .Nm RSA_flags , .Nm RSA_new_method .Nd select RSA method @@ -69,78 +68,65 @@ .Fo RSA_set_default_method .Fa "const RSA_METHOD *meth" .Fc -.Ft RSA_METHOD * +.Ft const RSA_METHOD * .Fn RSA_get_default_method void .Ft int .Fo RSA_set_method .Fa "RSA *rsa" .Fa "const RSA_METHOD *meth" .Fc -.Ft RSA_METHOD * +.Ft const RSA_METHOD * .Fo RSA_get_method .Fa "const RSA *rsa" .Fc -.Ft RSA_METHOD * +.Ft const RSA_METHOD * .Fn RSA_PKCS1_SSLeay void -.Ft RSA_METHOD * -.Fn RSA_null_method void .Ft int .Fo RSA_flags .Fa "const RSA *rsa" .Fc .Ft RSA * .Fo RSA_new_method -.Fa "RSA_METHOD *meth" +.Fa "ENGINE *engine" .Fc .Sh DESCRIPTION An .Vt RSA_METHOD -specifies the functions that OpenSSL uses for RSA operations. -By modifying the method, alternative implementations such as hardware -accelerators may be used. -See the -.Sx CAVEATS -section for how these RSA API functions are affected by the use of -.Xr engine 3 -API calls. -.Pp -Initially, the default -.Vt RSA_METHOD -is the OpenSSL internal implementation, as returned by -.Fn RSA_PKCS1_SSLeay . +object contains pointers to the functions used for RSA operations. +By default, the internal implementation returned by +.Fn RSA_PKCS1_SSLeay +is used. +By selecting another method, alternative implementations +such as hardware accelerators may be used. .Pp .Fn RSA_set_default_method -makes +selects .Fa meth -the default method for all +as the default method for all .Vt RSA structures created later. -.Sy NB : -This is true only whilst no +If any .Vt ENGINE -has been set as a default for RSA, so this function is no longer -recommended. +was registered with +.Xr ENGINE_register_RSA 3 +that can be successfully initialized, it overrides the default. .Pp .Fn RSA_get_default_method -returns a pointer to the current default -.Vt RSA_METHOD . -However, the meaningfulness of this result is dependent on whether -the -.Xr engine 3 -API is being used, so this function is no longer recommended. +returns a pointer to the current default method, +even if it is actually overridded by an +.Vt ENGINE . .Pp .Fn RSA_set_method selects .Fa meth to perform all operations using the key .Fa rsa . -This will replace the +This replaces the .Vt RSA_METHOD used by the RSA key, and if the previous method was supplied by an .Vt ENGINE , -the handle to that -.Vt ENGINE -will be released during the change. +.Xr ENGINE_finish 3 +is called on it. It is possible to have RSA keys that only work with certain .Vt RSA_METHOD implementations (e.g. from an @@ -175,34 +161,23 @@ section. allocates and initializes an .Vt RSA structure so that -.Fa meth -will be used for the RSA operations. +.Fa engine +is used for the RSA operations. If -.Sy engine -is NULL, the default ENGINE for RSA operations is used and, if no -default ENGINE is set, the RSA_METHOD controlled by +.Fa engine +is +.Dv NULL , +.Xr ENGINE_get_default_RSA 3 +is used. +If that returns +.Dv NULL , +the default method controlled by .Fn RSA_set_default_method is used. .Pp -.Fn RSA_flags -returns the -.Sy flags -that are set for -.Fa rsa Ns 's -current method. -.Pp -.Fn RSA_new_method -allocates and initializes an -.Vt RSA -structure so that -.Fa meth -will be used for the RSA operations. -If -.Fa meth -is -.Dv NULL , -the default method is used. -.Sh THE RSA_METHOD STRUCTURE +The +.Dv RSA_METHOD +structure is defined as follows: .Bd -literal typedef struct rsa_meth_st { @@ -265,30 +240,15 @@ typedef struct rsa_meth_st .Ed .Sh RETURN VALUES .Fn RSA_PKCS1_SSLeay , -.Fn RSA_null_method , -.Fn RSA_get_default_method +.Fn RSA_get_default_method , and .Fn RSA_get_method return pointers to the respective .Vt RSA_METHOD . .Pp .Fn RSA_set_method -returns a pointer to the old -.Vt RSA_METHOD -implementation that was replaced. -However, this return value should probably be ignored because if it was -supplied by an -.Vt ENGINE , -the pointer could be invalidated at any time if the -.Vt ENGINE -is unloaded. -In fact, it could be unloaded as a result of the -.Fn RSA_set_method -function releasing its handle to the -.Vt ENGINE . -For this reason, the return type may be replaced with a -.Vt void -declaration in a future release. +returns 1 on success or 0 on failure. +Currently, it cannot fail. .Pp .Fn RSA_new_method returns @@ -298,15 +258,17 @@ and sets an error code that can be obtained by if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. .Sh SEE ALSO +.Xr ENGINE_get_default_RSA 3 , +.Xr ENGINE_register_RSA 3 , +.Xr ENGINE_set_default_RSA 3 , .Xr RSA_meth_new 3 , .Xr RSA_new 3 .Sh HISTORY -.Fn RSA_PKCS1_SSLeay -appeared before SSLeay 0.8. -.Fn RSA_new_method +.Fn RSA_set_default_method , +.Fn RSA_PKCS1_SSLeay , and -.Fn RSA_set_default_method -first appeared in SSLeay 0.8. +.Fn RSA_new_method +first appeared in SSLeay 0.8.0. .Fn RSA_flags first appeared in SSLeay 0.9.0. These functions have been available since @@ -324,31 +286,6 @@ components of .Vt RSA_METHOD first appeared in OpenSSL 0.9.4 and have been available since .Ox 2.6 . -.Pp -.Fn RSA_null_method -first appeared in OpenSSL 0.9.5 and has been available since -.Ox 2.7 . -.Sh CAVEATS -As of version 0.9.7, -.Vt RSA_METHOD -implementations are grouped together with other algorithmic APIs (e.g.\& -.Vt DSA_METHOD -or -.Vt EVP_CIPHER ) -into -.Vt ENGINE -modules. -If a default -.Vt ENGINE -is specified for RSA functionality using an -.Xr engine 3 -API function, that will override any RSA defaults set using the RSA -API, i.e.\& -.Fn RSA_set_default_method . -For this reason, the -.Xr engine 3 -API is the recommended way to control default implementations for -use in RSA and other cryptographic algorithms. .Sh BUGS The behaviour of .Fn RSA_flags diff --git a/lib/libcrypto/man/RSA_sign.3 b/lib/libcrypto/man/RSA_sign.3 index 5c874cb39a..80e0b0e957 100644 --- a/lib/libcrypto/man/RSA_sign.3 +++ b/lib/libcrypto/man/RSA_sign.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_sign.3,v 1.5 2018/03/21 01:27:25 schwarze Exp $ +.\" $OpenBSD: RSA_sign.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL aa90ca11 Aug 20 15:48:56 2016 -0400 .\" .\" This file was written by Ulf Moeller . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RSA_SIGN 3 .Os .Sh NAME @@ -140,7 +140,8 @@ The error codes can be obtained by SSL, PKCS #1 v2.0 .Sh HISTORY .Fn RSA_sign -and +first appeared in SSLeay 0.4.4. .Fn RSA_verify -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0. +Both functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3 b/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3 index b9cff10994..215bb95401 100644 --- a/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3 +++ b/lib/libcrypto/man/RSA_sign_ASN1_OCTET_STRING.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_sign_ASN1_OCTET_STRING.3,v 1.5 2018/03/21 01:27:25 schwarze Exp $ +.\" $OpenBSD: RSA_sign_ASN1_OCTET_STRING.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RSA_SIGN_ASN1_OCTET_STRING 3 .Os .Sh NAME @@ -126,7 +126,7 @@ The error codes can be obtained by .Fn RSA_sign_ASN1_OCTET_STRING and .Fn RSA_verify_ASN1_OCTET_STRING -first appeared in SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Sh BUGS These functions serve no recognizable purpose. diff --git a/lib/libcrypto/man/RSA_size.3 b/lib/libcrypto/man/RSA_size.3 index f99979bb76..7218c2e1f8 100644 --- a/lib/libcrypto/man/RSA_size.3 +++ b/lib/libcrypto/man/RSA_size.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_size.3,v 1.8 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: RSA_size.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt RSA_SIZE 3 .Os .Sh NAME @@ -88,7 +88,7 @@ The size. .Xr RSA_new 3 .Sh HISTORY .Fn RSA_size -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.4.4 and has been available since .Ox 2.4 . .Pp .Fn RSA_bits diff --git a/lib/libcrypto/man/SHA1.3 b/lib/libcrypto/man/SHA1.3 index 74fc3380e7..f5061e56e6 100644 --- a/lib/libcrypto/man/SHA1.3 +++ b/lib/libcrypto/man/SHA1.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SHA1.3,v 1.6 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: SHA1.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SHA1 3 .Os .Sh NAME @@ -268,7 +268,7 @@ PUB 180-1 (Secure Hash Standard), ANSI X9.30 .Fn SHA1_Update , and .Fn SHA1_Final -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp The other functions first appeared in OpenSSL 0.9.8 diff --git a/lib/libcrypto/man/UI_create_method.3 b/lib/libcrypto/man/UI_create_method.3 index c0cb87396e..0c23e24e0e 100644 --- a/lib/libcrypto/man/UI_create_method.3 +++ b/lib/libcrypto/man/UI_create_method.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: UI_create_method.3,v 1.4 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: UI_create_method.3,v 1.5 2018/05/19 23:06:33 schwarze Exp $ .\" OpenSSL UI_create_method.pod 8e3d46e5 Mar 11 10:51:04 2017 +0100 .\" .\" This file was written by Richard Levitte . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt UI_CREATE_METHOD 3 .Os .Sh NAME @@ -71,7 +71,7 @@ .In openssl/ui.h .Ft UI_METHOD * .Fo UI_create_method -.Fa "char *name" +.Fa "const char *name" .Fc .Ft void .Fo UI_destroy_method diff --git a/lib/libcrypto/man/X25519.3 b/lib/libcrypto/man/X25519.3 dissimilarity index 97% index 3d8ccb8fcd..13f013e8a2 100644 --- a/lib/libcrypto/man/X25519.3 +++ b/lib/libcrypto/man/X25519.3 @@ -1,99 +1,100 @@ -.\" $OpenBSD: X25519.3,v 1.1 2017/04/10 17:45:06 schwarze Exp $ -.\" OpenSSL X25519.pod 69687aa8 Mar 28 23:57:28 2017 +0200 -.\" -.\" This file was written by Dr. Stephen Henson . -.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" 3. All advertising materials mentioning features or use of this -.\" software must display the following acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" -.\" -.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to -.\" endorse or promote products derived from this software without -.\" prior written permission. For written permission, please contact -.\" openssl-core@openssl.org. -.\" -.\" 5. Products derived from this software may not be called "OpenSSL" -.\" nor may "OpenSSL" appear in their names without prior written -.\" permission of the OpenSSL Project. -.\" -.\" 6. Redistributions of any form whatsoever must retain the following -.\" acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY -.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR -.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -.\" OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd $Mdocdate: April 10 2017 $ -.Dt X25519 3 -.Os -.Sh NAME -.Nm X25519 -.Nd EVP_PKEY X25519 support -.Sh DESCRIPTION -The -.Nm -.Vt EVP_PKEY -implementation supports key generation and key derivation using X25519. -It has associated private and public key formats compatible with -draft-ietf-curdle-pkix-03. -.Pp -No additional parameters can be set during key generation. -.Pp -The peer public key must be set using -.Xr EVP_PKEY_derive_set_peer 3 -when performing key derivation. -.Pp -A context for the -.Nm -algorithm can be obtained by calling: -.Pp -.Dl EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(NID_X25519, NULL); -.Sh EXAMPLES -Generate an -.Nm -private key and write it to standard output in PEM format: -.Bd -literal -#include -#include - -EVP_PKEY *pkey = NULL; -EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(NID_X25519, NULL); -EVP_PKEY_keygen_init(pctx); -EVP_PKEY_keygen(pctx, &pkey); -EVP_PKEY_CTX_free(pctx); -PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL); -.Ed -.Pp -The key derivation example in -.Xr EVP_PKEY_derive 3 -can be used with -.Nm . -.Sh SEE ALSO -.Xr EVP_PKEY_CTX_new 3 , -.Xr EVP_PKEY_derive 3 , -.Xr EVP_PKEY_keygen 3 +.\" $OpenBSD: X25519.3,v 1.4 2018/08/10 17:28:48 jsing Exp $ +.\" contains some text from: BoringSSL curve25519.h, curve25519.c +.\" content also checked up to: OpenSSL f929439f Mar 15 12:19:16 2018 +0000 +.\" +.\" Copyright (c) 2015 Google Inc. +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and/or distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: August 10 2018 $ +.Dt X25519 3 +.Os +.Sh NAME +.Nm X25519 , +.Nm X25519_keypair +.Nd Elliptic Curve Diffie-Hellman primitive based on Curve25519 +.Sh SYNOPSIS +.In openssl/curve25519.h +.Ft int +.Fo X25519 +.Fa "uint8_t out_shared_key[X25519_KEY_LENGTH]" +.Fa "const uint8_t private_key[X25519_KEY_LENGTH]" +.Fa "const uint8_t peer_public_value[X25519_KEY_LENGTH]" +.Fc +.Ft void +.Fo X25519_keypair +.Fa "uint8_t out_public_value[X25519_KEY_LENGTH]" +.Fa "uint8_t out_private_key[X25519_KEY_LENGTH]" +.Fc +.Sh DESCRIPTION +Curve25519 is an elliptic curve over a prime field specified in RFC 7748. +The prime field is defined by the prime number 2^255 - 19. +.Pp +.Fn X25519 +is the Diffie-Hellman primitive built from Curve25519 as described +in RFC 7748 section 5. +Section 6.1 describes the intended use in an Elliptic Curve Diffie-Hellman +(ECDH) protocol. +.Pp +.Fn X25519 +writes a shared key to +.Fa out_shared_key +that is calculated from the given +.Fa private_key +and the +.Fa peer_public_value +by scalar multiplication. +Do not use the shared key directly, rather use a key derivation +function and also include the two public values as inputs. +.Pp +.Fn X25519_keypair +sets +.Fa out_public_value +and +.Fa out_private_key +to a freshly generated public/private key pair. +First, the +.Fa out_private_key +is generated with +.Xr arc4random_buf 3 . +Then, the opposite of the masking described in RFC 7748 section 5 +is applied to it to make sure that the generated private key is never +correctly masked. +The purpose is to cause incorrect implementations on the peer side +to consistently fail. +Correct implementations will decode the key correctly even when it is +not correctly masked. +Finally, the +.Fa out_public_value +is calculated from the +.Fa out_private_key +by multiplying it with the Montgomery base point +.Vt uint8_t u[32] No = Brq 9 . +.Pp +The size of a public and private key is +.Dv X25519_KEY_LENGTH No = 32 +bytes each. +.Sh RETURN VALUES +.Fn X25519 +returns 1 on success or 0 on error. +Failure can occur when the input is a point of small order. +.Sh SEE ALSO +.Rs +.%A D. J. Bernstein +.%R A state-of-the-art Diffie-Hellman function:\ + How do I use Curve25519 in my own software? +.%U http://cr.yp.to/ecdh.html +.Re +.Sh STANDARDS +RFC 7748: Elliptic Curves for Security diff --git a/lib/libcrypto/man/X509_ALGOR_dup.3 b/lib/libcrypto/man/X509_ALGOR_dup.3 index c85dbd1d32..5a2b7a4604 100644 --- a/lib/libcrypto/man/X509_ALGOR_dup.3 +++ b/lib/libcrypto/man/X509_ALGOR_dup.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_ALGOR_dup.3,v 1.11 2018/03/23 05:48:56 schwarze Exp $ +.\" $OpenBSD: X509_ALGOR_dup.3,v 1.13 2018/05/01 19:42:58 schwarze Exp $ .\" OpenSSL 4692340e Jun 7 15:49:08 2016 -0400 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt X509_ALGOR_DUP 3 .Os .Sh NAME @@ -96,7 +96,7 @@ .Fc .Ft void .Fo X509_ALGOR_get0 -.Fa "ASN1_OBJECT **paobj" +.Fa "const ASN1_OBJECT **paobj" .Fa "int *pptype" .Fa "const void **ppval" .Fa "const X509_ALGOR *alg" @@ -216,7 +216,7 @@ Certificate Revocation List (CRL) Profile .Fn X509_ALGOR_new and .Fn X509_ALGOR_free -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Pp .Fn X509_ALGOR_dup @@ -230,7 +230,8 @@ first appeared in OpenSSL 0.9.8h and have been available since .Ox 4.5 . .Pp .Fn X509_ALGOR_cmp -first appeared in OpenSSL 0.9.8zd and 1.0.0p and has been available since +first appeared in OpenSSL 0.9.8zd, 1.0.0p, and 1.0.1k +and has been available since .Ox 4.9 . .Pp .Fn X509_ALGOR_set_md diff --git a/lib/libcrypto/man/X509_ATTRIBUTE_new.3 b/lib/libcrypto/man/X509_ATTRIBUTE_new.3 index a6ce900a55..cf978867f1 100644 --- a/lib/libcrypto/man/X509_ATTRIBUTE_new.3 +++ b/lib/libcrypto/man/X509_ATTRIBUTE_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_ATTRIBUTE_new.3,v 1.5 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_ATTRIBUTE_new.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_ATTRIBUTE_NEW 3 .Os .Sh NAME @@ -92,7 +92,7 @@ section 4.2: The SafeBag Type .Fn X509_ATTRIBUTE_new and .Fn X509_ATTRIBUTE_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Sh BUGS A data type designed to hold arbitrary data is an oxymoron. diff --git a/lib/libcrypto/man/X509_CINF_new.3 b/lib/libcrypto/man/X509_CINF_new.3 index eb18d66ffc..29d2371ffd 100644 --- a/lib/libcrypto/man/X509_CINF_new.3 +++ b/lib/libcrypto/man/X509_CINF_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_CINF_new.3,v 1.4 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: X509_CINF_new.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_CINF_NEW 3 .Os .Sh NAME @@ -103,7 +103,7 @@ Certificate Revocation List (CRL) Profile .Fn X509_VAL_new , and .Fn X509_VAL_free -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Pp .Fn X509_CERT_AUX_new diff --git a/lib/libcrypto/man/X509_CRL_new.3 b/lib/libcrypto/man/X509_CRL_new.3 index 2f824bff91..47b3d54940 100644 --- a/lib/libcrypto/man/X509_CRL_new.3 +++ b/lib/libcrypto/man/X509_CRL_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_CRL_new.3,v 1.6 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_CRL_new.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016, 2018 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_CRL_NEW 3 .Os .Sh NAME @@ -120,12 +120,14 @@ Certificate Revocation List (CRL) Profile, section 5: CRL and CRL Extensions Profile .Sh HISTORY .Fn X509_CRL_new , -.Fn X509_CRL_dup , .Fn X509_CRL_free , .Fn X509_CRL_INFO_new , and .Fn X509_CRL_INFO_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.4.4. +.Fn X509_CRL_dup +first appeared in SSLeay 0.5.1. +These functions have been available since .Ox 2.4 . .Pp .Fn X509_CRL_up_ref diff --git a/lib/libcrypto/man/X509_EXTENSION_set_object.3 b/lib/libcrypto/man/X509_EXTENSION_set_object.3 index ff59a6424d..414dfe6a55 100644 --- a/lib/libcrypto/man/X509_EXTENSION_set_object.3 +++ b/lib/libcrypto/man/X509_EXTENSION_set_object.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_EXTENSION_set_object.3,v 1.7 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_EXTENSION_set_object.3,v 1.9 2018/05/19 21:09:19 schwarze Exp $ .\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt X509_EXTENSION_SET_OBJECT 3 .Os .Sh NAME @@ -105,7 +105,7 @@ .Ft int .Fo X509_EXTENSION_set_object .Fa "X509_EXTENSION *ex" -.Fa "ASN1_OBJECT *obj" +.Fa "const ASN1_OBJECT *obj" .Fc .Ft int .Fo X509_EXTENSION_set_critical @@ -123,7 +123,7 @@ .Fc .Ft int .Fo X509_EXTENSION_get_critical -.Fa "X509_EXTENSION *ex" +.Fa "const X509_EXTENSION *ex" .Fc .Ft ASN1_OCTET_STRING * .Fo X509_EXTENSION_get_data @@ -287,5 +287,19 @@ pointer. RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +.Fn X509_EXTENSION_new +and +.Fn X509_EXTENSION_free +first appeared in SSLeay 0.6.2. +.Fn X509_EXTENSION_create_by_NID , +.Fn X509_EXTENSION_create_by_OBJ , +.Fn X509_EXTENSION_set_object , +.Fn X509_EXTENSION_set_critical , +.Fn X509_EXTENSION_set_data , +.Fn X509_EXTENSION_get_object , +.Fn X509_EXTENSION_get_critical , +and +.Fn X509_EXTENSION_get_data +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/X509_LOOKUP_hash_dir.3 b/lib/libcrypto/man/X509_LOOKUP_hash_dir.3 index 61924eb5d8..1f8520ce04 100644 --- a/lib/libcrypto/man/X509_LOOKUP_hash_dir.3 +++ b/lib/libcrypto/man/X509_LOOKUP_hash_dir.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_LOOKUP_hash_dir.3,v 1.7 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: X509_LOOKUP_hash_dir.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" .\" This file was written by Victor B. Wagner @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_LOOKUP_HASH_DIR 3 .Os .Sh NAME @@ -233,7 +233,7 @@ or 0 on error. .Fn X509_LOOKUP_file , and .Fn X509_load_cert_file -appeared before SSLeay 0.8. +first appeared in SSLeay 0.8.0. .Fn X509_load_crl_file first appeared in SSLeay 0.9.0. These functions have been available since diff --git a/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 b/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 index 49ce32ec11..d2cb9baa3c 100644 --- a/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 +++ b/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_NAME_ENTRY_get_object.3,v 1.9 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: X509_NAME_ENTRY_get_object.3,v 1.12 2018/05/19 21:25:51 schwarze Exp $ .\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -67,7 +67,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt X509_NAME_ENTRY_GET_OBJECT 3 .Os .Sh NAME @@ -93,16 +93,16 @@ .Fc .Ft ASN1_OBJECT * .Fo X509_NAME_ENTRY_get_object -.Fa "X509_NAME_ENTRY *ne" +.Fa "const X509_NAME_ENTRY *ne" .Fc .Ft ASN1_STRING * .Fo X509_NAME_ENTRY_get_data -.Fa "X509_NAME_ENTRY *ne" +.Fa "const X509_NAME_ENTRY *ne" .Fc .Ft int .Fo X509_NAME_ENTRY_set_object .Fa "X509_NAME_ENTRY *ne" -.Fa "ASN1_OBJECT *obj" +.Fa "const ASN1_OBJECT *obj" .Fc .Ft int .Fo X509_NAME_ENTRY_set_data @@ -124,13 +124,13 @@ .Fa "X509_NAME_ENTRY **ne" .Fa "int nid" .Fa "int type" -.Fa "unsigned char *bytes" +.Fa "const unsigned char *bytes" .Fa "int len" .Fc .Ft X509_NAME_ENTRY * .Fo X509_NAME_ENTRY_create_by_OBJ .Fa "X509_NAME_ENTRY **ne" -.Fa "ASN1_OBJECT *obj" +.Fa "const ASN1_OBJECT *obj" .Fa "int type" .Fa "const unsigned char *bytes" .Fa "int len" @@ -266,8 +266,10 @@ ITU-T Recommendation X.501, also known as ISO/IEC 9594-2: Information Technology Open Systems Interconnection The Directory: Models, section 9.3: Relative distinguished name .Sh HISTORY -.Fn X509_NAME_ENTRY_new , -.Fn X509_NAME_ENTRY_free , +.Fn X509_NAME_ENTRY_new +and +.Fn X509_NAME_ENTRY_free +first appeared in SSLeay 0.5.1. .Fn X509_NAME_ENTRY_get_object , .Fn X509_NAME_ENTRY_get_data , .Fn X509_NAME_ENTRY_set_object , @@ -275,7 +277,8 @@ section 9.3: Relative distinguished name .Fn X509_NAME_ENTRY_create_by_NID , and .Fn X509_NAME_ENTRY_create_by_OBJ -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Pp .Fn X509_NAME_ENTRY_create_by_txt diff --git a/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 b/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 index c70c7b73d5..1f09414039 100644 --- a/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 +++ b/lib/libcrypto/man/X509_NAME_add_entry_by_txt.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_NAME_add_entry_by_txt.3,v 1.9 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: X509_NAME_add_entry_by_txt.3,v 1.12 2018/05/19 23:02:00 schwarze Exp $ .\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt X509_NAME_ADD_ENTRY_BY_TXT 3 .Os .Sh NAME @@ -74,9 +74,9 @@ .Ft int .Fo X509_NAME_add_entry_by_OBJ .Fa "X509_NAME *name" -.Fa "ASN1_OBJECT *obj" +.Fa "const ASN1_OBJECT *obj" .Fa "int type" -.Fa "unsigned char *bytes" +.Fa "const unsigned char *bytes" .Fa "int len" .Fa "int loc" .Fa "int set" @@ -86,7 +86,7 @@ .Fa "X509_NAME *name" .Fa "int nid" .Fa "int type" -.Fa "unsigned char *bytes" +.Fa "const unsigned char *bytes" .Fa "int len" .Fa "int loc" .Fa "int set" @@ -94,7 +94,7 @@ .Ft int .Fo X509_NAME_add_entry .Fa "X509_NAME *name" -.Fa "X509_NAME_ENTRY *ne" +.Fa "const X509_NAME_ENTRY *ne" .Fa "int loc" .Fa "int set" .Fc @@ -259,7 +259,7 @@ if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC, .Fn X509_NAME_add_entry and .Fn X509_NAME_delete_entry -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn X509_NAME_add_entry_by_txt , diff --git a/lib/libcrypto/man/X509_NAME_get_index_by_NID.3 b/lib/libcrypto/man/X509_NAME_get_index_by_NID.3 index f80e08bf69..70202fed00 100644 --- a/lib/libcrypto/man/X509_NAME_get_index_by_NID.3 +++ b/lib/libcrypto/man/X509_NAME_get_index_by_NID.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_NAME_get_index_by_NID.3,v 1.7 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_NAME_get_index_by_NID.3,v 1.10 2018/07/09 09:57:41 tb Exp $ .\" OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: July 9 2018 $ .Dt X509_NAME_GET_INDEX_BY_NID 3 .Os .Sh NAME @@ -64,23 +64,23 @@ .In openssl/x509.h .Ft int .Fo X509_NAME_get_index_by_NID -.Fa "X509_NAME *name" +.Fa "const X509_NAME *name" .Fa "int nid" .Fa "int lastpos" .Fc .Ft int .Fo X509_NAME_get_index_by_OBJ -.Fa "X509_NAME *name" -.Fa "ASN1_OBJECT *obj" +.Fa "const X509_NAME *name" +.Fa "const ASN1_OBJECT *obj" .Fa "int lastpos" .Fc .Ft int .Fo X509_NAME_entry_count -.Fa "X509_NAME *name" +.Fa "const X509_NAME *name" .Fc .Ft X509_NAME_ENTRY * .Fo X509_NAME_get_entry -.Fa "X509_NAME *name" +.Fa "const X509_NAME *name" .Fa "int loc" .Fc .Ft int @@ -93,7 +93,7 @@ .Ft int .Fo X509_NAME_get_text_by_OBJ .Fa "X509_NAME *name" -.Fa "ASN1_OBJECT *obj" +.Fa "const ASN1_OBJECT *obj" .Fa "char *buf" .Fa "int len" .Fc @@ -228,7 +228,8 @@ for (;;) { .Xr ERR_get_error 3 , .Xr X509_NAME_new 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +These functions first appeared in SSLeay 0.8.0 +and have been available since .Ox 2.4 . .Sh CAVEATS .Fn X509_NAME_get_text_by_NID diff --git a/lib/libcrypto/man/X509_NAME_new.3 b/lib/libcrypto/man/X509_NAME_new.3 index 27ab03dfab..527e22272c 100644 --- a/lib/libcrypto/man/X509_NAME_new.3 +++ b/lib/libcrypto/man/X509_NAME_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_NAME_new.3,v 1.4 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_NAME_new.3,v 1.6 2018/07/29 20:29:32 tb Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: July 29 2018 $ .Dt X509_NAME_NEW 3 .Os .Sh NAME @@ -62,6 +62,11 @@ frees and all the .Vt X509_NAME_ENTRY objects contained in it. +If +.Fa name +is a +.Dv NULL +pointer, no action occurs. .Sh RETURN VALUES .Fn X509_NAME_new returns a new @@ -90,5 +95,5 @@ The Directory: Models, section 9: Names .Fn X509_NAME_new and .Fn X509_NAME_free -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/X509_NAME_print_ex.3 b/lib/libcrypto/man/X509_NAME_print_ex.3 index 6b91ff5d66..494066ff9c 100644 --- a/lib/libcrypto/man/X509_NAME_print_ex.3 +++ b/lib/libcrypto/man/X509_NAME_print_ex.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_NAME_print_ex.3,v 1.9 2018/03/22 17:11:04 schwarze Exp $ +.\" $OpenBSD: X509_NAME_print_ex.3,v 1.11 2018/05/19 22:05:58 schwarze Exp $ .\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt X509_NAME_PRINT_EX 3 .Os .Sh NAME @@ -64,27 +64,27 @@ .Ft int .Fo X509_NAME_print_ex .Fa "BIO *out" -.Fa "X509_NAME *nm" +.Fa "const X509_NAME *nm" .Fa "int indent" .Fa "unsigned long flags" .Fc .Ft int .Fo X509_NAME_print_ex_fp .Fa "FILE *fp" -.Fa "X509_NAME *nm" +.Fa "const X509_NAME *nm" .Fa "int indent" .Fa "unsigned long flags" .Fc .Ft char * .Fo X509_NAME_oneline -.Fa "X509_NAME *a" +.Fa "const X509_NAME *a" .Fa "char *buf" .Fa "int size" .Fc .Ft int .Fo X509_NAME_print .Fa "BIO *bp" -.Fa "X509_NAME *name" +.Fa "const X509_NAME *name" .Fa "int obase" .Fc .Sh DESCRIPTION @@ -276,7 +276,7 @@ returns 1 on success or 0 on error. .Fn X509_NAME_oneline and .Fn X509_NAME_print -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn X509_NAME_print_ex diff --git a/lib/libcrypto/man/X509_OBJECT_get0_X509.3 b/lib/libcrypto/man/X509_OBJECT_get0_X509.3 index 0119b91e1e..905146b38f 100644 --- a/lib/libcrypto/man/X509_OBJECT_get0_X509.3 +++ b/lib/libcrypto/man/X509_OBJECT_get0_X509.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_OBJECT_get0_X509.3,v 1.5 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_OBJECT_get0_X509.3,v 1.8 2018/08/24 19:23:07 tb Exp $ .\" Copyright (c) 2018 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -13,10 +13,11 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: August 24 2018 $ .Dt X509_OBJECT_GET0_X509 3 .Os .Sh NAME +.Nm X509_OBJECT_get_type , .Nm X509_OBJECT_up_ref_count , .Nm X509_OBJECT_free_contents , .Nm X509_OBJECT_get0_X509 , @@ -27,7 +28,11 @@ .Nd certificate, CRL, private key, and string wrapper for certificate stores .Sh SYNOPSIS .In openssl/x509_vfy.h -.Ft void +.Ft int +.Fo X509_OBJECT_get_type +.Fa "const X509_OBJECT *obj" +.Fc +.Ft int .Fo X509_OBJECT_up_ref_count .Fa "X509_OBJECT *obj" .Fc @@ -72,7 +77,8 @@ certificate revocation list object, one private key object, or one .Vt char * string. -It also remembers which type of object it contains at any given time. +The type of object stored at any given time can be inspected with +.Fn X509_OBJECT_get_type . .Pp Each .Vt X509_STORE @@ -145,6 +151,19 @@ otherwise, it searches for an .Vt X509_OBJECT with a matching type. .Sh RETURN VALUES +.Fn X509_OBJECT_get_type +returns +.Dv X509_LU_X509 +if +.Fa obj +contains a certificate, +.Dv X509_LU_CRL +if it contains a certificate revocation list, +or 0 if an error occurs. +.Pp +.Fn X509_OBJECT_up_ref_count +returns 1 on success and 0 on failure. +.Pp .Fn X509_OBJECT_get0_X509 returns an internal pointer to the certificate contained in .Fa obj @@ -219,7 +238,7 @@ or no match is found. .Fn X509_OBJECT_up_ref_count and .Fn X509_OBJECT_free_contents -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn X509_OBJECT_idx_by_subject , @@ -229,7 +248,8 @@ and first appeared in OpenSSL 0.9.6 and have been available since .Ox 2.9 . .Pp -.Fn X509_OBJECT_get0_X509 +.Fn X509_OBJECT_get_type , +.Fn X509_OBJECT_get0_X509 , and .Fn X509_OBJECT_get0_X509_CRL first appeared in OpenSSL 1.1.0 and have been available since diff --git a/lib/libcrypto/man/X509_PUBKEY_new.3 b/lib/libcrypto/man/X509_PUBKEY_new.3 index 077f6f7d0e..d5af722e42 100644 --- a/lib/libcrypto/man/X509_PUBKEY_new.3 +++ b/lib/libcrypto/man/X509_PUBKEY_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_PUBKEY_new.3,v 1.12 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_PUBKEY_new.3,v 1.13 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_PUBKEY_NEW 3 .Os .Sh NAME @@ -283,12 +283,15 @@ return 1 for success and 0 if an error occurred. RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile .Sh HISTORY -.Fn X509_PUBKEY_new , -.Fn X509_PUBKEY_free , -.Fn X509_PUBKEY_set , +.Fn X509_PUBKEY_new +and +.Fn X509_PUBKEY_free +appeared in SSLeay 0.4 or earlier. +.Fn X509_PUBKEY_set and .Fn X509_PUBKEY_get -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Pp .Fn d2i_PUBKEY diff --git a/lib/libcrypto/man/X509_REQ_new.3 b/lib/libcrypto/man/X509_REQ_new.3 index baa31a6c8c..8d000328f6 100644 --- a/lib/libcrypto/man/X509_REQ_new.3 +++ b/lib/libcrypto/man/X509_REQ_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_REQ_new.3,v 1.3 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_REQ_new.3,v 1.5 2018/07/29 20:29:32 tb Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: July 29 2018 $ .Dt X509_REQ_NEW 3 .Os .Sh NAME @@ -47,6 +47,11 @@ information about the signature algorithm used. .Fn X509_REQ_free frees .Fa req . +If +.Fa req +is a +.Dv NULL +pointer, no action occurs. .Pp .Fn X509_REQ_INFO_new allocates and initializes an empty @@ -61,6 +66,11 @@ certificate and additional attributes. .Fn X509_REQ_INFO_free frees .Fa req_info . +If +.Fa req_info +is a +.Dv NULL +pointer, no action occurs. .Sh RETURN VALUES .Fn X509_REQ_new and @@ -88,5 +98,5 @@ RFC 2986: PKCS #10: Certification Request Syntax Specification .Fn X509_REQ_INFO_new , and .Fn X509_REQ_INFO_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.4.4 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/X509_REVOKED_new.3 b/lib/libcrypto/man/X509_REVOKED_new.3 index 65d3470b40..03f45b166e 100644 --- a/lib/libcrypto/man/X509_REVOKED_new.3 +++ b/lib/libcrypto/man/X509_REVOKED_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_REVOKED_new.3,v 1.8 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_REVOKED_new.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: .\" OpenSSL man3/X509_CRL_get0_by_serial cdd6c8c5 Mar 20 12:29:37 2017 +0100 .\" @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_REVOKED_NEW 3 .Os .Sh NAME @@ -182,7 +182,7 @@ Certificate Revocation List (CRL) Profile, section 5.1: CRL Fields .Fn X509_REVOKED_new and .Fn X509_REVOKED_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.4.4 and have been available since .Ox 2.4 . .Pp .Fn X509_REVOKED_set_serialNumber diff --git a/lib/libcrypto/man/X509_SIG_new.3 b/lib/libcrypto/man/X509_SIG_new.3 index ee96861519..79a7125202 100644 --- a/lib/libcrypto/man/X509_SIG_new.3 +++ b/lib/libcrypto/man/X509_SIG_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_SIG_new.3,v 1.3 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_SIG_new.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_SIG_NEW 3 .Os .Sh NAME @@ -63,5 +63,5 @@ section 9: Encoding Methods for Signatures .Fn X509_SIG_new and .Fn X509_SIG_free -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/X509_STORE_CTX_get_error.3 b/lib/libcrypto/man/X509_STORE_CTX_get_error.3 index 6d575139d5..06021bb5c4 100644 --- a/lib/libcrypto/man/X509_STORE_CTX_get_error.3 +++ b/lib/libcrypto/man/X509_STORE_CTX_get_error.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_STORE_CTX_get_error.3,v 1.10 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_STORE_CTX_get_error.3,v 1.11 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: .\" OpenSSL crypto/X509_STORE_CTX_get_error f0e0fd51 Apr 14 23:59:26 2016 -0400 .\" selective merge up to: @@ -53,7 +53,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_STORE_CTX_GET_ERROR 3 .Os .Sh NAME @@ -381,7 +381,7 @@ This will never be returned unless explicitly set by an application. .Fn X509_STORE_CTX_get_current_cert , and .Fn X509_verify_cert_error_string -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn X509_STORE_CTX_get1_chain diff --git a/lib/libcrypto/man/X509_STORE_CTX_new.3 b/lib/libcrypto/man/X509_STORE_CTX_new.3 index 501e2b0e78..581c6b2f24 100644 --- a/lib/libcrypto/man/X509_STORE_CTX_new.3 +++ b/lib/libcrypto/man/X509_STORE_CTX_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_STORE_CTX_new.3,v 1.17 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_STORE_CTX_new.3,v 1.18 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 .\" selective merge up to: OpenSSL 7643a172 Apr 21 13:35:51 2017 +0200 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_STORE_CTX_NEW 3 .Os .Sh NAME @@ -327,7 +327,7 @@ returns an internal pointer. .Fn X509_STORE_CTX_set_cert , and .Fn X509_STORE_CTX_set_chain -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn X509_STORE_CTX_new diff --git a/lib/libcrypto/man/X509_STORE_load_locations.3 b/lib/libcrypto/man/X509_STORE_load_locations.3 index 9b42ce8f4d..ad64bd0316 100644 --- a/lib/libcrypto/man/X509_STORE_load_locations.3 +++ b/lib/libcrypto/man/X509_STORE_load_locations.3 @@ -1,4 +1,6 @@ -.\" $OpenBSD: X509_STORE_load_locations.3,v 1.4 2018/03/21 03:28:40 schwarze Exp $ +.\" $OpenBSD: X509_STORE_load_locations.3,v 1.6 2018/03/30 00:44:24 schwarze Exp $ +.\" full merge up to: +.\" OpenSSL X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000 .\" .\" Copyright (c) 2017 Ingo Schwarze .\" @@ -14,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 30 2018 $ .Dt X509_STORE_LOAD_LOCATIONS 3 .Os .Sh NAME @@ -44,6 +46,8 @@ contained in the colon-separated list .Fa dirs for looking up certificates, in addition to files and directories that are already configured. +The certificates in the directores must be in hashed form, as documented in +.Xr X509_LOOKUP_hash_dir 3 . Directories already in use are not added again. If .Dv NULL @@ -112,7 +116,7 @@ default directory for .Fn X509_STORE_load_locations and .Fn X509_STORE_set_default_paths -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Sh BUGS By the time that adding a directory is found to have failed, diff --git a/lib/libcrypto/man/X509_STORE_new.3 b/lib/libcrypto/man/X509_STORE_new.3 index d450ec1f95..814e5cfcba 100644 --- a/lib/libcrypto/man/X509_STORE_new.3 +++ b/lib/libcrypto/man/X509_STORE_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_STORE_new.3,v 1.3 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_STORE_new.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" @@ -67,7 +67,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_STORE_NEW 3 .Os .Sh NAME @@ -132,7 +132,7 @@ returns 1 for success and 0 for failure. .Fn X509_STORE_new and .Fn X509_STORE_free -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn X509_STORE_up_ref diff --git a/lib/libcrypto/man/X509_STORE_set1_param.3 b/lib/libcrypto/man/X509_STORE_set1_param.3 index d444eaf4f7..ea6e399e54 100644 --- a/lib/libcrypto/man/X509_STORE_set1_param.3 +++ b/lib/libcrypto/man/X509_STORE_set1_param.3 @@ -1,5 +1,6 @@ -.\" $OpenBSD: X509_STORE_set1_param.3,v 1.12 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_STORE_set1_param.3,v 1.15 2018/04/02 01:35:37 schwarze Exp $ .\" content checked up to: +.\" OpenSSL man3/X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000 .\" OpenSSL man3/X509_STORE_get0_param e90fc053 Jul 15 09:39:45 2017 -0400 .\" .\" Copyright (c) 2018 Ingo Schwarze @@ -16,7 +17,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: April 2 2018 $ .Dt X509_STORE_SET1_PARAM 3 .Os .Sh NAME @@ -27,6 +28,7 @@ .Nm X509_STORE_set_depth , .Nm X509_STORE_add_cert , .Nm X509_STORE_add_crl , +.Nm X509_STORE_get0_param , .Nm X509_STORE_get0_objects , .Nm X509_STORE_get_ex_new_index , .Nm X509_STORE_set_ex_data , @@ -69,6 +71,10 @@ .Fa "X509_STORE *store" .Fa "X509_CRL *crl" .Fc +.Ft X509_VERIFY_PARAM * +.Fo X509_STORE_get0_param +.Fa "X509_STORE *store" +.Fc .Ft STACK_OF(X509_OBJECT) * .Fo X509_STORE_get0_objects .Fa "X509_STORE *store" @@ -123,6 +129,7 @@ or the certificate revocation list to the .Fa store , increasing its reference count by 1 in case of success. +Untrusted objects should not be added in this way. .Pp .Fn X509_STORE_get_ex_new_index , .Fn X509_STORE_set_ex_data , @@ -167,11 +174,13 @@ are already contained in the .Fa store , or if memory allocation fails. .Pp +.Fn X509_STORE_get0_param +returns an internal pointer to the verification parameter object +contained in the +.Fa store , .Fn X509_STORE_get0_objects -returns an internal pointer to the stack of certificates, revocation lists, -and private keys contained in the -.Fa store . -The returned pointer must not be freed by the calling application. +to the stack of certificates, revocation lists, and private keys. +The returned pointers must not be freed by the calling application. .Pp .Fn X509_STORE_get_ex_new_index returns a new index or \-1 on failure. @@ -189,7 +198,7 @@ on failure. .Xr X509_VERIFY_PARAM_set_flags 3 .Sh HISTORY .Fn X509_STORE_add_cert -appeared before SSLeay 0.8. +first appeared in SSLeay 0.8.0. .Fn X509_STORE_add_crl first appeared in SSLeay 0.9.0. These functions have been available since @@ -208,6 +217,7 @@ and first appeared in OpenSSL 0.9.8 and have been available since .Ox 4.5 . .Pp +.Fn X509_STORE_get0_param , .Fn X509_STORE_get0_objects , .Fn X509_STORE_get_ex_new_index , .Fn X509_STORE_set_ex_data , diff --git a/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 b/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 index 03ec907fb3..16f1fac2ec 100644 --- a/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 +++ b/lib/libcrypto/man/X509_STORE_set_verify_cb_func.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_STORE_set_verify_cb_func.3,v 1.7 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_STORE_set_verify_cb_func.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_STORE_SET_VERIFY_CB_FUNC 3 .Os .Sh NAME @@ -96,7 +96,7 @@ do not return a value. .Xr X509_STORE_new 3 .Sh HISTORY .Fn X509_STORE_set_verify_cb_func -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . .Pp .Fn X509_STORE_set_verify_cb diff --git a/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 b/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 index 4f3261c975..5e45278604 100644 --- a/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 +++ b/lib/libcrypto/man/X509_VERIFY_PARAM_set_flags.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.12 2018/03/23 14:26:40 schwarze Exp $ +.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.14 2018/04/07 13:57:43 jmc Exp $ .\" full merge up to: OpenSSL d33def66 Feb 9 14:17:13 2016 -0500 .\" selective merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 .\" @@ -68,7 +68,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: April 7 2018 $ .Dt X509_VERIFY_PARAM_SET_FLAGS 3 .Os .Sh NAME @@ -344,14 +344,14 @@ is .Dv NULL or empty, the list of hostnames is cleared, and name checks are not performed on the peer certificate. -If +.Fa namelen +should be set to the length of +.Fa name . +For historical compatibility, if .Fa name is NUL-terminated, .Fa namelen -may be zero, otherwise -.Fa namelen -must be set to the length of -.Fa name . +may be specified as zero. When a hostname is specified, certificate verification automatically invokes .Xr X509_check_host 3 @@ -360,6 +360,10 @@ with flags equal to the argument given to .Fn X509_VERIFY_PARAM_set_hostflags (default zero). +.Fn X509_VERIFY_PARAM_set1_host +will fail if +.Fa name +contains any embedded 0 bytes. .Pp .Fn X509_VERIFY_PARAM_add1_host adds @@ -376,6 +380,18 @@ No change is made if is .Dv NULL or empty. +.Fa namelen +should be set to the length of +.Fa name . +For historical compatibility, if +.Fa name +is NUL-terminated, +.Fa namelen +may be specified as zero. +.Fn X509_VERIFY_PARAM_add1_host +will fail if +.Fa name +contains any embedded 0 bytes. When multiple names are configured, the peer is considered verified when any name matches. .Pp @@ -390,14 +406,18 @@ identifier respectively. .Fn X509_VERIFY_PARAM_set1_email sets the expected RFC822 email address to .Fa email . -If +.Fa emaillen +should be set to the length of +.Fa email . +For historical compatibility, if .Fa email is NUL-terminated, .Fa emaillen -may be zero, otherwise -.Fa emaillen -must be set to the length of -.Fa email . +may be specified as zero, +.Fn X509_VERIFY_PARAM_set1_email +will fail if +.Fa email +is NULL, an empty string, or contains embedded 0 bytes. When an email address is specified, certificate verification automatically invokes .Xr X509_check_email 3 . @@ -410,6 +430,12 @@ The argument is in binary format, in network byte-order, and .Fa iplen must be set to 4 for IPv4 and 16 for IPv6. +.Fn X509_VERIFY_PARAM_set1_ip +will fail if +.Fa ip +is NULL or if +.Fa iplen +is not 4 or 16. When an IP address is specified, certificate verification automatically invokes .Xr X509_check_ip 3 . @@ -422,6 +448,10 @@ The argument is a NUL-terminal ASCII string: dotted decimal quad for IPv4 and colon-separated hexadecimal for IPv6. The condensed "::" notation is supported for IPv6 addresses. +.Fn X509_VERIFY_PARAM_set1_ip_asc +will fail if +.Fa ipasc +is unparsable. .Pp .Fn X509_VERIFY_PARAM_add0_table adds @@ -476,14 +506,23 @@ on allocation failure. .Fn X509_VERIFY_PARAM_set_trust , .Fn X509_VERIFY_PARAM_add0_policy , .Fn X509_VERIFY_PARAM_set1_policies , +and +.Fn X509_VERIFY_PARAM_add0_table +return 1 for success or 0 for failure. +.Pp .Fn X509_VERIFY_PARAM_set1_host , .Fn X509_VERIFY_PARAM_add1_host , .Fn X509_VERIFY_PARAM_set1_email , .Fn X509_VERIFY_PARAM_set1_ip , -.Fn X509_VERIFY_PARAM_set1_ip_asc , and -.Fn X509_VERIFY_PARAM_add0_table +.Fn X509_VERIFY_PARAM_set1_ip_asc , return 1 for success or 0 for failure. +A failure from these routines will poison +the +.Vt X509_VERIFY_PARAM +object so that future calls to +.Xr X509_verify_cert 3 +using the poisoned object will fail. .Pp .Fn X509_VERIFY_PARAM_get_flags returns the current verification flags. diff --git a/lib/libcrypto/man/X509_check_private_key.3 b/lib/libcrypto/man/X509_check_private_key.3 index 1a48478194..38e297d54c 100644 --- a/lib/libcrypto/man/X509_check_private_key.3 +++ b/lib/libcrypto/man/X509_check_private_key.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_check_private_key.3,v 1.3 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: X509_check_private_key.3,v 1.5 2018/05/19 22:40:34 schwarze Exp $ .\" OpenSSL X509_check_private_key.pod 09ddb878 Jun 5 03:56:07 2017 +0800 .\" .\" Copyright (c) 2017 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt X509_CHECK_PRIVATE_KEY 3 .Os .Sh NAME @@ -26,8 +26,8 @@ .In openssl/x509.h .Ft int .Fo X509_check_private_key -.Fa "X509 *x" -.Fa "EVP_PKEY *k" +.Fa "const X509 *x" +.Fa "const EVP_PKEY *k" .Fc .Ft int .Fo X509_REQ_check_private_key @@ -63,7 +63,7 @@ On error or mismatch, a reason code can be obtained using .Xr SSL_check_private_key 3 .Sh HISTORY .Fn X509_check_private_key -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.5 and has been available since .Ox 2.4 . .Pp .Fn X509_REQ_check_private_key diff --git a/lib/libcrypto/man/X509_cmp_time.3 b/lib/libcrypto/man/X509_cmp_time.3 index 5a8922efd1..d7a55653ae 100644 --- a/lib/libcrypto/man/X509_cmp_time.3 +++ b/lib/libcrypto/man/X509_cmp_time.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_cmp_time.3,v 1.7 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: X509_cmp_time.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL X509_cmp_time.pod 24053693 Mar 28 14:27:37 2017 +0200 .\" .\" This file was written by Emilia Kasper @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_CMP_TIME 3 .Os .Sh NAME @@ -139,7 +139,7 @@ on error. .Xr time 3 .Sh HISTORY .Fn X509_cmp_current_time -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.0 and has been available since .Ox 2.4 . .Pp .Fn X509_cmp_time diff --git a/lib/libcrypto/man/X509_digest.3 b/lib/libcrypto/man/X509_digest.3 index 24a5e6239d..e29160d50c 100644 --- a/lib/libcrypto/man/X509_digest.3 +++ b/lib/libcrypto/man/X509_digest.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_digest.3,v 1.5 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: X509_digest.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL X509_digest.pod 3ba4dac6 Mar 23 13:04:52 2017 -0400 .\" .\" This file was written by Rich Salz @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_DIGEST 3 .Os .Sh NAME @@ -136,7 +136,7 @@ These functions return 1 for success or 0 for failure. .Fn X509_NAME_digest , and .Fn PKCS7_ISSUER_AND_SERIAL_digest -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.5 and have been available since .Ox 2.4 . .Pp .Fn X509_CRL_digest diff --git a/lib/libcrypto/man/X509_get_pubkey.3 b/lib/libcrypto/man/X509_get_pubkey.3 index e84ff0b18a..49a57447e8 100644 --- a/lib/libcrypto/man/X509_get_pubkey.3 +++ b/lib/libcrypto/man/X509_get_pubkey.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_get_pubkey.3,v 1.4 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_get_pubkey.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_GET_PUBKEY 3 .Os .Sh NAME @@ -159,11 +159,13 @@ return 1 for success or 0 for failure. .Sh HISTORY .Fn X509_get_pubkey , .Fn X509_set_pubkey , -.Fn X509_get_X509_PUBKEY , .Fn X509_REQ_get_pubkey , and .Fn X509_REQ_set_pubkey -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.5. +.Fn X509_get_X509_PUBKEY +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Pp .Fn X509_get0_pubkey diff --git a/lib/libcrypto/man/X509_get_serialNumber.3 b/lib/libcrypto/man/X509_get_serialNumber.3 index fcc01a1389..b8d540dcf2 100644 --- a/lib/libcrypto/man/X509_get_serialNumber.3 +++ b/lib/libcrypto/man/X509_get_serialNumber.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_get_serialNumber.3,v 1.2 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_get_serialNumber.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_GET_SERIALNUMBER 3 .Os .Sh NAME @@ -109,5 +109,5 @@ returns 1 for success and 0 for failure. .Fn X509_get_serialNumber and .Fn X509_set_serialNumber -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.5 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/X509_get_subject_name.3 b/lib/libcrypto/man/X509_get_subject_name.3 index 89012ba370..06b554eff3 100644 --- a/lib/libcrypto/man/X509_get_subject_name.3 +++ b/lib/libcrypto/man/X509_get_subject_name.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_get_subject_name.3,v 1.5 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: X509_get_subject_name.3,v 1.7 2018/05/13 14:25:40 schwarze Exp $ .\" OpenSSL 0ad69cd6 Jun 14 23:02:16 2016 +0200 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: May 13 2018 $ .Dt X509_GET_SUBJECT_NAME 3 .Os .Sh NAME @@ -65,7 +65,7 @@ .In openssl/x509.h .Ft X509_NAME * .Fo X509_get_subject_name -.Fa "X509 *x" +.Fa "const X509 *x" .Fc .Ft int .Fo X509_set_subject_name @@ -74,7 +74,7 @@ .Fc .Ft X509_NAME * .Fo X509_get_issuer_name -.Fa "X509 *x" +.Fa "const X509 *x" .Fc .Ft int .Fo X509_set_issuer_name @@ -169,14 +169,17 @@ return 1 for success or 0 for failure. .Xr X509_verify_cert 3 , .Xr X509V3_get_d2i 3 .Sh HISTORY -.Fn X509_get_subject_name , +.Fn X509_get_subject_name +and +.Fn X509_get_issuer_name +appeared in SSLeay 0.4 or earlier. .Fn X509_set_subject_name , -.Fn X509_get_issuer_name , .Fn X509_set_issuer_name , .Fn X509_REQ_get_subject_name , and .Fn X509_REQ_set_subject_name -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.5. +These functions have been available since .Ox 2.4 . .Pp .Fn X509_CRL_get_issuer diff --git a/lib/libcrypto/man/X509_get_version.3 b/lib/libcrypto/man/X509_get_version.3 index 0e238a9eb1..395502fa07 100644 --- a/lib/libcrypto/man/X509_get_version.3 +++ b/lib/libcrypto/man/X509_get_version.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_get_version.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $ +.\" $OpenBSD: X509_get_version.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_GET_VERSION 3 .Os .Sh NAME @@ -153,7 +153,7 @@ return 1 for success or 0 for failure. .Fn X509_REQ_get_version , and .Fn X509_REQ_set_version -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.5 and have been available since .Ox 2.4 . .Pp .Fn X509_CRL_get_version diff --git a/lib/libcrypto/man/X509_new.3 b/lib/libcrypto/man/X509_new.3 index 4bfc430549..1d0f602341 100644 --- a/lib/libcrypto/man/X509_new.3 +++ b/lib/libcrypto/man/X509_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_new.3,v 1.14 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_new.3,v 1.15 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_NEW 3 .Os .Sh NAME @@ -158,7 +158,7 @@ Certificate Revocation List (CRL) Profile .Fn X509_new and .Fn X509_free -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Pp .Fn X509_up_ref diff --git a/lib/libcrypto/man/X509_sign.3 b/lib/libcrypto/man/X509_sign.3 index 5341da6dc9..cc3c7ab8b8 100644 --- a/lib/libcrypto/man/X509_sign.3 +++ b/lib/libcrypto/man/X509_sign.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_sign.3,v 1.4 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: X509_sign.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_SIGN 3 .Os .Sh NAME @@ -189,14 +189,19 @@ some other error occurred, then -1 is returned. .Xr X509_verify_cert 3 , .Xr X509V3_get_d2i 3 .Sh HISTORY -.Fn X509_sign , -.Fn X509_verify , -.Fn X509_REQ_sign , -.Fn X509_REQ_verify , -.Fn X509_CRL_sign , +.Fn X509_verify +appeared in SSLeay 0.4 or earlier. +.Fn X509_sign +and +.Fn X509_REQ_sign +first appeared in SSLeay 0.4.4. +.Fn X509_REQ_verify and .Fn X509_CRL_verify -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.4.5b. +.Fn X509_CRL_sign +first appeared in SSLeay 0.5.1. +These functions have been available since .Ox 2.4 . .Pp .Fn X509_sign_ctx , diff --git a/lib/libcrypto/man/X509_verify_cert.3 b/lib/libcrypto/man/X509_verify_cert.3 index fda351809b..604d3bd5da 100644 --- a/lib/libcrypto/man/X509_verify_cert.3 +++ b/lib/libcrypto/man/X509_verify_cert.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_verify_cert.3,v 1.6 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509_verify_cert.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt X509_VERIFY_CERT 3 .Os .Sh NAME @@ -83,7 +83,7 @@ using .Xr X509_STORE_CTX_get_error 3 .Sh HISTORY .Fn X509_verify_cert -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . .Sh BUGS This function uses the header diff --git a/lib/libcrypto/man/X509v3_get_ext_by_NID.3 b/lib/libcrypto/man/X509v3_get_ext_by_NID.3 index 93517a5d28..d823c0b4ef 100644 --- a/lib/libcrypto/man/X509v3_get_ext_by_NID.3 +++ b/lib/libcrypto/man/X509v3_get_ext_by_NID.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509v3_get_ext_by_NID.3,v 1.6 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: X509v3_get_ext_by_NID.3,v 1.9 2018/05/19 22:37:10 schwarze Exp $ .\" OpenSSL c952780c Jun 21 07:03:34 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt X509V3_GET_EXT_BY_NID 3 .Os .Sh NAME @@ -101,7 +101,7 @@ .Ft int .Fo X509v3_get_ext_by_OBJ .Fa "const STACK_OF(X509_EXTENSION) *x" -.Fa "ASN1_OBJECT *obj" +.Fa "const ASN1_OBJECT *obj" .Fa "int lastpos" .Fc .Ft int @@ -123,28 +123,28 @@ .Fc .Ft int .Fo X509_get_ext_count -.Fa "X509 *x" +.Fa "const X509 *x" .Fc .Ft X509_EXTENSION * .Fo X509_get_ext -.Fa "X509 *x" +.Fa "const X509 *x" .Fa "int loc" .Fc .Ft int .Fo X509_get_ext_by_NID -.Fa "X509 *x" +.Fa "const X509 *x" .Fa "int nid" .Fa "int lastpos" .Fc .Ft int .Fo X509_get_ext_by_OBJ -.Fa "X509 *x" -.Fa "ASN1_OBJECT *obj" +.Fa "const X509 *x" +.Fa "const ASN1_OBJECT *obj" .Fa "int lastpos" .Fc .Ft int .Fo X509_get_ext_by_critical -.Fa "X509 *x" +.Fa "const X509 *x" .Fa "int crit" .Fa "int lastpos" .Fc @@ -199,28 +199,28 @@ .Fc .Ft int .Fo X509_REVOKED_get_ext_count -.Fa "X509_REVOKED *x" +.Fa "const X509_REVOKED *x" .Fc .Ft X509_EXTENSION * .Fo X509_REVOKED_get_ext -.Fa "X509_REVOKED *x" +.Fa "const X509_REVOKED *x" .Fa "int loc" .Fc .Ft int .Fo X509_REVOKED_get_ext_by_NID -.Fa "X509_REVOKED *x" +.Fa "const X509_REVOKED *x" .Fa "int nid" .Fa "int lastpos" .Fc .Ft int .Fo X509_REVOKED_get_ext_by_OBJ -.Fa "X509_REVOKED *x" -.Fa "ASN1_OBJECT *obj" +.Fa "const X509_REVOKED *x" +.Fa "const ASN1_OBJECT *obj" .Fa "int lastpos" .Fc .Ft int .Fo X509_REVOKED_get_ext_by_critical -.Fa "X509_REVOKED *x" +.Fa "const X509_REVOKED *x" .Fa "int crit" .Fa "int lastpos" .Fc @@ -388,5 +388,6 @@ on error. .Xr X509_REVOKED_new 3 , .Xr X509V3_get_d2i 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +These functions first appeared in SSLeay 0.8.0 +and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/d2i_ASN1_OBJECT.3 b/lib/libcrypto/man/d2i_ASN1_OBJECT.3 index 687f97efef..09a17ced7c 100644 --- a/lib/libcrypto/man/d2i_ASN1_OBJECT.3 +++ b/lib/libcrypto/man/d2i_ASN1_OBJECT.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.7 2018/03/20 18:35:13 schwarze Exp $ +.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.9 2018/04/25 15:17:52 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" Copyright (c) 2017 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt D2I_ASN1_OBJECT 3 .Os .Sh NAME @@ -32,7 +32,7 @@ .Fc .Ft int .Fo i2d_ASN1_OBJECT -.Fa "ASN1_OBJECT *val_in" +.Fa "const ASN1_OBJECT *val_in" .Fa "unsigned char **der_out" .Fc .Sh DESCRIPTION @@ -78,7 +78,7 @@ or a value <= 0 if an error occurs. .Fn d2i_ASN1_OBJECT and .Fn i2d_ASN1_OBJECT -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Sh CAVEATS .Fn d2i_ASN1_OBJECT diff --git a/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 b/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 index 451d5cdd77..c985bc8b68 100644 --- a/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 +++ b/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.11 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.12 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2017 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_ASN1_OCTET_STRING 3 .Os .Sh NAME @@ -394,13 +394,15 @@ Certificate Revocation List (CRL) Profile .Fn d2i_ASN1_IA5STRING , .Fn i2d_ASN1_IA5STRING , .Fn d2i_ASN1_T61STRING , +.Fn i2d_ASN1_T61STRING , .Fn d2i_ASN1_PRINTABLESTRING , +.Fn i2d_ASN1_PRINTABLESTRING .Fn d2i_ASN1_PRINTABLE , .Fn i2d_ASN1_PRINTABLE , .Fn d2i_ASN1_UTCTIME , and .Fn i2d_ASN1_UTCTIME -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn d2i_ASN1_BMPSTRING @@ -429,10 +431,6 @@ first appeared in OpenSSL 0.9.3. These functions have been available since .Ox 2.6 . .Pp -.Fn i2d_ASN1_PRINTABLESTRING -first appeared in OpenSSL 0.9.5 and has been available since -.Ox 2.7 . -.Pp .Fn d2i_ASN1_UNIVERSALSTRING , .Fn i2d_ASN1_UNIVERSALSTRING , .Fn d2i_ASN1_GENERALSTRING , diff --git a/lib/libcrypto/man/d2i_DHparams.3 b/lib/libcrypto/man/d2i_DHparams.3 index 0a216dc507..7fd9878dc0 100644 --- a/lib/libcrypto/man/d2i_DHparams.3 +++ b/lib/libcrypto/man/d2i_DHparams.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_DHparams.3,v 1.7 2018/03/20 22:22:10 schwarze Exp $ +.\" $OpenBSD: d2i_DHparams.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" .\" This file was written by Ulf Moeller and @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_DHPARAMS 3 .Os .Sh NAME @@ -95,5 +95,5 @@ if an error occurs. .Fn d2i_DHparams and .Fn i2d_DHparams -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/d2i_DSAPublicKey.3 b/lib/libcrypto/man/d2i_DSAPublicKey.3 index 103954c924..37ef22e1b9 100644 --- a/lib/libcrypto/man/d2i_DSAPublicKey.3 +++ b/lib/libcrypto/man/d2i_DSAPublicKey.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_DSAPublicKey.3,v 1.12 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: d2i_DSAPublicKey.3,v 1.14 2018/08/26 17:03:32 tb Exp $ .\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: August 26 2018 $ .Dt D2I_DSAPUBLICKEY 3 .Os .Sh NAME @@ -69,6 +69,10 @@ .Nm i2d_DSAPrivateKey_fp , .Nm d2i_DSAparams , .Nm i2d_DSAparams , +.Nm d2i_DSAparams_bio , +.Nm i2d_DSAparams_bio , +.Nm d2i_DSAparams_fp , +.Nm i2d_DSAparams_fp , .Nm DSAparams_dup , .Nm d2i_DSA_SIG , .Nm i2d_DSA_SIG @@ -86,6 +90,7 @@ .Fa "const DSA *val_in" .Fa "unsigned char **der_out" .Fc +.In openssl/x509.h .Ft DSA * .Fo d2i_DSA_PUBKEY .Fa "DSA **val_out" @@ -117,6 +122,7 @@ .Fa "FILE *out_fp" .Fa "DSA *val_in" .Fc +.In openssl/dsa.h .Ft DSA * .Fo d2i_DSAPrivateKey .Fa "DSA **val_out" @@ -128,6 +134,7 @@ .Fa "const DSA *val_in" .Fa "unsigned char **der_out" .Fc +.In openssl/x509.h .Ft DSA * .Fo d2i_DSAPrivateKey_bio .Fa "BIO *in_bio" @@ -148,6 +155,7 @@ .Fa "FILE *out_fp" .Fa "DSA *val_in" .Fc +.In openssl/dsa.h .Ft DSA * .Fo d2i_DSAparams .Fa "DSA **val_out" @@ -160,6 +168,26 @@ .Fa "unsigned char **der_out" .Fc .Ft DSA * +.Fo d2i_DSAparams_bio +.Fa "BIO *in_bio" +.Fa "DSA **val_out" +.Fc +.Ft int +.Fo i2d_DSAparams_bio +.Fa "BIO *out_bio" +.Fa "DSA *val_in" +.Fc +.Ft DSA * +.Fo d2i_DSAparams_fp +.Fa "FILE *in_fp" +.Fa "DSA **val_out" +.Fc +.Ft int +.Fo i2d_DSAparams_fp +.Fa FILE *out_fp +.Fa "DSA *val_in" +.Fc +.Ft DSA * .Fo DSAparams_dup .Fa "DSA *val_in" .Fc @@ -246,7 +274,6 @@ For private key security when writing private keys to files, consider using .Xr PEM_write_DSAPrivateKey 3 instead. -The .Fn d2i_DSAPrivateKey_bio , .Fn d2i_DSAPrivateKey_fp , .Fn i2d_DSAPrivateKey_bio , @@ -267,6 +294,15 @@ structure defined in RFC 3279 section 2.3.2 and used for the parameters field of the ASN.1 .Vt AlgorithmIdentifier structure defined in RFC 5280 section 4.1.1.2. +.Fn d2i_DSAparams_bio , +.Fn i2d_DSAparams_bio , +.Fn d2i_DSAparams_fp , +.Fn i2d_DSAparams_fp +are similar except that they decode or encode using a +.Vt BIO +or +.Vt FILE +pointer. .Pp .Fn DSAparams_dup allocates and initializes an empty @@ -299,6 +335,8 @@ structure described in RFC 5280 sections 4.1.1.3 and 5.1.1.3. .Fn d2i_DSAPrivateKey_bio , .Fn d2i_DSAPrivateKey_fp , .Fn d2i_DSAparams , +.Fn d2i_DSAparams_bio , +.Fn d2i_DSAparams_fp , and .Fn DSAparams_dup return a valid @@ -338,16 +376,23 @@ section 2.3.2: DSA Signature Keys .Fn d2i_DSAPublicKey , .Fn i2d_DSAPublicKey , .Fn d2i_DSAPrivateKey , -.Fn i2d_DSAPrivateKey , +and +.Fn i2d_DSAPrivateKey +first appeared in SSLeay 0.6.0. .Fn d2i_DSAPrivateKey_bio , .Fn d2i_DSAPrivateKey_fp , .Fn i2d_DSAPrivateKey_bio , .Fn i2d_DSAPrivateKey_fp , .Fn d2i_DSAparams , .Fn i2d_DSAparams , +.Fn d2i_DSAparams_bio , +.Fn i2d_DSAparams_bio , +.Fn d2i_DSAparams_fp , +.Fn i2d_DSAparams_fp , and .Fn DSAparams_dup -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Pp .Fn d2i_DSA_SIG diff --git a/lib/libcrypto/man/d2i_ECPKParameters.3 b/lib/libcrypto/man/d2i_ECPKParameters.3 index 3637786b6b..e82e7911dd 100644 --- a/lib/libcrypto/man/d2i_ECPKParameters.3 +++ b/lib/libcrypto/man/d2i_ECPKParameters.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_ECPKParameters.3,v 1.11 2018/03/23 00:09:11 schwarze Exp $ +.\" $OpenBSD: d2i_ECPKParameters.3,v 1.12 2018/05/19 22:51:40 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: May 19 2018 $ .Dt D2I_ECPKPARAMETERS 3 .Os .Sh NAME @@ -184,7 +184,7 @@ .Fc .Ft int .Fo i2o_ECPublicKey -.Fa "EC_KEY *val_in" +.Fa "const EC_KEY *val_in" .Fa "unsigned char **des_out" .Fc .Ft int diff --git a/lib/libcrypto/man/d2i_PKCS7.3 b/lib/libcrypto/man/d2i_PKCS7.3 index cb00bf2a0c..0581583fc7 100644 --- a/lib/libcrypto/man/d2i_PKCS7.3 +++ b/lib/libcrypto/man/d2i_PKCS7.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_PKCS7.3,v 1.5 2018/03/21 00:54:31 schwarze Exp $ +.\" $OpenBSD: d2i_PKCS7.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_PKCS7 3 .Os .Sh NAME @@ -350,5 +350,5 @@ RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5 .Fn d2i_PKCS7_SIGN_ENVELOPE , and .Fn i2d_PKCS7_SIGN_ENVELOPE -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/d2i_PrivateKey.3 b/lib/libcrypto/man/d2i_PrivateKey.3 index 7a2824bc57..85b46d44a0 100644 --- a/lib/libcrypto/man/d2i_PrivateKey.3 +++ b/lib/libcrypto/man/d2i_PrivateKey.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_PrivateKey.3,v 1.7 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: d2i_PrivateKey.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_PRIVATEKEY 3 .Os .Sh NAME @@ -271,7 +271,7 @@ Information Syntax Specification .Fn d2i_PublicKey , and .Fn i2d_PublicKey -appeared in SSLeay 0.8.1b or earlier and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . .Pp .Fn d2i_AutoPrivateKey , diff --git a/lib/libcrypto/man/d2i_RSAPublicKey.3 b/lib/libcrypto/man/d2i_RSAPublicKey.3 index a98fd44018..d6c376d84b 100644 --- a/lib/libcrypto/man/d2i_RSAPublicKey.3 +++ b/lib/libcrypto/man/d2i_RSAPublicKey.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_RSAPublicKey.3,v 1.12 2018/03/23 05:48:56 schwarze Exp $ +.\" $OpenBSD: d2i_RSAPublicKey.3,v 1.13 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" .\" This file is a derived work. @@ -67,7 +67,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_RSAPUBLICKEY 3 .Os .Sh NAME @@ -353,18 +353,23 @@ section 4.1: Basic Certificate Fields .Fn i2d_RSAPublicKey , .Fn d2i_RSAPrivateKey , .Fn i2d_RSAPrivateKey , +.Fn d2i_RSAPrivateKey_fp , +.Fn i2d_RSAPrivateKey_fp , .Fn d2i_Netscape_RSA , -.Fn i2d_Netscape_RSA , +and +.Fn i2d_Netscape_RSA +first appeared in SSLeay 0.5.1. +.Fn d2i_RSAPrivateKey_bio +and +.Fn i2d_RSAPrivateKey_bio +first appeared in SSLeay 0.6.0. .Fn d2i_RSAPublicKey_bio , .Fn d2i_RSAPublicKey_fp , .Fn i2d_RSAPublicKey_bio , -.Fn i2d_RSAPublicKey_fp , -.Fn d2i_RSAPrivateKey_bio , -.Fn d2i_RSAPrivateKey_fp , -.Fn i2d_RSAPrivateKey_bio , and -.Fn i2d_RSAPrivateKey_fp -appeared before SSLeay 0.8 and have been available since +.Fn i2d_RSAPublicKey_fp +first appeared in SSLeay 0.8.1. +These functions have been available since .Ox 2.4 . .Pp .Fn d2i_RSA_PUBKEY , diff --git a/lib/libcrypto/man/d2i_X509.3 b/lib/libcrypto/man/d2i_X509.3 index 9c80fcdb75..94b136a0ce 100644 --- a/lib/libcrypto/man/d2i_X509.3 +++ b/lib/libcrypto/man/d2i_X509.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509.3,v 1.8 2018/03/22 16:06:33 schwarze Exp $ +.\" $OpenBSD: d2i_X509.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 94480b57 Sep 12 23:34:41 2009 +0000 .\" .\" This file is a derived work. @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509 3 .Os .Sh NAME @@ -272,16 +272,19 @@ Certificate Revocation List (CRL) Profile .Sh HISTORY .Fn d2i_X509 , .Fn i2d_X509 , -.Fn d2i_X509_bio , .Fn d2i_X509_fp , -.Fn i2d_X509_bio , .Fn i2d_X509_fp , .Fn d2i_X509_CINF , .Fn i2d_X509_CINF , .Fn d2i_X509_VAL , and .Fn i2d_X509_VAL -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1. +.Fn d2i_X509_bio +and +.Fn i2d_X509_bio +first appeared in SSLeay 0.6.0. +These functions have been available since .Ox 2.4 . .Pp .Fn d2i_X509_AUX , diff --git a/lib/libcrypto/man/d2i_X509_ALGOR.3 b/lib/libcrypto/man/d2i_X509_ALGOR.3 index 0d5ad2c459..530ae86cf4 100644 --- a/lib/libcrypto/man/d2i_X509_ALGOR.3 +++ b/lib/libcrypto/man/d2i_X509_ALGOR.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509_ALGOR.3,v 1.8 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: d2i_X509_ALGOR.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 .\" .\" Copyright (c) 2016 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509_ALGOR 3 .Os .Sh NAME @@ -54,5 +54,5 @@ Certificate Revocation List (CRL) Profile .Fn d2i_X509_ALGOR and .Fn i2d_X509_ALGOR -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3 b/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3 index 5d913928a2..6b070e5e51 100644 --- a/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3 +++ b/lib/libcrypto/man/d2i_X509_ATTRIBUTE.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509_ATTRIBUTE.3,v 1.2 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: d2i_X509_ATTRIBUTE.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509_ATTRIBUTE 3 .Os .Sh NAME @@ -72,5 +72,5 @@ section 8.2: Overall structure .Fn d2i_X509_ATTRIBUTE and .Fn i2d_X509_ATTRIBUTE -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/d2i_X509_CRL.3 b/lib/libcrypto/man/d2i_X509_CRL.3 index aa023848f7..920be4aa89 100644 --- a/lib/libcrypto/man/d2i_X509_CRL.3 +++ b/lib/libcrypto/man/d2i_X509_CRL.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509_CRL.3,v 1.6 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: d2i_X509_CRL.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" .\" Copyright (c) 2016 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509_CRL 3 .Os .Sh NAME @@ -132,14 +132,17 @@ section 5: CRL and CRL Extensions Profile .Sh HISTORY .Fn d2i_X509_CRL , .Fn i2d_X509_CRL , -.Fn d2i_X509_CRL_bio , .Fn d2i_X509_CRL_fp , -.Fn i2d_X509_CRL_bio , .Fn i2d_X509_CRL_fp , .Fn d2i_X509_CRL_INFO , .Fn i2d_X509_CRL_INFO , .Fn d2i_X509_REVOKED , and .Fn i2d_X509_REVOKED -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1. +.Fn d2i_X509_CRL_bio +and +.Fn i2d_X509_CRL_bio +first appeared in SSLeay 0.6.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/d2i_X509_EXTENSION.3 b/lib/libcrypto/man/d2i_X509_EXTENSION.3 index 046ef29e78..46a680c1ba 100644 --- a/lib/libcrypto/man/d2i_X509_EXTENSION.3 +++ b/lib/libcrypto/man/d2i_X509_EXTENSION.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509_EXTENSION.3,v 1.3 2018/03/23 01:05:50 schwarze Exp $ +.\" $OpenBSD: d2i_X509_EXTENSION.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509_EXTENSION 3 .Os .Sh NAME @@ -94,7 +94,7 @@ Certificate Revocation List (CRL) Profile .Fn d2i_X509_EXTENSION and .Fn i2d_X509_EXTENSION -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.2 and have been available since .Ox 2.4 . .Pp .Fn d2i_X509_EXTENSIONS diff --git a/lib/libcrypto/man/d2i_X509_NAME.3 b/lib/libcrypto/man/d2i_X509_NAME.3 index 063a72edeb..3289ccb134 100644 --- a/lib/libcrypto/man/d2i_X509_NAME.3 +++ b/lib/libcrypto/man/d2i_X509_NAME.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509_NAME.3,v 1.13 2018/03/23 23:18:17 schwarze Exp $ +.\" $OpenBSD: d2i_X509_NAME.3,v 1.14 2018/03/27 17:35:50 schwarze Exp $ .\" checked up to: .\" OpenSSL crypto/d2i_X509_NAME 4692340e Jun 7 15:49:08 2016 -0400 and .\" OpenSSL man3/X509_NAME_get0_der 99d63d46 Oct 26 13:56:48 2016 -0400 @@ -17,7 +17,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509_NAME 3 .Os .Sh NAME @@ -175,15 +175,18 @@ Information technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER). .Sh HISTORY +.Fn X509_NAME_dup +first appeared in SSLeay 0.4.4. .Fn d2i_X509_NAME , .Fn i2d_X509_NAME , -.Fn X509_NAME_dup , -.Fn X509_NAME_hash , .Fn d2i_X509_NAME_ENTRY , .Fn i2d_X509_NAME_ENTRY , and .Fn X509_NAME_ENTRY_dup -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1. +.Fn X509_NAME_hash +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Pp .Fn X509_NAME_get0_der diff --git a/lib/libcrypto/man/d2i_X509_REQ.3 b/lib/libcrypto/man/d2i_X509_REQ.3 index 3030ac6664..95785a2d25 100644 --- a/lib/libcrypto/man/d2i_X509_REQ.3 +++ b/lib/libcrypto/man/d2i_X509_REQ.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509_REQ.3,v 1.6 2018/03/21 03:16:08 schwarze Exp $ +.\" $OpenBSD: d2i_X509_REQ.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" .\" Copyright (c) 2016 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509_REQ 3 .Os .Sh NAME @@ -137,12 +137,15 @@ RFC 2986: PKCS #10: Certification Request Syntax Specification .Sh HISTORY .Fn d2i_X509_REQ , .Fn i2d_X509_REQ , -.Fn d2i_X509_REQ_bio , .Fn d2i_X509_REQ_fp , -.Fn i2d_X509_REQ_bio , .Fn i2d_X509_REQ_fp , .Fn d2i_X509_REQ_INFO , and .Fn i2d_X509_REQ_INFO -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1. +.Fn d2i_X509_REQ_bio +and +.Fn i2d_X509_REQ_bio +first appeared in SSLeay 0.6.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libcrypto/man/d2i_X509_SIG.3 b/lib/libcrypto/man/d2i_X509_SIG.3 index 2f512d3174..fddeed79b3 100644 --- a/lib/libcrypto/man/d2i_X509_SIG.3 +++ b/lib/libcrypto/man/d2i_X509_SIG.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_X509_SIG.3,v 1.8 2018/03/21 21:18:08 schwarze Exp $ +.\" $OpenBSD: d2i_X509_SIG.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" .\" Copyright (c) 2016 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt D2I_X509_SIG 3 .Os .Sh NAME @@ -127,7 +127,7 @@ section 9: Encoding Methods for Signatures .Fn d2i_X509_SIG and .Fn i2d_X509_SIG -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Fn d2i_PKCS8_bio , diff --git a/lib/libcrypto/man/des_read_pw.3 b/lib/libcrypto/man/des_read_pw.3 index a7060d6efa..8c63a65fd2 100644 --- a/lib/libcrypto/man/des_read_pw.3 +++ b/lib/libcrypto/man/des_read_pw.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: des_read_pw.3,v 1.7 2018/03/20 22:06:59 schwarze Exp $ +.\" $OpenBSD: des_read_pw.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL doc/crypto/ui_compat.pod May 14 11:28:00 2006 +0000 .\" OpenSSL doc/crypto/des.pod 2a9aca32 Oct 25 08:44:10 2001 +0000 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 20 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DES_READ_PW 3 .Os .Sh NAME @@ -131,8 +131,13 @@ is functionally similar to .Sh SEE ALSO .Xr UI_new 3 .Sh HISTORY -These functions appeared in SSLeay 0.8.1b or earlier -and have been available since +.Fn des_read_pw_string +appeared in SSLeay 0.4 or earlier. +.Fn EVP_read_pw_string +first appeared in SSLeay 0.5.1. +.Fn des_read_pw +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . .Sh AUTHORS .An Richard Levitte Aq Mt richard@levitte.org diff --git a/lib/libcrypto/man/engine.3 b/lib/libcrypto/man/engine.3 deleted file mode 100644 index d0b83d7745..0000000000 --- a/lib/libcrypto/man/engine.3 +++ /dev/null @@ -1,1424 +0,0 @@ -.\" $OpenBSD: engine.3,v 1.13 2018/03/22 21:08:22 schwarze Exp $ -.\" full merge up to: OpenSSL crypto/engine e6390aca Jul 21 10:06:03 2015 -0400 -.\" selective merge up to: man3/ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 -.\" -.\" This file was written by Geoff Thorpe -.\" with contributions from Paul Yang . -.\" Copyright (c) 2002, 2004, 2007, 2015, 2017 The OpenSSL Project. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" 3. All advertising materials mentioning features or use of this -.\" software must display the following acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" -.\" -.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to -.\" endorse or promote products derived from this software without -.\" prior written permission. For written permission, please contact -.\" openssl-core@openssl.org. -.\" -.\" 5. Products derived from this software may not be called "OpenSSL" -.\" nor may "OpenSSL" appear in their names without prior written -.\" permission of the OpenSSL Project. -.\" -.\" 6. Redistributions of any form whatsoever must retain the following -.\" acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY -.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR -.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -.\" OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd $Mdocdate: March 22 2018 $ -.Dt ENGINE 3 -.Os -.Sh NAME -.Nm ENGINE_get_first , -.Nm ENGINE_get_last , -.Nm ENGINE_get_next , -.Nm ENGINE_get_prev , -.Nm ENGINE_add , -.Nm ENGINE_remove , -.Nm ENGINE_by_id , -.Nm ENGINE_init , -.Nm ENGINE_finish , -.Nm ENGINE_load_openssl , -.Nm ENGINE_load_dynamic , -.Nm ENGINE_load_cryptodev , -.Nm ENGINE_load_builtin_engines , -.Nm ENGINE_cleanup , -.Nm ENGINE_get_default_RSA , -.Nm ENGINE_get_default_DSA , -.Nm ENGINE_get_default_ECDH , -.Nm ENGINE_get_default_ECDSA , -.Nm ENGINE_get_default_DH , -.Nm ENGINE_get_default_RAND , -.Nm ENGINE_get_cipher_engine , -.Nm ENGINE_get_digest_engine , -.Nm ENGINE_set_default_RSA , -.Nm ENGINE_set_default_DSA , -.Nm ENGINE_set_default_ECDH , -.Nm ENGINE_set_default_ECDSA , -.Nm ENGINE_set_default_DH , -.Nm ENGINE_set_default_RAND , -.Nm ENGINE_set_default_ciphers , -.Nm ENGINE_set_default_digests , -.Nm ENGINE_set_default_string , -.Nm ENGINE_set_default , -.Nm ENGINE_get_table_flags , -.Nm ENGINE_set_table_flags , -.Nm ENGINE_register_RSA , -.Nm ENGINE_unregister_RSA , -.Nm ENGINE_register_all_RSA , -.Nm ENGINE_register_DSA , -.Nm ENGINE_unregister_DSA , -.Nm ENGINE_register_all_DSA , -.Nm ENGINE_register_ECDH , -.Nm ENGINE_unregister_ECDH , -.Nm ENGINE_register_all_ECDH , -.Nm ENGINE_register_ECDSA , -.Nm ENGINE_unregister_ECDSA , -.Nm ENGINE_register_all_ECDSA , -.Nm ENGINE_register_DH , -.Nm ENGINE_unregister_DH , -.Nm ENGINE_register_all_DH , -.Nm ENGINE_register_RAND , -.Nm ENGINE_unregister_RAND , -.Nm ENGINE_register_all_RAND , -.Nm ENGINE_register_STORE , -.Nm ENGINE_unregister_STORE , -.Nm ENGINE_register_all_STORE , -.Nm ENGINE_register_ciphers , -.Nm ENGINE_unregister_ciphers , -.Nm ENGINE_register_all_ciphers , -.Nm ENGINE_register_digests , -.Nm ENGINE_unregister_digests , -.Nm ENGINE_register_all_digests , -.Nm ENGINE_register_complete , -.Nm ENGINE_register_all_complete , -.Nm ENGINE_ctrl , -.Nm ENGINE_cmd_is_executable , -.Nm ENGINE_ctrl_cmd , -.Nm ENGINE_ctrl_cmd_string , -.Nm ENGINE_new , -.Nm ENGINE_free , -.Nm ENGINE_up_ref , -.Nm ENGINE_set_id , -.Nm ENGINE_set_name , -.Nm ENGINE_set_RSA , -.Nm ENGINE_set_DSA , -.Nm ENGINE_set_ECDH , -.Nm ENGINE_set_ECDSA , -.Nm ENGINE_set_DH , -.Nm ENGINE_set_RAND , -.Nm ENGINE_set_STORE , -.Nm ENGINE_set_destroy_function , -.Nm ENGINE_set_init_function , -.Nm ENGINE_set_finish_function , -.Nm ENGINE_set_ctrl_function , -.Nm ENGINE_set_load_privkey_function , -.Nm ENGINE_set_load_pubkey_function , -.Nm ENGINE_set_ciphers , -.Nm ENGINE_set_digests , -.Nm ENGINE_set_flags , -.Nm ENGINE_set_cmd_defns , -.Nm ENGINE_get_id , -.Nm ENGINE_get_name , -.Nm ENGINE_get_RSA , -.Nm ENGINE_get_DSA , -.Nm ENGINE_get_ECDH , -.Nm ENGINE_get_ECDSA , -.Nm ENGINE_get_DH , -.Nm ENGINE_get_RAND , -.Nm ENGINE_get_STORE , -.Nm ENGINE_get_destroy_function , -.Nm ENGINE_get_init_function , -.Nm ENGINE_get_finish_function , -.Nm ENGINE_get_ctrl_function , -.Nm ENGINE_get_load_privkey_function , -.Nm ENGINE_get_load_pubkey_function , -.Nm ENGINE_get_ciphers , -.Nm ENGINE_get_digests , -.Nm ENGINE_get_cipher , -.Nm ENGINE_get_digest , -.Nm ENGINE_get_flags , -.Nm ENGINE_get_cmd_defns , -.Nm ENGINE_load_private_key , -.Nm ENGINE_load_public_key -.Nd ENGINE cryptographic module support -.Sh SYNOPSIS -.In openssl/engine.h -.Ft ENGINE * -.Fn ENGINE_get_first void -.Ft ENGINE * -.Fn ENGINE_get_last void -.Ft ENGINE * -.Fo ENGINE_get_next -.Fa "ENGINE *e" -.Fc -.Ft ENGINE * -.Fo ENGINE_get_prev -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_add -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_remove -.Fa "ENGINE *e" -.Fc -.Ft ENGINE * -.Fo ENGINE_by_id -.Fa "const char *id" -.Fc -.Ft int -.Fo ENGINE_init -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_finish -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_load_openssl void -.Ft void -.Fn ENGINE_load_dynamic void -.Ft void -.Fn ENGINE_load_cryptodev void -.Ft void -.Fn ENGINE_load_builtin_engines void -.Ft void -.Fn ENGINE_cleanup void -.Ft ENGINE * -.Fn ENGINE_get_default_RSA void -.Ft ENGINE * -.Fn ENGINE_get_default_DSA void -.Ft ENGINE * -.Fn ENGINE_get_default_ECDH void -.Ft ENGINE * -.Fn ENGINE_get_default_ECDSA void -.Ft ENGINE * -.Fn ENGINE_get_default_DH void -.Ft ENGINE * -.Fn ENGINE_get_default_RAND void -.Ft ENGINE * -.Fo ENGINE_get_cipher_engine -.Fa "int nid" -.Fc -.Ft ENGINE * -.Fo ENGINE_get_digest_engine -.Fa "int nid" -.Fc -.Ft int -.Fo ENGINE_set_default_RSA -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_DSA -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_ECDH -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_ECDSA -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_DH -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_RAND -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_ciphers -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_digests -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_default_string -.Fa "ENGINE *e" -.Fa "const char *list" -.Fc -.Ft int -.Fo ENGINE_set_default -.Fa "ENGINE *e" -.Fa "unsigned int flags" -.Fc -.Ft unsigned int -.Fn ENGINE_get_table_flags void -.Ft void -.Fo ENGINE_set_table_flags -.Fa "unsigned int flags" -.Fc -.Ft int -.Fo ENGINE_register_RSA -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_RSA -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_RSA void -.Ft int -.Fo ENGINE_register_DSA -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_DSA -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_DSA void -.Ft int -.Fo ENGINE_register_ECDH -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_ECDH -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_ECDH void -.Ft int -.Fo ENGINE_register_ECDSA -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_ECDSA -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_ECDSA void -.Ft int -.Fo ENGINE_register_DH -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_DH -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_DH void -.Ft int -.Fo ENGINE_register_RAND -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_RAND -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_RAND void -.Ft int -.Fo ENGINE_register_STORE -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_STORE -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_STORE void -.Ft int -.Fo ENGINE_register_ciphers -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_ciphers -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_ciphers void -.Ft int -.Fo ENGINE_register_digests -.Fa "ENGINE *e" -.Fc -.Ft void -.Fo ENGINE_unregister_digests -.Fa "ENGINE *e" -.Fc -.Ft void -.Fn ENGINE_register_all_digests void -.Ft int -.Fo ENGINE_register_complete -.Fa "ENGINE *e" -.Fc -.Ft int -.Fn ENGINE_register_all_complete void -.Ft int -.Fo ENGINE_ctrl -.Fa "ENGINE *e" -.Fa "int cmd" -.Fa "long i" -.Fa "void *p" -.Fa "void (*f)(void)" -.Fc -.Ft int -.Fo ENGINE_cmd_is_executable -.Fa "ENGINE *e" -.Fa "int cmd" -.Fc -.Ft int -.Fo ENGINE_ctrl_cmd -.Fa "ENGINE *e" -.Fa "const char *cmd_name" -.Fa "long i" -.Fa "void *p" -.Fa "void (*f)(void)" -.Fa "int cmd_optional" -.Fc -.Ft int -.Fo ENGINE_ctrl_cmd_string -.Fa "ENGINE *e" -.Fa "const char *cmd_name" -.Fa "const char *arg" -.Fa "int cmd_optional" -.Fc -.Ft ENGINE * -.Fn ENGINE_new void -.Ft int -.Fo ENGINE_free -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_up_ref -.Fa "ENGINE *e" -.Fc -.Ft int -.Fo ENGINE_set_id -.Fa "ENGINE *e" -.Fa "const char *id" -.Fc -.Ft int -.Fo ENGINE_set_name -.Fa "ENGINE *e" -.Fa "const char *name" -.Fc -.Ft int -.Fo ENGINE_set_RSA -.Fa "ENGINE *e" -.Fa "const RSA_METHOD *rsa_meth" -.Fc -.Ft int -.Fo ENGINE_set_DSA -.Fa "ENGINE *e" -.Fa "const DSA_METHOD *dsa_meth" -.Fc -.Ft int -.Fo ENGINE_set_ECDH -.Fa "ENGINE *e" -.Fa "const ECDH_METHOD *dh_meth" -.Fc -.Ft int -.Fo ENGINE_set_ECDSA -.Fa "ENGINE *e" -.Fa "const ECDSA_METHOD *dh_meth" -.Fc -.Ft int -.Fo ENGINE_set_DH -.Fa "ENGINE *e" -.Fa "const DH_METHOD *dh_meth" -.Fc -.Ft int -.Fo ENGINE_set_RAND -.Fa "ENGINE *e" -.Fa "const RAND_METHOD *rand_meth" -.Fc -.Ft int -.Fo ENGINE_set_STORE -.Fa "ENGINE *e" -.Fa "const STORE_METHOD *rand_meth" -.Fc -.Ft int -.Fo ENGINE_set_destroy_function -.Fa "ENGINE *e" -.Fa "ENGINE_GEN_INT_FUNC_PTR destroy_f" -.Fc -.Ft int -.Fo ENGINE_set_init_function -.Fa "ENGINE *e" -.Fa "ENGINE_GEN_INT_FUNC_PTR init_f" -.Fc -.Ft int -.Fo ENGINE_set_finish_function -.Fa "ENGINE *e" -.Fa "ENGINE_GEN_INT_FUNC_PTR finish_f" -.Fc -.Ft int -.Fo ENGINE_set_ctrl_function -.Fa "ENGINE *e" -.Fa "ENGINE_CTRL_FUNC_PTR ctrl_f" -.Fc -.Ft int -.Fo ENGINE_set_load_privkey_function -.Fa "ENGINE *e" -.Fa "ENGINE_LOAD_KEY_PTR loadpriv_f" -.Fc -.Ft int -.Fo ENGINE_set_load_pubkey_function -.Fa "ENGINE *e" -.Fa "ENGINE_LOAD_KEY_PTR loadpub_f" -.Fc -.Ft int -.Fo ENGINE_set_ciphers -.Fa "ENGINE *e" -.Fa "ENGINE_CIPHERS_PTR f" -.Fc -.Ft int -.Fo ENGINE_set_digests -.Fa "ENGINE *e" -.Fa "ENGINE_DIGESTS_PTR f" -.Fc -.Ft int -.Fo ENGINE_set_flags -.Fa "ENGINE *e" -.Fa "int flags" -.Fc -.Ft int -.Fo ENGINE_set_cmd_defns -.Fa "ENGINE *e" -.Fa "const ENGINE_CMD_DEFN *defns" -.Fc -.Ft const char * -.Fo ENGINE_get_id -.Fa "const ENGINE *e" -.Fc -.Ft const char * -.Fo ENGINE_get_name -.Fa "const ENGINE *e" -.Fc -.Ft const RSA_METHOD * -.Fo ENGINE_get_RSA -.Fa "const ENGINE *e" -.Fc -.Ft const DSA_METHOD * -.Fo ENGINE_get_DSA -.Fa "const ENGINE *e" -.Fc -.Ft const ECDH_METHOD * -.Fo ENGINE_get_ECDH -.Fa "const ENGINE *e" -.Fc -.Ft const ECDSA_METHOD * -.Fo ENGINE_get_ECDSA -.Fa "const ENGINE *e" -.Fc -.Ft const DH_METHOD * -.Fo ENGINE_get_DH -.Fa "const ENGINE *e" -.Fc -.Ft const RAND_METHOD * -.Fo ENGINE_get_RAND -.Fa "const ENGINE *e" -.Fc -.Ft const STORE_METHOD * -.Fo ENGINE_get_STORE -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_GEN_INT_FUNC_PTR -.Fo ENGINE_get_destroy_function -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_GEN_INT_FUNC_PTR -.Fo ENGINE_get_init_function -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_GEN_INT_FUNC_PTR -.Fo ENGINE_get_finish_function -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_CTRL_FUNC_PTR -.Fo ENGINE_get_ctrl_function -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_LOAD_KEY_PTR -.Fo ENGINE_get_load_privkey_function -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_LOAD_KEY_PTR -.Fo ENGINE_get_load_pubkey_function -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_CIPHERS_PTR -.Fo ENGINE_get_ciphers -.Fa "const ENGINE *e" -.Fc -.Ft ENGINE_DIGESTS_PTR -.Fo ENGINE_get_digests -.Fa "const ENGINE *e" -.Fc -.Ft const EVP_CIPHER * -.Fo ENGINE_get_cipher -.Fa "ENGINE *e" -.Fa "int nid" -.Fc -.Ft const EVP_MD * -.Fo ENGINE_get_digest -.Fa "ENGINE *e" -.Fa "int nid" -.Fc -.Ft int -.Fo ENGINE_get_flags -.Fa "const ENGINE *e" -.Fc -.Ft const ENGINE_CMD_DEFN * -.Fo ENGINE_get_cmd_defns -.Fa "const ENGINE *e" -.Fc -.Ft EVP_PKEY * -.Fo ENGINE_load_private_key -.Fa "ENGINE *e" -.Fa "const char *key_id" -.Fa "UI_METHOD *ui_method" -.Fa "void *callback_data" -.Fc -.Ft EVP_PKEY * -.Fo ENGINE_load_public_key -.Fa "ENGINE *e" -.Fa "const char *key_id" -.Fa "UI_METHOD *ui_method" -.Fa "void *callback_data" -.Fc -.Sh DESCRIPTION -These functions create, manipulate, and use cryptographic modules -in the form of -.Vt ENGINE -objects. -These objects act as containers for implementations of cryptographic -algorithms, and support a reference-counted mechanism to allow them to -be dynamically loaded in and out of the running application. -.Pp -The cryptographic functionality that can be provided by an -.Vt ENGINE -implementation includes the following abstractions: -.Pp -.Bl -bullet -compact -.It -.Vt RSA_METHOD : -for providing alternative RSA implementations -.It -.Vt DSA_METHOD , DH_METHOD , RAND_METHOD , ECDH_METHOD , -.Vt ECDSA_METHOD , STORE_METHOD : -similarly for other OpenSSL APIs -.It -.Vt EVP_CIPHER : -potentially multiple cipher algorithms (indexed by 'nid') -.It -.Vt EVP_DIGEST : -potentially multiple hash algorithms (indexed by 'nid') -.It -key-loading: loading public and/or private EVP_PKEY keys -.El -.Ss Reference counting and handles -Due to the modular nature of the -.Nm engine -API, pointers to -.Vt ENGINE Ns s -need to be treated as handles - i.e. not only as pointers, but also -as references to the underlying -.Vt ENGINE -object. -One should obtain a new reference when making copies of an -.Vt ENGINE -pointer if the copies will be used (and released) independently. -.Pp -.Vt ENGINE -objects have two levels of reference-counting to match the way in -which the objects are used. -At the most basic level, each -.Vt ENGINE -pointer is inherently a -.Sy structural -reference - a structural reference is required to use the pointer value -at all, as this kind of reference is a guarantee that the structure cannot -be deallocated until the reference is released. -.Pp -However, a structural reference provides no guarantee that the -.Vt ENGINE -is initialised and able to use any of its cryptographic implementations. -Indeed it's quite possible that most -.Vt ENGINE Ns s -will not initialise at all in typical environments, as -.Vt ENGINE Ns s -are typically used to support specialised hardware. -To use an -.Vt ENGINE Ap s -functionality, you need a -.Sy functional -reference. -This kind of reference can be considered a specialised form of -structural reference, because each functional reference implicitly -contains a structural reference as well - however to avoid -difficult-to-find programming bugs, it is recommended to treat the two -kinds of reference independently. -If you have a functional reference to an -.Vt ENGINE , -you have a guarantee that the -.Vt ENGINE -has been initialised and is ready to perform cryptographic operations and -will remain uninitialised until after you have released your -reference. -.Pp -.Em Structural references -.Pp -This basic type of reference is used for instantiating new -.Vt ENGINE Ns s , -iterating across OpenSSL's internal linked-list of loaded -.Vt ENGINE Ns s , -reading information about an -.Vt ENGINE , -etc. -Essentially a structural reference is sufficient if you only need to -query or manipulate the data of an -.Vt ENGINE -implementation rather than use its functionality. -.Pp -The -.Fn ENGINE_new -function returns a structural reference to a new (empty) -.Vt ENGINE -object. -There are other -.Nm engine -API functions that return structural references such as -.Fn ENGINE_by_id , -.Fn ENGINE_get_first , -.Fn ENGINE_get_last , -.Fn ENGINE_get_next , -and -.Fn ENGINE_get_prev . -All structural references should be released by a corresponding call -to the -.Fn ENGINE_free -function. -The -.Vt ENGINE -object itself will only actually be cleaned up and deallocated when -the last structural reference is released. -.Pp -It should also be noted that many -.Nm engine -API function calls that accept a structural reference will internally -obtain another reference. -Typically this happens whenever the supplied -.Vt ENGINE -will be needed by OpenSSL after the function has returned. -For example, the function to add a new -.Vt ENGINE -to OpenSSL's internal list is -.Fn ENGINE_add . -If this function returns success, OpenSSL will have stored a new -structural reference internally so the caller is still responsible for -freeing their own reference with -.Fn ENGINE_free -when they are finished with it. -In a similar way, some functions will automatically release the -structural reference passed to it if part of the function's job is -to do so. -For example, the -.Fn ENGINE_get_next -and -.Fn ENGINE_get_prev -functions are used for iterating across the internal -.Vt ENGINE -list. -They -will return a new structural reference to the next (or previous) -.Vt ENGINE -in the list or -.Dv NULL -if at the end (or beginning) of the list, but in either case the -structural reference passed to the function is released on behalf -of the caller. -.Pp -To clarify a particular function's handling of references, one should -always consult that function's manual page, or failing that the -.In openssl/engine.h -header file includes some hints. -.Pp -.Em Functional references -.Pp -As mentioned, functional references exist when the cryptographic -functionality of an -.Vt ENGINE -is required to be available. -A functional reference can be obtained in one of two ways; from an -existing structural reference to the required -.Vt ENGINE , -or by asking OpenSSL for the default operational -.Vt ENGINE -for a given cryptographic purpose. -.Pp -To obtain a functional reference from an existing structural reference, -call the -.Fn ENGINE_init -function. -This returns zero if the -.Vt ENGINE -was not already operational and couldn't be successfully initialised -(e.g. lack of system drivers, no special hardware attached), -otherwise it will return non-zero to indicate that the -.Vt ENGINE -is now operational and will have allocated a new -.Sy functional -reference to the -.Vt ENGINE . -All functional references are released by calling -.Fn ENGINE_finish , -which removes the implicit structural reference as well. -.Pp -The second way to get a functional reference is by asking OpenSSL for a -default implementation for a given task, e.g. -by -.Fn ENGINE_get_default_RSA , -.Fn ENGINE_get_default_cipher_engine , -etc. -These are discussed in the next section, though they are not usually -required by application programmers as they are used automatically when -creating and using the relevant algorithm-specific types in OpenSSL, -such as RSA, DSA, EVP_CIPHER_CTX, etc. -.Ss Default implementations -For each supported abstraction, the -.Nm engine -code maintains an internal table of state to control which -implementations are available for a given abstraction and which -should be used by default. -These implementations are registered in the tables and indexed by an -.Fa nid -value, because abstractions like -.Vt EVP_CIPHER -and -.Vt EVP_DIGEST -support many distinct algorithms and modes, and -.Vt ENGINE Ns s -can support arbitrarily many of them. -In the case of other abstractions like RSA, DSA, etc., there is -only one "algorithm" so all implementations implicitly register -using the same -.Fa nid -index. -.Pp -When a default -.Vt ENGINE -is requested for a given abstraction/algorithm/mode, (e.g. when -calling -.Fn RSA_new_method NULL ) , -a "get_default" call will be made to the -.Nm engine -subsystem to process the corresponding state table and return -a functional reference to an initialised -.Vt ENGINE -whose implementation should be used. -If no -.Vt ENGINE -should (or can) be used, it will return -.Dv NULL -and the caller will operate with a -.Dv NULL -.Vt ENGINE -handle. -This usually equates to using the conventional software implementation. -In the latter case, OpenSSL will from then on behave the way it used to -before the -.Nm engine -API existed. -.Pp -Each state table has a flag to note whether it has processed this -"get_default" query since the table was last modified, because to -process this question it must iterate across all the registered -.Vt ENGINE Ns s -in the table trying to initialise each of them in turn, in case one of -them is operational. -If it returns a functional reference to an -.Vt ENGINE , -it will also cache another reference to speed up processing future -queries (without needing to iterate across the table). -Likewise, it will cache a -.Dv NULL -response if no -.Vt ENGINE -was available so that future queries won't repeat the same iteration -unless the state table changes. -This behaviour can also be changed; if the -.Dv ENGINE_TABLE_FLAG_NOINIT -flag is set (using -.Fn ENGINE_set_table_flags ) , -no attempted initialisations will take place, instead the only way for -the state table to return a -.Pf non- Dv NULL -.Vt ENGINE -to the "get_default" query will be if one is expressly set in the table. -For example, -.Fn ENGINE_set_default_RSA -does the same job as -.Fn ENGINE_register_RSA -except that it also sets the state table's cached response for the -"get_default" query. -In the case of abstractions like -.Vt EVP_CIPHER , -where implementations are indexed by -.Fa nid , -these flags and cached-responses are distinct for each -.Fa nid -value. -.Ss Application requirements -This section will explain the basic things an application programmer -should support to make the most useful elements of the -.Nm engine -functionality available to the user. -The first thing to consider is whether the programmer wishes to make -alternative -.Vt ENGINE -modules available to the application and user. -OpenSSL maintains an internal linked list of "visible" -.Vt ENGINE Ns s -from which it has to operate. -At start-up, this list is empty, and in fact if an application does -not call any -.Nm engine -API calls and it uses static -linking against openssl, then the resulting application binary will -not contain any alternative -.Nm engine -code at all. -So the first consideration is whether any/all available -.Vt ENGINE -implementations should be made visible to OpenSSL. -This is controlled by calling the various "load" functions, e.g. -.Fn ENGINE_load_builtin_engines -to make all -.Vt ENGINE -implementations bundled with OpenSSL available. -.Pp -Note that -.Fn ENGINE_load_dynamic -is a placeholder and does not enable dynamic engine loading support. -.Pp -Having called any of these functions, -.Vt ENGINE -objects would have been dynamically allocated and populated with -these implementations and linked into OpenSSL's internal linked -list. -.Pp -If no -.Nm engine -API functions are called at all in an application, then there are -no inherent memory leaks to worry about from the -.Nm engine -functionality, however if any -.Vt ENGINE Ns s -are loaded, even if they are never registered or used, it is necessary -to use the -.Fn ENGINE_cleanup -function to correspondingly cleanup before program exit, if the caller -wishes to avoid memory leaks. -This mechanism uses an internal callback registration table so that any -.Nm engine -API functionality that knows it requires cleanup can register its -cleanup details to be called during -.Fn ENGINE_cleanup . -This approach allows -.Fn ENGINE_cleanup -to clean up after any -.Nm engine -functionality at all that your program uses, yet doesn't automatically -create linker dependencies to all possible -.Nm engine -functionality - only the cleanup callbacks required by the functionality -you do use will be required by the linker. -.Pp -The fact that -.Vt ENGINE Ns s -are made visible to OpenSSL (and thus are linked into the program -and loaded into memory at run-time) does not mean they are "registered" -or called into use by OpenSSL automatically - that behaviour is -something for the application to control. -Some applications will want to allow the user to specify exactly which -.Vt ENGINE -they want used if any is to be used at all. -Others may prefer to load all support and have OpenSSL automatically use -at run-time any -.Vt ENGINE -that is able to successfully initialised - i.e. to assume that this -corresponds to acceleration hardware attached to the machine or -some such thing. -There are probably numerous other ways in which applications may prefer -to handle things, so we will simply illustrate the consequences as they -apply to a couple of simple cases and leave developers to consider these -and the source code to openssl's builtin utilities as guides. -.Pp -.Em Using a specific ENGINE implementation -.Pp -Here we'll assume an application has been configured by its user or -admin to want to use the "ACME" -.Vt ENGINE -if it is available in the version of OpenSSL the application was -compiled with. -If it is available, it should be used by default for all RSA, DSA, and -symmetric cipher operations, otherwise OpenSSL should use its builtin -software as usual. -The following code illustrates how to approach this: -.Bd -literal -ENGINE *e; -const char *engine_id = "ACME"; -ENGINE_load_builtin_engines(); -e = ENGINE_by_id(engine_id); -if (!e) - /* the engine isn't available */ - return; -if (!ENGINE_init(e)) { - /* the engine couldn't initialise, release 'e' */ - ENGINE_free(e); - return; -} -if (!ENGINE_set_default_RSA(e)) - /* This should only happen when 'e' can't initialise, but the previous - * statement suggests it did. */ - abort(); -ENGINE_set_default_DSA(e); -ENGINE_set_default_ciphers(e); -/* Release the functional reference from ENGINE_init() */ -ENGINE_finish(e); -/* Release the structural reference from ENGINE_by_id() */ -ENGINE_free(e); -.Ed -.Pp -.Em Automatically using builtin ENGINE implementations -.Pp -Here we'll assume we want to load and register all -.Vt ENGINE -implementations bundled with OpenSSL, such that for any cryptographic -algorithm required by OpenSSL - if there is an -.Vt ENGINE -that implements it and can be initialised, it should be used. -The following code illustrates how this can work; -.Bd -literal -/* Load all bundled ENGINEs into memory and make them visible */ -ENGINE_load_builtin_engines(); -/* Register all of them for every algorithm they collectively implement */ -ENGINE_register_all_complete(); -.Ed -.Pp -That's all that's required. -For example, the next time OpenSSL tries to set up an RSA key, any bundled -.Vt ENGINE Ns s -that implement -.Vt RSA_METHOD -will be passed to -.Fn ENGINE_init -and if any of those succeed, that -.Vt ENGINE -will be set as the default for RSA use from then on. -.Ss Advanced configuration support -There is a mechanism supported by the -.Nm engine -framework that allows each -.Vt ENGINE -implementation to define an arbitrary set of configuration -"commands" and expose them to OpenSSL and any applications based on -OpenSSL. -This mechanism is entirely based on the use of name-value pairs -and assumes ASCII input (no unicode or UTF for now!), so it is ideal if -applications want to provide a transparent way for users to provide -arbitrary configuration "directives" directly to such -.Vt ENGINE Ns s . -It is also possible for the application to dynamically interrogate the -loaded -.Vt ENGINE -implementations for the names, descriptions, and input flags of -their available "control commands", providing a more flexible -configuration scheme. -However, if the user is expected to know which -.Vt ENGINE -device he/she is using (in the case of specialised hardware, this -goes without saying) then applications may not need to concern -themselves with discovering the supported control commands and -simply prefer to pass settings into -.Vt ENGINE s -exactly as they are provided by the user. -.Pp -Before illustrating how control commands work, it is worth mentioning -what they are typically used for. -Broadly speaking there are two uses for control commands; the first is -to provide the necessary details to the implementation (which may know -nothing at all specific to the host system) so that it can be -initialised for use. -This could include the path to any driver or config files it needs to -load, required network addresses, smart-card identifiers, passwords to -initialise protected devices, logging information, etc. -This class of commands typically needs to be passed to an -.Vt ENGINE -.Sy before -attempting to initialise it, i.e. before calling -.Fn ENGINE_init . -The other class of commands consist of settings or operations that tweak -certain behaviour or cause certain operations to take place, and these -commands may work either before or after -.Fn ENGINE_init , -or in some cases both. -.Vt ENGINE -implementations should provide indications of this in the descriptions -attached to builtin control commands and/or in external product -documentation. -.Pp -.Em Issuing control commands to an ENGINE -.Pp -Let's illustrate by example; a function for which the caller supplies -the name of the -.Vt ENGINE -it wishes to use, a table of string-pairs for use before initialisation, -and another table for use after initialisation. -Note that the string-pairs used for control commands consist of a -command "name" followed by the command "parameter" - the parameter -could be -.Dv NULL -in some cases but the name cannot. -This function should initialise the -.Vt ENGINE -(issuing the "pre" commands beforehand and the "post" commands -afterwards) and set it as the default for everything except RAND -and then return a boolean success or failure. -.Bd -literal -int -generic_load_engine_fn(const char *engine_id, - const char **pre_cmds, int pre_num, - const char **post_cmds, int post_num) -{ - ENGINE *e = ENGINE_by_id(engine_id); - - if (!e) - return 0; - while (pre_num--) { - if (!ENGINE_ctrl_cmd_string(e, - pre_cmds[0], pre_cmds[1], 0)) { - fprintf(stderr, - "Failed command (%s - %s:%s)\en", - engine_id, pre_cmds[0], - pre_cmds[1] ? pre_cmds[1] : "(NULL)"); - ENGINE_free(e); - return 0; - } - pre_cmds += 2; - } - if (!ENGINE_init(e)) { - fprintf(stderr, "Failed initialisation\en"); - ENGINE_free(e); - return 0; - } - /* - * ENGINE_init() returned a functional reference, - * so free the structural reference from - * ENGINE_by_id(). - */ - ENGINE_free(e); - while (post_num--) { - if (!ENGINE_ctrl_cmd_string(e, - post_cmds[0], post_cmds[1], 0)) { - fprintf(stderr, - "Failed command (%s - %s:%s)\en", - engine_id, post_cmds[0], - post_cmds[1] ? post_cmds[1] : "(NULL)"); - ENGINE_finish(e); - return 0; - } - post_cmds += 2; - } - ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND); - /* Success */ - return 1; -} -.Ed -.Pp -Note that -.Fn ENGINE_ctrl_cmd_string -accepts a boolean argument that can relax the semantics of the function. -If set to non-zero it will only return failure if the -.Vt ENGINE -supported the given command name but failed while executing it, if the -.Vt ENGINE -doesn't support the command name it will simply return success without -doing anything. -In this case we assume the user is only supplying commands specific to -the given -.Vt ENGINE -so we set this to FALSE. -.Pp -.Em Discovering supported control commands -.Pp -It is possible to discover at run-time the names, numerical-ids, -descriptions and input parameters of the control commands supported by an -.Vt ENGINE -using a structural reference. -Note that some control commands are defined by OpenSSL itself and it -will intercept and handle these control commands on behalf of the -.Vt ENGINE , -i.e. the -.Vt ENGINE Ap s -ctrl() handler is not used for the control command. -.In openssl/engine.h -defines an index, -.Dv ENGINE_CMD_BASE , -that all control commands implemented by -.Vt ENGINE Ns s -should be numbered from. -Any command value lower than this symbol is considered a "generic" -command is handled directly by the OpenSSL core routines. -.Pp -It is using these "core" control commands that one can discover the -control commands implemented by a given -.Vt ENGINE , -specifically the commands: -.Bd -literal -#define ENGINE_HAS_CTRL_FUNCTION 10 -#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 -#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 -#define ENGINE_CTRL_GET_CMD_FROM_NAME 13 -#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 -#define ENGINE_CTRL_GET_NAME_FROM_CMD 15 -#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 -#define ENGINE_CTRL_GET_DESC_FROM_CMD 17 -#define ENGINE_CTRL_GET_CMD_FLAGS 18 -.Ed -.Pp -Whilst these commands are automatically processed by the OpenSSL -framework code, they use various properties exposed by each -.Vt ENGINE -to process these queries. -An -.Vt ENGINE -has 3 properties it exposes that can affect how this behaves; -it can supply a ctrl() handler, it can specify -.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL -in the -.Vt ENGINE Ap s -flags, and it can expose an array of control command descriptions. -If an -.Vt ENGINE -specifies the -.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL -flag, then it will simply pass all these "core" control commands -directly to the -.Vt ENGINE Ap s -ctrl() handler (and thus, it must have supplied one), so it is up -to the -.Vt ENGINE -to reply to these "discovery" commands itself. -If that flag is not set, then the OpenSSL framework code will work with -the following rules; -.Bl -tag -width Ds -.It If no ctrl() handler is supplied: -.Dv ENGINE_HAS_CTRL_FUNCTION -returns FALSE (zero), all other commands fail. -.It If a ctrl() handler was supplied but no array of control commands: -.Dv ENGINE_HAS_CTRL_FUNCTION -returns TRUE, all other commands fail. -.It If a ctrl() handler and array of control commands was supplied: -.Dv ENGINE_HAS_CTRL_FUNCTION -returns TRUE, all other commands proceed processing... -.El -.Pp -If the -.Vt ENGINE Ns s -array of control commands is empty, then all other commands will fail. -Otherwise -.Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE -returns the identifier of the first command supported by the -.Vt ENGINE , -.Dv ENGINE_GET_NEXT_CMD_TYPE -takes the identifier of a command supported by the -.Vt ENGINE -and returns the next command identifier or fails if there are no more, -.Dv ENGINE_CMD_FROM_NAME -takes a string name for a command and returns the corresponding -identifier or fails if no such command name exists, and the remaining -commands take a command identifier and return properties of the -corresponding commands. -All except -.Dv ENGINE_CTRL_GET_FLAGS -return the string length of a command name or description, or -populate a supplied character buffer with a copy of the command -name or description. -.Dv ENGINE_CTRL_GET_FLAGS -returns a bitwise-OR'd mask of the following possible values: -.Bd -literal -#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 -#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 -#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 -#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 -.Ed -.Pp -If the -.Dv ENGINE_CMD_FLAG_INTERNAL -flag is set, then any other flags are purely informational to the caller. -This flag will prevent the command being usable for any higher-level -.Vt ENGINE -functions such as -.Fn ENGINE_ctrl_cmd_string . -"INTERNAL" commands are not intended to be exposed to text-based -configuration by applications, administrations, users, etc. -These can support arbitrary operations via -.Fn ENGINE_ctrl , -including passing to and/or from the control commands data of any -arbitrary type. -These commands are supported in the discovery mechanisms simply allow -applications to determine if an -.Vt ENGINE -supports certain specific commands it might want to use (e.g. -application "foo" might query various -.Vt ENGINE Ns s -to see if they implement "FOO_GET_VENDOR_LOGO_GIF" - and -.Vt ENGINE -could therefore decide whether or not to support this "foo"-specific -extension). -.Sh RETURN VALUES -.Fn ENGINE_get_first , -.Fn ENGINE_get_last , -.Fn ENGINE_get_next , -.Fn ENGINE_get_prev , -.Fn ENGINE_by_id , -.Fn ENGINE_get_cipher_engine , -.Fn ENGINE_get_digest_engine , -.Fn ENGINE_new , -and all -.Fn ENGINE_get_default_* -functions return a valid -.Vt ENGINE -structure or -.Dv NULL -if an error occurred. -.Pp -.Fn ENGINE_add , -.Fn ENGINE_remove , -.Fn ENGINE_init , -.Fn ENGINE_finish , -.Fn ENGINE_ctrl_cmd , -.Fn ENGINE_ctrl_cmd_string , -.Fn ENGINE_free , -.Fn ENGINE_up_ref , -and all -.Fn ENGINE_set_* -and -.Fn ENGINE_register_* -functions return 1 on success or 0 on error. -.Pp -.Fn ENGINE_get_table_flags -returns an unsigned integer value representing the global table -flags which are used to control the registration behaviour of -.Vt ENGINE -implementations. -.Pp -For -.Fn ENGINE_ctrl , -positive return values indicate success and negative return values -indicate failure. -The meaning of a zero return value depends on the particular -.Fa cmd -and may indicate both success and failure, which is pathetic. -.Pp -.Fn ENGINE_cmd_is_executable -returns 1 if -.Fa cmd -is executable or 0 otherwise. -.Pp -.Fn ENGINE_get_id -and -.Fn ENGINE_get_name -return a pointer to an internal string representing the identifier -and the name of -.Fa e , -respectively. -.Pp -.Fn ENGINE_get_RSA , -.Fn ENGINE_get_DSA , -.Fn ENGINE_get_DH , -.Fn ENGINE_get_RAND , -and -.Fn ENGINE_get_STORE -return a method structure for the respective algorithm. -.Pp -.Fn ENGINE_get_destroy_function , -.Fn ENGINE_get_init_function , -.Fn ENGINE_get_finish_function , -.Fn ENGINE_get_ctrl_function , -.Fn ENGINE_get_load_privkey_function , -.Fn ENGINE_get_load_pubkey_function , -.Fn ENGINE_get_ciphers , -and -.Fn ENGINE_get_digests -return a function pointer to the respective callback. -.Pp -.Fn ENGINE_get_cipher -returns a valid -.Vt EVP_CIPHER -structure on success or -.Dv NULL -if an error occurred. -.Pp -.Fn ENGINE_get_digest -returns a valid -.Vt EVP_MD -structure on success or -.Dv NULL -if an error occurred. -.Pp -.Fn ENGINE_get_flags -returns an integer representing the flags -which are used to control various behaviours of an -.Vt ENGINE . -.Pp -.Fn ENGINE_get_cmd_defns -returns an -.Vt ENGINE_CMD_DEFN -structure or -.Dv NULL -if none is set. -.Pp -.Fn ENGINE_load_private_key -and -.Fn ENGINE_load_public_key -return a valid -.Vt EVP_PKEY -structure on success or -.Dv NULL -if an error occurred. -.Sh SEE ALSO -.Xr DH_new 3 , -.Xr DSA_new 3 , -.Xr ENGINE_add_conf_module 3 , -.Xr ENGINE_set_ex_data 3 , -.Xr RSA_new 3 -.Sh HISTORY -The engine API first appeared in OpenSSL 0.9.7 -and has been available since -.Ox 3.2 . diff --git a/lib/libcrypto/man/evp.3 b/lib/libcrypto/man/evp.3 index 2d927de6a1..085db2eb6e 100644 --- a/lib/libcrypto/man/evp.3 +++ b/lib/libcrypto/man/evp.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: evp.3,v 1.4 2016/12/06 15:15:26 schwarze Exp $ +.\" $OpenBSD: evp.3,v 1.5 2018/04/18 01:12:11 schwarze Exp $ .\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100 .\" .\" This file was written by Ulf Moeller , @@ -51,7 +51,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 6 2016 $ +.Dd $Mdocdate: April 18 2018 $ .Dt EVP 3 .Os .Sh NAME @@ -158,16 +158,15 @@ Algorithms are loaded with .Pp All the symmetric algorithms (ciphers), digests and asymmetric algorithms (public key algorithms) can be replaced by -.Xr engine 3 -modules providing alternative implementations. +.Vt ENGINE +modules providing alternative implementations; see +.Xr ENGINE_register_RSA 3 +and the related manual pages for more information. If .Vt ENGINE implementations of ciphers or digests are registered as defaults, then the various EVP functions will automatically use those implementations in preference to built in software implementations. -For more information, consult the -.Xr engine 3 -manual page. .Pp Although low level algorithm specific functions exist for many algorithms, their use is discouraged. @@ -181,7 +180,7 @@ Using them also makes code harder to adapt to new algorithms, some options are not cleanly supported at the low level, and some operations are more efficient using the high level interfaces. .Sh SEE ALSO -.Xr engine 3 , +.Xr ENGINE_register_RSA 3 , .Xr EVP_AEAD_CTX_init 3 , .Xr EVP_BytesToKey 3 , .Xr EVP_DigestInit 3 , diff --git a/lib/libcrypto/man/lh_new.3 b/lib/libcrypto/man/lh_new.3 index 4f2f3a152a..3be32cf675 100644 --- a/lib/libcrypto/man/lh_new.3 +++ b/lib/libcrypto/man/lh_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: lh_new.3,v 1.3 2016/11/28 14:31:20 schwarze Exp $ +.\" $OpenBSD: lh_new.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 1bc74519 May 20 08:11:46 2016 -0400 .\" .\" -------------------------------------------------------------------------- @@ -115,7 +115,7 @@ .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" -.Dd $Mdocdate: November 28 2016 $ +.Dd $Mdocdate: March 27 2018 $ .Dt LH_NEW 3 .Os .Sh NAME @@ -525,7 +525,19 @@ rather it would be used in the function passed to .Sh SEE ALSO .Xr lh_stats 3 .Sh HISTORY -The lhash library is available in all versions of SSLeay and OpenSSL. +.Fn lh_new , +.Fn lh_free , +.Fn lh_insert , +.Fn lh_delete , +.Fn lh_retrieve , +and +.Fn lh_doall +appeared in SSLeay 0.4 or earlier. +.Fn lh_doall_arg +first appeared in SSLeay 0.5.1. +These functions have been available since +.Ox 2.4 . +.Pp .Fn lh__error was added in SSLeay 0.9.1b. .Pp diff --git a/lib/libcrypto/man/lh_stats.3 b/lib/libcrypto/man/lh_stats.3 index 90bd1c9893..e057d7d65e 100644 --- a/lib/libcrypto/man/lh_stats.3 +++ b/lib/libcrypto/man/lh_stats.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: lh_stats.3,v 1.5 2016/12/06 12:24:33 schwarze Exp $ +.\" $OpenBSD: lh_stats.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL e2f92610 May 18 11:44:05 2016 -0400 .\" .\" -------------------------------------------------------------------------- @@ -113,7 +113,7 @@ .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" -.Dd $Mdocdate: December 6 2016 $ +.Dd $Mdocdate: March 27 2018 $ .Dt LH_STATS 3 .Os .Sh NAME @@ -193,6 +193,16 @@ These functions do not return values. .Xr BIO_new 3 , .Xr lh_new 3 .Sh HISTORY -These functions are available in all versions of SSLeay and OpenSSL. +.Fn lh_stats , +.Fn lh_node_stats , +.Fn lh_node_usage_stats +appeared in SSLeay 0.4. +.Fn lh_stats_bio , +.Fn lh_node_stats_bio , +and +.Fn lh_node_usage_stats_bio +first appeared in SSLeay 0.6.0. +These functions have been available since +.Ox 2.4 . .Sh AUTHORS .An Eric Young diff --git a/lib/libcrypto/man/x509v3.cnf.5 b/lib/libcrypto/man/x509v3.cnf.5 index fcdf06301a..d307e6a1d0 100644 --- a/lib/libcrypto/man/x509v3.cnf.5 +++ b/lib/libcrypto/man/x509v3.cnf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: x509v3.cnf.5,v 1.4 2018/02/16 18:48:55 schwarze Exp $ +.\" $OpenBSD: x509v3.cnf.5,v 1.5 2018/08/26 18:04:54 jmc Exp $ .\" full merge up to: .\" OpenSSL man5/x509v3_config a41815f0 Mar 17 18:43:53 2017 -0700 .\" selective merge up to: OpenSSL 36cf10cf Oct 4 02:11:08 2017 -0400 @@ -51,7 +51,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: February 16 2018 $ +.Dd $Mdocdate: August 26 2018 $ .Dt X509V3.CNF 5 .Os .Sh NAME @@ -130,7 +130,7 @@ is .Cm TRUE , then an optional .Ic pathlen -name followed by an non-negative value can be included. +name followed by a non-negative value can be included. For example: .Bd -literal -offset indent basicConstraints=CA:TRUE diff --git a/lib/libcrypto/mem_dbg.c b/lib/libcrypto/mem_dbg.c index cae02a6f21..64bc46a5dc 100644 --- a/lib/libcrypto/mem_dbg.c +++ b/lib/libcrypto/mem_dbg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem_dbg.c,v 1.22 2014/06/12 15:49:27 deraadt Exp $ */ +/* $OpenBSD: mem_dbg.c,v 1.23 2018/08/24 19:16:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -181,21 +181,21 @@ CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, abort(); } -void +int CRYPTO_mem_leaks(BIO *b) { - return; + return -1; } -void +int CRYPTO_mem_leaks_fp(FILE *fp) { - return; + return -1; } -void +int CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb) { - return; + return -1; } diff --git a/lib/libcrypto/modes/modes.h b/lib/libcrypto/modes/modes.h index a532cb3f41..67ec7518d6 100644 --- a/lib/libcrypto/modes/modes.h +++ b/lib/libcrypto/modes/modes.h @@ -1,4 +1,4 @@ -/* $OpenBSD: modes.h,v 1.2 2014/06/12 15:49:30 deraadt Exp $ */ +/* $OpenBSD: modes.h,v 1.3 2018/07/24 10:47:19 bcook Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * @@ -8,6 +8,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + typedef void (*block128_f)(const unsigned char in[16], unsigned char out[16], const void *key); @@ -134,3 +138,7 @@ typedef struct xts128_context XTS128_CONTEXT; int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16], const unsigned char *inp, unsigned char *out, size_t len, int enc); + +#ifdef __cplusplus +} +#endif diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index 5b7fac0588..6c50aa980a 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.39 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.41 2018/09/08 13:49:26 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -328,12 +328,12 @@ OBJ_add_object(const ASN1_OBJECT *obj) return (o->nid); -err2: + err2: OBJerror(ERR_R_MALLOC_FAILURE); -err: + err: for (i = ADDED_DATA; i <= ADDED_NID; i++) free(ao[i]); - free(o); + ASN1_OBJECT_free(o); return (NID_undef); } @@ -632,11 +632,11 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) } } -out: + out: BN_free(bl); return ret; -err: + err: ret = 0; goto out; } @@ -810,7 +810,7 @@ OBJ_create(const char *oid, const char *sn, const char *ln) goto err; ok = OBJ_add_object(op); -err: + err: ASN1_OBJECT_free(op); free(buf); return (ok); diff --git a/lib/libcrypto/objects/obj_lib.c b/lib/libcrypto/objects/obj_lib.c index 53f3bb9ebe..5327a0cb98 100644 --- a/lib/libcrypto/objects/obj_lib.c +++ b/lib/libcrypto/objects/obj_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_lib.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: obj_lib.c,v 1.15 2018/09/08 10:31:24 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -109,7 +109,7 @@ OBJ_dup(const ASN1_OBJECT *o) ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA); return (r); -err: + err: OBJerror(ERR_R_MALLOC_FAILURE); free(ln); free(sn); diff --git a/lib/libcrypto/objects/objects.README b/lib/libcrypto/objects/objects.README index 4d745508d8..c49e93d679 100644 --- a/lib/libcrypto/objects/objects.README +++ b/lib/libcrypto/objects/objects.README @@ -1,7 +1,7 @@ objects.txt syntax ------------------ -To cover all the naming hacks that were previously in objects.h needed some +To cover all the naming hacks that were previously in objects.h, we needed some kind of hacks in objects.txt. The basic syntax for adding an object is as follows: @@ -16,13 +16,13 @@ The basic syntax for adding an object is as follows: create the C macros SN_base, LN_base, NID_base and OBJ_base. Note that if the base name contains spaces, dashes or periods, - those will be converte to underscore. + those will be converted to underscore. Then there are some extra commands: !Alias foo 1 2 3 4 - This juts makes a name foo for an OID. The C macro + This just makes a name foo for an OID. The C macro OBJ_foo will be created as a result. !Cname foo diff --git a/lib/libcrypto/ocsp/ocsp.h b/lib/libcrypto/ocsp/ocsp.h index b2c4367f83..316fb8ed93 100644 --- a/lib/libcrypto/ocsp/ocsp.h +++ b/lib/libcrypto/ocsp/ocsp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp.h,v 1.12 2018/03/17 14:44:34 jsing Exp $ */ +/* $OpenBSD: ocsp.h,v 1.16 2018/08/24 20:03:21 tb Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ @@ -383,8 +383,8 @@ typedef struct ocsp_service_locator_st { OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id); -OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req); -OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req, +OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req); +OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req, int maxline); int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx); void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx); @@ -392,10 +392,11 @@ int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req); int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, const char *name, const char *value); -OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer); +OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, + const X509 *issuer); -OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, X509_NAME *issuerName, - ASN1_BIT_STRING* issuerKey, ASN1_INTEGER *serialNumber); +OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, const X509_NAME *issuerName, + const ASN1_BIT_STRING *issuerKey, const ASN1_INTEGER *serialNumber); OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); @@ -428,8 +429,8 @@ int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags); -int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, - int *pssl); +int OCSP_parse_url(const char *url, char **phost, char **pport, + char **ppath, int *pssl); int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b); int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); @@ -449,17 +450,17 @@ int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); int OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags); -X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); +X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim); X509_EXTENSION *OCSP_accept_responses_new(char **oids); X509_EXTENSION *OCSP_archive_cutoff_new(char* tim); -X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls); +X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, const char **urls); int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); -int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, +int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj, int lastpos); int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); @@ -472,7 +473,7 @@ int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); -int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, +int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos); int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); @@ -484,7 +485,7 @@ int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); -int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, +int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj, int lastpos); int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos); @@ -499,8 +500,8 @@ int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); -int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, - int lastpos); +int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, + const ASN1_OBJECT *obj, int lastpos); int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos); X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); diff --git a/lib/libcrypto/ocsp/ocsp_ext.c b/lib/libcrypto/ocsp/ocsp_ext.c index 1f2563ca8a..eb51cfbff5 100644 --- a/lib/libcrypto/ocsp/ocsp_ext.c +++ b/lib/libcrypto/ocsp/ocsp_ext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_ext.c,v 1.15 2016/12/27 16:01:19 jsing Exp $ */ +/* $OpenBSD: ocsp_ext.c,v 1.18 2018/05/14 23:47:10 tb Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ @@ -88,7 +88,8 @@ OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos) } int -OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos) +OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj, + int lastpos) { return X509v3_get_ext_by_OBJ(x->tbsRequest->requestExtensions, obj, lastpos); @@ -149,7 +150,7 @@ OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos) } int -OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos) +OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(x->singleRequestExtensions, obj, lastpos); } @@ -209,7 +210,8 @@ OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos) } int -OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos) +OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj, + int lastpos) { return X509v3_get_ext_by_OBJ(x->tbsResponseData->responseExtensions, obj, lastpos); @@ -271,7 +273,7 @@ OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos) } int -OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, +OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(x->singleExtensions, obj, lastpos); @@ -435,7 +437,7 @@ OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req) } X509_EXTENSION * -OCSP_crlID_new(char *url, long *n, char *tim) +OCSP_crlID_new(const char *url, long *n, char *tim) { X509_EXTENSION *x = NULL; OCSP_CRLID *cid = NULL; @@ -517,7 +519,7 @@ err: * method forces NID_ad_ocsp and uniformResourceLocator [6] IA5String. */ X509_EXTENSION * -OCSP_url_svcloc_new(X509_NAME* issuer, char **urls) +OCSP_url_svcloc_new(X509_NAME* issuer, const char **urls) { X509_EXTENSION *x = NULL; ASN1_IA5STRING *ia5 = NULL; diff --git a/lib/libcrypto/ocsp/ocsp_ht.c b/lib/libcrypto/ocsp/ocsp_ht.c index b9c969928a..255f890397 100644 --- a/lib/libcrypto/ocsp/ocsp_ht.c +++ b/lib/libcrypto/ocsp/ocsp_ht.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_ht.c,v 1.24 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ocsp_ht.c,v 1.25 2018/05/13 10:42:03 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -149,7 +149,7 @@ OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, const char *name, } OCSP_REQ_CTX * -OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req, int maxline) +OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req, int maxline) { OCSP_REQ_CTX *rctx; @@ -440,7 +440,7 @@ next_line: /* Blocking OCSP request handler: now a special case of non-blocking I/O */ OCSP_RESPONSE * -OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req) +OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req) { OCSP_RESPONSE *resp = NULL; OCSP_REQ_CTX *ctx; diff --git a/lib/libcrypto/ocsp/ocsp_lib.c b/lib/libcrypto/ocsp/ocsp_lib.c index d56a002096..53d516020d 100644 --- a/lib/libcrypto/ocsp/ocsp_lib.c +++ b/lib/libcrypto/ocsp/ocsp_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_lib.c,v 1.20 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ocsp_lib.c,v 1.23 2018/08/24 20:03:21 tb Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ @@ -77,10 +77,10 @@ /* Convert a certificate and its issuer to an OCSP_CERTID */ OCSP_CERTID * -OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer) +OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, const X509 *issuer) { X509_NAME *iname; - ASN1_INTEGER *serial; + const ASN1_INTEGER *serial; ASN1_BIT_STRING *ikey; #ifndef OPENSSL_NO_SHA1 @@ -89,7 +89,7 @@ OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer) #endif if (subject) { iname = X509_get_issuer_name(subject); - serial = X509_get_serialNumber(subject); + serial = X509_get0_serialNumber(subject); } else { iname = X509_get_subject_name(issuer); serial = NULL; @@ -99,8 +99,8 @@ OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer) } OCSP_CERTID * -OCSP_cert_id_new(const EVP_MD *dgst, X509_NAME *issuerName, - ASN1_BIT_STRING* issuerKey, ASN1_INTEGER *serialNumber) +OCSP_cert_id_new(const EVP_MD *dgst, const X509_NAME *issuerName, + const ASN1_BIT_STRING *issuerKey, const ASN1_INTEGER *serialNumber) { int nid; unsigned int i; @@ -180,7 +180,8 @@ OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b) * it is SSL. */ int -OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl) +OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, + int *pssl) { char *host, *path, *port, *tmp; diff --git a/lib/libcrypto/opensslv.h b/lib/libcrypto/opensslv.h index c882e09a32..1cd48ce80f 100644 --- a/lib/libcrypto/opensslv.h +++ b/lib/libcrypto/opensslv.h @@ -1,11 +1,11 @@ -/* $OpenBSD: opensslv.h,v 1.46.2.2 2018/06/13 14:54:17 bcook Exp $ */ +/* $OpenBSD: opensslv.h,v 1.49 2018/09/30 02:35:23 bcook Exp $ */ #ifndef HEADER_OPENSSLV_H #define HEADER_OPENSSLV_H /* These will change with each release of LibreSSL-portable */ -#define LIBRESSL_VERSION_NUMBER 0x2070400fL +#define LIBRESSL_VERSION_NUMBER 0x2080200fL /* ^ Patch starts here */ -#define LIBRESSL_VERSION_TEXT "LibreSSL 2.7.4" +#define LIBRESSL_VERSION_TEXT "LibreSSL 2.8.2" /* These will never change */ #define OPENSSL_VERSION_NUMBER 0x20000000L diff --git a/lib/libcrypto/pem/pem.h b/lib/libcrypto/pem/pem.h index d1916a1833..adc85226e8 100644 --- a/lib/libcrypto/pem/pem.h +++ b/lib/libcrypto/pem/pem.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pem.h,v 1.17 2016/09/04 16:22:54 jsing Exp $ */ +/* $OpenBSD: pem.h,v 1.19 2018/08/24 19:51:31 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -385,8 +385,8 @@ int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, #ifndef OPENSSL_NO_BIO int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data, long *len); -int PEM_write_bio(BIO *bp, const char *name, char *hdr, unsigned char *data, - long len); +int PEM_write_bio(BIO *bp, const char *name, const char *hdr, + const unsigned char *data, long len); int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, pem_password_cb *cb, void *u); void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, @@ -403,8 +403,8 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, int PEM_read(FILE *fp, char **name, char **header, unsigned char **data, long *len); -int PEM_write(FILE *fp, char *name, char *hdr, unsigned char *data, - long len); +int PEM_write(FILE *fp, const char *name, const char *hdr, + const unsigned char *data, long len); void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, pem_password_cb *cb, void *u); int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, @@ -421,8 +421,8 @@ void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl, unsigned char *out, int *outl, EVP_PKEY *priv); -void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); -void PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt); +int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt); int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey); diff --git a/lib/libcrypto/pem/pem_lib.c b/lib/libcrypto/pem/pem_lib.c index 0f7c36d21c..6661a222f0 100644 --- a/lib/libcrypto/pem/pem_lib.c +++ b/lib/libcrypto/pem/pem_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_lib.c,v 1.45 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: pem_lib.c,v 1.48 2018/08/24 19:48:39 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -227,8 +227,7 @@ check_pem(const char *nm, const char *name) else r = 0; #ifndef OPENSSL_NO_ENGINE - if (e) - ENGINE_finish(e); + ENGINE_finish(e); #endif return r; } @@ -565,7 +564,8 @@ load_iv(char **fromp, unsigned char *to, int num) } int -PEM_write(FILE *fp, char *name, char *header, unsigned char *data, long len) +PEM_write(FILE *fp, const char *name, const char *header, + const unsigned char *data, long len) { BIO *b; int ret; @@ -581,8 +581,8 @@ PEM_write(FILE *fp, char *name, char *header, unsigned char *data, long len) } int -PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data, - long len) +PEM_write_bio(BIO *bp, const char *name, const char *header, + const unsigned char *data, long len) { int nlen, n, i, j, outl; unsigned char *buf = NULL; @@ -613,7 +613,8 @@ PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data, i = j = 0; while (len > 0) { n = (int)((len > (PEM_BUFSIZE * 5)) ? (PEM_BUFSIZE * 5) : len); - EVP_EncodeUpdate(&ctx, buf, &outl, &(data[j]), n); + if (!EVP_EncodeUpdate(&ctx, buf, &outl, &(data[j]), n)) + goto err; if ((outl) && (BIO_write(bp, (char *)buf, outl) != outl)) goto err; i += outl; diff --git a/lib/libcrypto/pem/pem_sign.c b/lib/libcrypto/pem/pem_sign.c index a225e8970f..fddeec79f3 100644 --- a/lib/libcrypto/pem/pem_sign.c +++ b/lib/libcrypto/pem/pem_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_sign.c,v 1.13 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: pem_sign.c,v 1.14 2018/08/24 19:51:31 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,17 +64,17 @@ #include #include -void +int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) { - EVP_DigestInit_ex(ctx, type, NULL); + return EVP_DigestInit_ex(ctx, type, NULL); } -void +int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, unsigned int count) { - EVP_DigestUpdate(ctx, data, count); + return EVP_DigestUpdate(ctx, data, count); } int diff --git a/lib/libcrypto/pem/pvkfmt.c b/lib/libcrypto/pem/pvkfmt.c index 18de5d52a4..76cc6fefe3 100644 --- a/lib/libcrypto/pem/pvkfmt.c +++ b/lib/libcrypto/pem/pvkfmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pvkfmt.c,v 1.19 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: pvkfmt.c,v 1.20 2018/08/05 11:19:25 bcook Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ @@ -847,17 +847,10 @@ i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, pem_password_cb *cb, if (pklen < 0) return -1; outlen += pklen; - if (!out) - return outlen; - if (*out) - p = *out; - else { - p = malloc(outlen); - if (!p) { - PEMerror(ERR_R_MALLOC_FAILURE); - return -1; - } - *out = p; + p = malloc(outlen); + if (!p) { + PEMerror(ERR_R_MALLOC_FAILURE); + return -1; } write_ledword(&p, MS_PVKMAGIC); @@ -875,9 +868,10 @@ i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, pem_password_cb *cb, p += PVK_SALTLEN; } do_i2b(&p, pk, 0); - if (enclevel == 0) + if (enclevel == 0) { + *out = p; return outlen; - else { + } else { char psbuf[PEM_BUFSIZE]; unsigned char keybuf[20]; int enctmplen, inlen; @@ -904,10 +898,12 @@ i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, pem_password_cb *cb, goto error; } EVP_CIPHER_CTX_cleanup(&cctx); + *out = p; return outlen; error: EVP_CIPHER_CTX_cleanup(&cctx); + free(p); return -1; } diff --git a/lib/libcrypto/pkcs12/p12_add.c b/lib/libcrypto/pkcs12/p12_add.c index 5642a141f5..08bb75d312 100644 --- a/lib/libcrypto/pkcs12/p12_add.c +++ b/lib/libcrypto/pkcs12/p12_add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_add.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: p12_add.c,v 1.17 2018/05/13 14:24:07 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -232,7 +232,7 @@ PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen) } PKCS8_PRIV_KEY_INFO * -PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, int passlen) +PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, const char *pass, int passlen) { return PKCS8_decrypt(bag->value.shkeybag, pass, passlen); } @@ -247,7 +247,7 @@ PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes) } STACK_OF(PKCS7) * -PKCS12_unpack_authsafes(PKCS12 *p12) +PKCS12_unpack_authsafes(const PKCS12 *p12) { if (!PKCS7_type_is_data(p12->authsafes)) { PKCS12error(PKCS12_R_CONTENT_TYPE_NOT_DATA); diff --git a/lib/libcrypto/pkcs12/p12_attr.c b/lib/libcrypto/pkcs12/p12_attr.c index 7552cf0a60..65bfaa039e 100644 --- a/lib/libcrypto/pkcs12/p12_attr.c +++ b/lib/libcrypto/pkcs12/p12_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_attr.c,v 1.10 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: p12_attr.c,v 1.12 2018/08/24 20:07:41 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -77,14 +77,10 @@ PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen) int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage) { - unsigned char us_val; + unsigned char us_val = (unsigned char)usage; - us_val = (unsigned char) usage; - if (X509at_add1_attr_by_NID(&p8->attributes, NID_key_usage, - V_ASN1_BIT_STRING, &us_val, 1)) - return 1; - else - return 0; + return PKCS8_pkey_add1_attr_by_NID(p8, NID_key_usage, V_ASN1_BIT_STRING, + &us_val, 1); } /* Add a friendlyname to a safebag */ @@ -122,7 +118,7 @@ PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen) } ASN1_TYPE * -PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid) +PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid) { X509_ATTRIBUTE *attrib; int i; diff --git a/lib/libcrypto/pkcs12/p12_crt.c b/lib/libcrypto/pkcs12/p12_crt.c index af2c6afc37..f8ba3357e7 100644 --- a/lib/libcrypto/pkcs12/p12_crt.c +++ b/lib/libcrypto/pkcs12/p12_crt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_crt.c,v 1.17 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: p12_crt.c,v 1.18 2018/05/13 13:46:55 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -80,7 +80,7 @@ copy_bag_attr(PKCS12_SAFEBAG *bag, EVP_PKEY *pkey, int nid) } PKCS12 * -PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, +PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, int mac_iter, int keytype) { @@ -221,7 +221,7 @@ err: PKCS12_SAFEBAG * PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, int key_usage, - int iter, int nid_key, char *pass) + int iter, int nid_key, const char *pass) { PKCS12_SAFEBAG *bag = NULL; PKCS8_PRIV_KEY_INFO *p8 = NULL; @@ -261,7 +261,7 @@ err: int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, - int nid_safe, int iter, char *pass) + int nid_safe, int iter, const char *pass) { PKCS7 *p7 = NULL; int free_safes = 0; diff --git a/lib/libcrypto/pkcs12/p12_decr.c b/lib/libcrypto/pkcs12/p12_decr.c index ca08ee55d5..1ef5c4a898 100644 --- a/lib/libcrypto/pkcs12/p12_decr.c +++ b/lib/libcrypto/pkcs12/p12_decr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_decr.c,v 1.18 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: p12_decr.c,v 1.19 2018/05/13 14:22:34 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -67,8 +67,9 @@ */ unsigned char * -PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, int passlen, - unsigned char *in, int inlen, unsigned char **data, int *datalen, int en_de) +PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass, int passlen, + const unsigned char *in, int inlen, unsigned char **data, int *datalen, + int en_de) { unsigned char *out; int outlen, i; @@ -119,8 +120,8 @@ err: */ void * -PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, - const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf) +PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, const ASN1_OCTET_STRING *oct, int zbuf) { unsigned char *out; const unsigned char *p; diff --git a/lib/libcrypto/pkcs12/p12_npas.c b/lib/libcrypto/pkcs12/p12_npas.c index 63b3df17ad..d6b12edab3 100644 --- a/lib/libcrypto/pkcs12/p12_npas.c +++ b/lib/libcrypto/pkcs12/p12_npas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_npas.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: p12_npas.c,v 1.13 2018/05/13 14:22:34 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -65,10 +65,11 @@ /* PKCS#12 password change routine */ -static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass); -static int newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, char *oldpass, - char *newpass); -static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass); +static int newpass_p12(PKCS12 *p12, const char *oldpass, const char *newpass); +static int newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, const char *oldpass, + const char *newpass); +static int newpass_bag(PKCS12_SAFEBAG *bag, const char *oldpass, + const char *newpass); static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen); /* @@ -76,7 +77,7 @@ static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen); */ int -PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass) +PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass) { /* Check for NULL PKCS12 structure */ @@ -103,7 +104,7 @@ PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass) /* Parse the outer PKCS#12 structure */ static int -newpass_p12(PKCS12 *p12, char *oldpass, char *newpass) +newpass_p12(PKCS12 *p12, const char *oldpass, const char *newpass) { STACK_OF(PKCS7) *asafes, *newsafes; STACK_OF(PKCS12_SAFEBAG) *bags; @@ -189,7 +190,8 @@ err: static int -newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, char *oldpass, char *newpass) +newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, const char *oldpass, + const char *newpass) { int i; @@ -204,7 +206,7 @@ newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, char *oldpass, char *newpass) /* Change password of safebag: only needs handle shrouded keybags */ static int -newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass) +newpass_bag(PKCS12_SAFEBAG *bag, const char *oldpass, const char *newpass) { PKCS8_PRIV_KEY_INFO *p8; X509_SIG *p8new; diff --git a/lib/libcrypto/pkcs12/p12_p8d.c b/lib/libcrypto/pkcs12/p12_p8d.c index 68af6bf5b5..0286d4acf5 100644 --- a/lib/libcrypto/pkcs12/p12_p8d.c +++ b/lib/libcrypto/pkcs12/p12_p8d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_p8d.c,v 1.6 2016/12/30 15:34:35 jsing Exp $ */ +/* $OpenBSD: p12_p8d.c,v 1.7 2018/05/13 14:28:14 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -61,7 +61,7 @@ #include PKCS8_PRIV_KEY_INFO * -PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen) +PKCS8_decrypt(const X509_SIG *p8, const char *pass, int passlen) { return PKCS12_item_decrypt_d2i(p8->algor, &PKCS8_PRIV_KEY_INFO_it, pass, passlen, p8->digest, 1); diff --git a/lib/libcrypto/pkcs12/p12_utl.c b/lib/libcrypto/pkcs12/p12_utl.c index eb95417d1b..ff3a035d3f 100644 --- a/lib/libcrypto/pkcs12/p12_utl.c +++ b/lib/libcrypto/pkcs12/p12_utl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_utl.c,v 1.15 2016/12/30 15:34:35 jsing Exp $ */ +/* $OpenBSD: p12_utl.c,v 1.16 2018/05/30 15:32:11 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -100,7 +100,7 @@ OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen) } char * -OPENSSL_uni2asc(unsigned char *uni, int unilen) +OPENSSL_uni2asc(const unsigned char *uni, int unilen) { size_t asclen, u16len, i; char *asctmp; diff --git a/lib/libcrypto/pkcs12/pkcs12.h b/lib/libcrypto/pkcs12/pkcs12.h index e30f9ac790..56635f9d7e 100644 --- a/lib/libcrypto/pkcs12/pkcs12.h +++ b/lib/libcrypto/pkcs12/pkcs12.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs12.h,v 1.17 2016/12/30 15:08:58 jsing Exp $ */ +/* $OpenBSD: pkcs12.h,v 1.24 2018/05/30 15:32:11 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -178,9 +178,10 @@ X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag); PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, int nid2); PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); -PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen); -PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass, int passlen); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, + const char *pass, int passlen); X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, int passlen, unsigned char *salt, int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8); @@ -195,7 +196,7 @@ STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); -STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12); +STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12); int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); @@ -206,13 +207,14 @@ int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, int namelen); int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); -ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid); +ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, + int attr_nid); char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); -unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, - int passlen, unsigned char *in, int inlen, unsigned char **data, +unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass, + int passlen, const unsigned char *in, int inlen, unsigned char **data, int *datalen, int en_de); -void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, - const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf); +void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, const ASN1_OCTET_STRING *oct, int zbuf); ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, const char *pass, int passlen, void *obj, int zbuf); PKCS12 *PKCS12_init(int mode); @@ -235,7 +237,7 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, const EVP_MD *md_type); unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); -char *OPENSSL_uni2asc(unsigned char *uni, int unilen); +char *OPENSSL_uni2asc(const unsigned char *uni, int unilen); PKCS12 *PKCS12_new(void); void PKCS12_free(PKCS12 *a); @@ -264,22 +266,22 @@ extern const ASN1_ITEM PKCS12_AUTHSAFES_it; void PKCS12_PBE_add(void); int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca); -PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, - STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, +PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, + X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, int mac_iter, int keytype); PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, - int key_usage, int iter, int key_nid, char *pass); + int key_usage, int iter, int key_nid, const char *pass); int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, - int safe_nid, int iter, char *pass); + int safe_nid, int iter, const char *pass); PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); -int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); +int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass); /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes diff --git a/lib/libcrypto/rsa/rsa.h b/lib/libcrypto/rsa/rsa.h index 23929aafb9..d2df1a92d3 100644 --- a/lib/libcrypto/rsa/rsa.h +++ b/lib/libcrypto/rsa/rsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.h,v 1.38 2018/03/17 15:12:56 tb Exp $ */ +/* $OpenBSD: rsa.h,v 1.39 2018/09/12 06:35:38 djm Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -433,10 +433,12 @@ RSA *RSAPrivateKey_dup(RSA *rsa); RSA_METHOD *RSA_meth_new(const char *name, int flags); void RSA_meth_free(RSA_METHOD *meth); RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); +int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); int RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); int RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); +int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa); int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa)); /* BEGIN ERROR CODES */ diff --git a/lib/libcrypto/rsa/rsa_ameth.c b/lib/libcrypto/rsa/rsa_ameth.c index ec8a71b7b9..ce3e9b3509 100644 --- a/lib/libcrypto/rsa/rsa_ameth.c +++ b/lib/libcrypto/rsa/rsa_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_ameth.c,v 1.18 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: rsa_ameth.c,v 1.19 2018/08/24 20:22:15 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -154,7 +154,7 @@ rsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) } static int -rsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) +rsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) { const unsigned char *p; int pklen; diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c index 544846f825..84e1dc7eaf 100644 --- a/lib/libcrypto/rsa/rsa_lib.c +++ b/lib/libcrypto/rsa/rsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_lib.c,v 1.36 2018/02/20 17:42:32 tb Exp $ */ +/* $OpenBSD: rsa_lib.c,v 1.37 2018/04/14 07:09:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -114,10 +114,8 @@ RSA_set_method(RSA *rsa, const RSA_METHOD *meth) if (mtmp->finish) mtmp->finish(rsa); #ifndef OPENSSL_NO_ENGINE - if (rsa->engine) { - ENGINE_finish(rsa->engine); - rsa->engine = NULL; - } + ENGINE_finish(rsa->engine); + rsa->engine = NULL; #endif rsa->meth = meth; if (meth->init) @@ -149,7 +147,7 @@ RSA_new_method(ENGINE *engine) ret->engine = ENGINE_get_default_RSA(); if (ret->engine) { ret->meth = ENGINE_get_RSA(ret->engine); - if (!ret->meth) { + if (ret->meth == NULL) { RSAerror(ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); @@ -177,8 +175,7 @@ RSA_new_method(ENGINE *engine) ret->flags = ret->meth->flags & ~RSA_FLAG_NON_FIPS_ALLOW; if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data)) { #ifndef OPENSSL_NO_ENGINE - if (ret->engine) - ENGINE_finish(ret->engine); + ENGINE_finish(ret->engine); #endif free(ret); return NULL; @@ -186,8 +183,7 @@ RSA_new_method(ENGINE *engine) if (ret->meth->init != NULL && !ret->meth->init(ret)) { #ifndef OPENSSL_NO_ENGINE - if (ret->engine) - ENGINE_finish(ret->engine); + ENGINE_finish(ret->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); free(ret); @@ -211,8 +207,7 @@ RSA_free(RSA *r) if (r->meth->finish) r->meth->finish(r); #ifndef OPENSSL_NO_ENGINE - if (r->engine) - ENGINE_finish(r->engine); + ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); diff --git a/lib/libcrypto/rsa/rsa_meth.c b/lib/libcrypto/rsa/rsa_meth.c index 0e52799a38..ae613cc65c 100644 --- a/lib/libcrypto/rsa/rsa_meth.c +++ b/lib/libcrypto/rsa/rsa_meth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_meth.c,v 1.1 2018/03/17 15:12:56 tb Exp $ */ +/* $OpenBSD: rsa_meth.c,v 1.2 2018/09/12 06:35:38 djm Exp $ */ /* * Copyright (c) 2018 Theo Buehler * @@ -63,6 +63,24 @@ RSA_meth_dup(const RSA_METHOD *meth) } int +RSA_meth_set1_name(RSA_METHOD *meth, const char *name) +{ + char *copy; + + if ((copy = strdup(name)) == NULL) + return 0; + free((char *)meth->name); + meth->name = copy; + return 1; +} + +int +(*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa) +{ + return meth->finish; +} + +int RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding)) { diff --git a/lib/libcrypto/rsa/rsa_oaep.c b/lib/libcrypto/rsa/rsa_oaep.c index cd7af203b7..c463a885d2 100644 --- a/lib/libcrypto/rsa/rsa_oaep.c +++ b/lib/libcrypto/rsa/rsa_oaep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_oaep.c,v 1.26 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: rsa_oaep.c,v 1.29 2018/08/19 20:17:20 tb Exp $ */ /* Written by Ulf Moeller. This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ @@ -72,14 +72,18 @@ RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, } if (MGF1(dbmask, emlen - SHA_DIGEST_LENGTH, seed, - SHA_DIGEST_LENGTH) < 0) + SHA_DIGEST_LENGTH) < 0) { + free(dbmask); return 0; + } for (i = 0; i < emlen - SHA_DIGEST_LENGTH; i++) db[i] ^= dbmask[i]; if (MGF1(seedmask, SHA_DIGEST_LENGTH, db, - emlen - SHA_DIGEST_LENGTH) < 0) + emlen - SHA_DIGEST_LENGTH) < 0) { + free(dbmask); return 0; + } for (i = 0; i < SHA_DIGEST_LENGTH; i++) seed[i] ^= seedmask[i]; @@ -122,8 +126,7 @@ RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, } dblen = num - SHA_DIGEST_LENGTH; - db = malloc(dblen + num); - if (db == NULL) { + if ((db = malloc(dblen + num)) == NULL) { RSAerror(ERR_R_MALLOC_FAILURE); return -1; } @@ -139,17 +142,17 @@ RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, maskeddb = padded_from + SHA_DIGEST_LENGTH; if (MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen)) - return -1; + goto err; for (i = 0; i < SHA_DIGEST_LENGTH; i++) seed[i] ^= padded_from[i]; if (MGF1(db, dblen, seed, SHA_DIGEST_LENGTH)) - return -1; + goto err; for (i = 0; i < dblen; i++) db[i] ^= maskeddb[i]; if (!EVP_Digest((void *)param, plen, phash, NULL, EVP_sha1(), NULL)) - return -1; + goto err; if (timingsafe_memcmp(db, phash, SHA_DIGEST_LENGTH) != 0 || bad) goto decoding_err; @@ -173,12 +176,13 @@ RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, free(db); return mlen; -decoding_err: + decoding_err: /* * To avoid chosen ciphertext attacks, the error message should not * reveal which kind of decoding error happened */ RSAerror(RSA_R_OAEP_DECODING_ERROR); + err: free(db); return -1; } @@ -219,7 +223,7 @@ PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed, } } rv = 0; -err: + err: EVP_MD_CTX_cleanup(&c); return rv; } diff --git a/lib/libcrypto/rsa/rsa_pmeth.c b/lib/libcrypto/rsa/rsa_pmeth.c index b4a4e730c0..ea6401b3da 100644 --- a/lib/libcrypto/rsa/rsa_pmeth.c +++ b/lib/libcrypto/rsa/rsa_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_pmeth.c,v 1.20 2017/08/28 17:41:59 jsing Exp $ */ +/* $OpenBSD: rsa_pmeth.c,v 1.21 2018/09/05 00:55:33 djm Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -296,7 +296,7 @@ pkey_rsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, return 0; } - if (rslen != tbslen || memcmp(tbs, rctx->tbuf, rslen)) + if (rslen != tbslen || timingsafe_bcmp(tbs, rctx->tbuf, rslen)) return 0; return 1; diff --git a/lib/libcrypto/rsa/rsa_pss.c b/lib/libcrypto/rsa/rsa_pss.c index 870f634b8d..562f7b252c 100644 --- a/lib/libcrypto/rsa/rsa_pss.c +++ b/lib/libcrypto/rsa/rsa_pss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_pss.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: rsa_pss.c,v 1.13 2018/09/05 00:55:33 djm Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ @@ -163,7 +163,7 @@ RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, } if (!EVP_DigestFinal_ex(&ctx, H_, NULL)) goto err; - if (memcmp(H_, H, hLen)) { + if (timingsafe_bcmp(H_, H, hLen)) { RSAerror(RSA_R_BAD_SIGNATURE); ret = 0; } else diff --git a/lib/libcrypto/rsa/rsa_saos.c b/lib/libcrypto/rsa/rsa_saos.c index e1fbdcb5df..93492ac503 100644 --- a/lib/libcrypto/rsa/rsa_saos.c +++ b/lib/libcrypto/rsa/rsa_saos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_saos.c,v 1.23 2017/05/02 03:59:45 deraadt Exp $ */ +/* $OpenBSD: rsa_saos.c,v 1.24 2018/09/05 00:55:33 djm Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -130,7 +130,7 @@ RSA_verify_ASN1_OCTET_STRING(int dtype, const unsigned char *m, goto err; if ((unsigned int)sig->length != m_len || - memcmp(m, sig->data, m_len) != 0) { + timingsafe_bcmp(m, sig->data, m_len) != 0) { RSAerror(RSA_R_BAD_SIGNATURE); } else ret = 1; diff --git a/lib/libcrypto/rsa/rsa_sign.c b/lib/libcrypto/rsa/rsa_sign.c index 6e9e869f0a..50e07f4f1e 100644 --- a/lib/libcrypto/rsa/rsa_sign.c +++ b/lib/libcrypto/rsa/rsa_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_sign.c,v 1.29 2017/05/02 03:59:45 deraadt Exp $ */ +/* $OpenBSD: rsa_sign.c,v 1.31 2018/09/05 00:55:33 djm Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,168 +70,197 @@ /* Size of an SSL signature: MD5+SHA1 */ #define SSL_SIG_LENGTH 36 -int -RSA_sign(int type, const unsigned char *m, unsigned int m_len, - unsigned char *sigret, unsigned int *siglen, RSA *rsa) +static int encode_pkcs1(unsigned char **, int *, int , const unsigned char *, + unsigned int); + +/* + * encode_pkcs1 encodes a DigestInfo prefix of hash `type' and digest `m', as + * described in EMSA-PKCS-v1_5-ENCODE, RFC 8017 section 9. step 2. This + * encodes the DigestInfo (T and tLen) but does not add the padding. + * + * On success, it returns one and sets `*out' to a newly allocated buffer + * containing the result and `*out_len' to its length. Freeing `*out' is + * the caller's responsibility. Failure is indicated by zero. + */ +static int +encode_pkcs1(unsigned char **out, int *out_len, int type, + const unsigned char *m, unsigned int m_len) { X509_SIG sig; - ASN1_TYPE parameter; - int i, j, ret = 1; - unsigned char *p, *tmps = NULL; - const unsigned char *s = NULL; X509_ALGOR algor; + ASN1_TYPE parameter; ASN1_OCTET_STRING digest; + uint8_t *der = NULL; + int len; + + sig.algor = &algor; + if ((sig.algor->algorithm = OBJ_nid2obj(type)) == NULL) { + RSAerror(RSA_R_UNKNOWN_ALGORITHM_TYPE); + return 0; + } + if (sig.algor->algorithm->length == 0) { + RSAerror( + RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD); + return 0; + } + parameter.type = V_ASN1_NULL; + parameter.value.ptr = NULL; + sig.algor->parameter = ¶meter; + + sig.digest = &digest; + sig.digest->data = (unsigned char*)m; /* TMP UGLY CAST */ + sig.digest->length = m_len; - if ((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_sign) + if ((len = i2d_X509_SIG(&sig, &der)) < 0) + return 0; + + *out = der; + *out_len = len; + + return 1; +} + +int +RSA_sign(int type, const unsigned char *m, unsigned int m_len, + unsigned char *sigret, unsigned int *siglen, RSA *rsa) +{ + const unsigned char *encoded = NULL; + unsigned char *tmps = NULL; + int encrypt_len, encoded_len = 0, ret = 0; + + if ((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_sign != NULL) return rsa->meth->rsa_sign(type, m, m_len, sigret, siglen, rsa); - /* Special case: SSL signature, just check the length */ + /* Compute the encoded digest. */ if (type == NID_md5_sha1) { + /* + * NID_md5_sha1 corresponds to the MD5/SHA1 combination in + * TLS 1.1 and earlier. It has no DigestInfo wrapper but + * otherwise is RSASSA-PKCS-v1.5. + */ if (m_len != SSL_SIG_LENGTH) { - RSAerror(RSA_R_INVALID_MESSAGE_LENGTH); + RSAerror(RSA_R_INVALID_DIGEST_LENGTH); return 0; } - i = SSL_SIG_LENGTH; - s = m; + encoded_len = SSL_SIG_LENGTH; + encoded = m; } else { - sig.algor = &algor; - sig.algor->algorithm = OBJ_nid2obj(type); - if (sig.algor->algorithm == NULL) { - RSAerror(RSA_R_UNKNOWN_ALGORITHM_TYPE); - return 0; - } - if (sig.algor->algorithm->length == 0) { - RSAerror(RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD); - return 0; - } - parameter.type = V_ASN1_NULL; - parameter.value.ptr = NULL; - sig.algor->parameter = ¶meter; - - sig.digest = &digest; - sig.digest->data = (unsigned char *)m; /* TMP UGLY CAST */ - sig.digest->length = m_len; - - i = i2d_X509_SIG(&sig, NULL); + if (!encode_pkcs1(&tmps, &encoded_len, type, m, m_len)) + goto err; + encoded = tmps; } - j = RSA_size(rsa); - if (i > j - RSA_PKCS1_PADDING_SIZE) { + if (encoded_len > RSA_size(rsa) - RSA_PKCS1_PADDING_SIZE) { RSAerror(RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); - return 0; - } - if (type != NID_md5_sha1) { - tmps = malloc(j + 1); - if (tmps == NULL) { - RSAerror(ERR_R_MALLOC_FAILURE); - return 0; - } - p = tmps; - i2d_X509_SIG(&sig, &p); - s = tmps; + goto err; } - i = RSA_private_encrypt(i, s, sigret, rsa, RSA_PKCS1_PADDING); - if (i <= 0) - ret = 0; - else - *siglen = i; - - if (type != NID_md5_sha1) - freezero(tmps, (unsigned int)j + 1); + if ((encrypt_len = RSA_private_encrypt(encoded_len, encoded, sigret, + rsa, RSA_PKCS1_PADDING)) <= 0) + goto err; + + *siglen = encrypt_len; + ret = 1; + + err: + freezero(tmps, (size_t)encoded_len); return (ret); } +/* + * int_rsa_verify verifies an RSA signature in `sigbuf' using `rsa'. It may be + * called in two modes. If `rm' is NULL, it verifies the signature for the + * digest `m'. Otherwise, it recovers the digest from the signature, writing the + * digest to `rm' and the length to `*prm_len'. `type' is the NID of the digest + * algorithm to use. It returns one on successful verification and zero + * otherwise. + */ int -int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, +int_rsa_verify(int type, const unsigned char *m, unsigned int m_len, unsigned char *rm, size_t *prm_len, const unsigned char *sigbuf, size_t siglen, RSA *rsa) { - int i, ret = 0, sigtype; - unsigned char *s; - X509_SIG *sig = NULL; + unsigned char *decrypt_buf, *encoded = NULL; + int decrypt_len, encoded_len = 0, ret = 0; - if (siglen != (unsigned int)RSA_size(rsa)) { + if (siglen != (size_t)RSA_size(rsa)) { RSAerror(RSA_R_WRONG_SIGNATURE_LENGTH); return 0; } - if ((dtype == NID_md5_sha1) && rm) { - i = RSA_public_decrypt((int)siglen, sigbuf, rm, rsa, - RSA_PKCS1_PADDING); - if (i <= 0) - return 0; - *prm_len = i; - return 1; - } - - s = malloc(siglen); - if (s == NULL) { + /* Recover the encoded digest. */ + if ((decrypt_buf = malloc(siglen)) == NULL) { RSAerror(ERR_R_MALLOC_FAILURE); goto err; } - if (dtype == NID_md5_sha1 && m_len != SSL_SIG_LENGTH) { - RSAerror(RSA_R_INVALID_MESSAGE_LENGTH); - goto err; - } - i = RSA_public_decrypt((int)siglen, sigbuf, s, rsa, RSA_PKCS1_PADDING); - - if (i <= 0) + if ((decrypt_len = RSA_public_decrypt((int)siglen, sigbuf, decrypt_buf, + rsa, RSA_PKCS1_PADDING)) <= 0) goto err; + + if (type == NID_md5_sha1) { + /* + * NID_md5_sha1 corresponds to the MD5/SHA1 combination in + * TLS 1.1 and earlier. It has no DigestInfo wrapper but + * otherwise is RSASSA-PKCS1-v1_5. + */ + if (decrypt_len != SSL_SIG_LENGTH) { + RSAerror(RSA_R_INVALID_DIGEST_LENGTH); + goto err; + } - /* Special case: SSL signature */ - if (dtype == NID_md5_sha1) { - if (i != SSL_SIG_LENGTH || memcmp(s, m, SSL_SIG_LENGTH)) - RSAerror(RSA_R_BAD_SIGNATURE); - else - ret = 1; + if (rm != NULL) { + memcpy(rm, decrypt_buf, SSL_SIG_LENGTH); + *prm_len = SSL_SIG_LENGTH; + } else { + if (m_len != SSL_SIG_LENGTH) { + RSAerror(RSA_R_INVALID_MESSAGE_LENGTH); + goto err; + } + if (timingsafe_bcmp(decrypt_buf, + m, SSL_SIG_LENGTH) != 0) { + RSAerror(RSA_R_BAD_SIGNATURE); + goto err; + } + } } else { - const unsigned char *p = s; + /* + * If recovering the digest, extract a digest-sized output from + * the end of `decrypt_buf' for `encode_pkcs1', then compare the + * decryption output as in a standard verification. + */ + if (rm != NULL) { + const EVP_MD *md; - sig = d2i_X509_SIG(NULL, &p, (long)i); + if ((md = EVP_get_digestbynid(type)) == NULL) { + RSAerror(RSA_R_UNKNOWN_ALGORITHM_TYPE); + goto err; + } + if ((m_len = EVP_MD_size(md)) > (size_t)decrypt_len) { + RSAerror(RSA_R_INVALID_DIGEST_LENGTH); + goto err; + } + m = decrypt_buf + decrypt_len - m_len; + } - if (sig == NULL) + /* Construct the encoded digest and ensure it matches */ + if (!encode_pkcs1(&encoded, &encoded_len, type, m, m_len)) goto err; - /* Excess data can be used to create forgeries */ - if (p != s + i) { + if (encoded_len != decrypt_len || + timingsafe_bcmp(encoded, decrypt_buf, encoded_len) != 0) { RSAerror(RSA_R_BAD_SIGNATURE); goto err; } - /* Parameters to the signature algorithm can also be used to - create forgeries */ - if (sig->algor->parameter && - ASN1_TYPE_get(sig->algor->parameter) != V_ASN1_NULL) { - RSAerror(RSA_R_BAD_SIGNATURE); - goto err; + /* Output the recovered digest. */ + if (rm != NULL) { + memcpy(rm, m, m_len); + *prm_len = m_len; } - - sigtype = OBJ_obj2nid(sig->algor->algorithm); - - if (sigtype != dtype) { - RSAerror(RSA_R_ALGORITHM_MISMATCH); - goto err; - } - if (rm) { - const EVP_MD *md; - - md = EVP_get_digestbynid(dtype); - if (md && (EVP_MD_size(md) != sig->digest->length)) - RSAerror(RSA_R_INVALID_DIGEST_LENGTH); - else { - memcpy(rm, sig->digest->data, - sig->digest->length); - *prm_len = sig->digest->length; - ret = 1; - } - } else if ((unsigned int)sig->digest->length != m_len || - memcmp(m, sig->digest->data, m_len) != 0) { - RSAerror(RSA_R_BAD_SIGNATURE); - } else - ret = 1; } -err: - X509_SIG_free(sig); - freezero(s, (unsigned int)siglen); + + ret = 1; + err: + freezero(encoded, (size_t)encoded_len); + freezero(decrypt_buf, siglen); return ret; } diff --git a/lib/libcrypto/shlib_version b/lib/libcrypto/shlib_version index c5b8a2505c..77964f81e8 100644 --- a/lib/libcrypto/shlib_version +++ b/lib/libcrypto/shlib_version @@ -1,3 +1,3 @@ # Don't forget to give libssl and libtls the same type of bump! -major=43 +major=44 minor=1 diff --git a/lib/libcrypto/stack/stack.c b/lib/libcrypto/stack/stack.c index d941f9e6fb..b76a0d7271 100644 --- a/lib/libcrypto/stack/stack.c +++ b/lib/libcrypto/stack/stack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack.c,v 1.19 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: stack.c,v 1.20 2018/04/01 00:36:28 schwarze Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -312,6 +312,7 @@ sk_set(_STACK *st, int i, void *value) { if (!st || (i < 0) || (i >= st->num)) return NULL; + st->sorted = 0; return (st->data[i] = value); } diff --git a/lib/libcrypto/ts/ts.h b/lib/libcrypto/ts/ts.h index a8d2281b7a..fa8eb949a4 100644 --- a/lib/libcrypto/ts/ts.h +++ b/lib/libcrypto/ts/ts.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ts.h,v 1.8 2016/12/27 16:05:57 jsing Exp $ */ +/* $OpenBSD: ts.h,v 1.10 2018/05/13 15:35:46 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL * project 2002, 2003, 2004. */ @@ -365,7 +365,7 @@ X509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a); int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len); ASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a); -int TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy); +int TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy); ASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a); int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce); @@ -378,7 +378,7 @@ STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a); void TS_REQ_ext_free(TS_REQ *a); int TS_REQ_get_ext_count(TS_REQ *a); int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos); -int TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos); +int TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos); int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos); X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc); X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc); @@ -439,7 +439,8 @@ STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a); void TS_TST_INFO_ext_free(TS_TST_INFO *a); int TS_TST_INFO_get_ext_count(TS_TST_INFO *a); int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos); -int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos); +int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, + int lastpos); int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos); X509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc); X509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc); @@ -524,14 +525,14 @@ int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer); int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key); /* This parameter must be set. */ -int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy); +int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy); /* No additional certs are included in the response by default. */ int TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs); /* Adds a new acceptable policy, only the default policy is accepted by default. */ -int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy); +int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy); /* Adds a new acceptable message digest. Note that no message digests are accepted by default. The md argument is shared with the caller. */ diff --git a/lib/libcrypto/ts/ts_conf.c b/lib/libcrypto/ts/ts_conf.c index c223aa3d46..41d185ee5a 100644 --- a/lib/libcrypto/ts/ts_conf.c +++ b/lib/libcrypto/ts/ts_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_conf.c,v 1.10 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ts_conf.c,v 1.11 2018/04/14 07:18:37 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -248,8 +248,7 @@ err: TSerror(TS_R_COULD_NOT_SET_ENGINE); ERR_asprintf_error_data("engine:%s", name); } - if (e) - ENGINE_free(e); + ENGINE_free(e); return ret; } diff --git a/lib/libcrypto/ts/ts_req_utils.c b/lib/libcrypto/ts/ts_req_utils.c index bd707c228f..6b9c13f39b 100644 --- a/lib/libcrypto/ts/ts_req_utils.c +++ b/lib/libcrypto/ts/ts_req_utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_req_utils.c,v 1.5 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ts_req_utils.c,v 1.6 2018/05/13 15:04:05 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -134,7 +134,7 @@ TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a) } int -TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy) +TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy) { ASN1_OBJECT *new_policy; @@ -219,7 +219,7 @@ TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos) } int -TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos) +TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos); } diff --git a/lib/libcrypto/ts/ts_rsp_sign.c b/lib/libcrypto/ts/ts_rsp_sign.c index 57e2d7f348..9ab80160b3 100644 --- a/lib/libcrypto/ts/ts_rsp_sign.c +++ b/lib/libcrypto/ts/ts_rsp_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_rsp_sign.c,v 1.21 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ts_rsp_sign.c,v 1.22 2018/05/13 15:04:05 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -201,7 +201,7 @@ TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key) } int -TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy) +TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy) { if (ctx->default_policy) ASN1_OBJECT_free(ctx->default_policy); @@ -238,7 +238,7 @@ TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs) } int -TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy) +TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy) { ASN1_OBJECT *copy = NULL; diff --git a/lib/libcrypto/ts/ts_rsp_utils.c b/lib/libcrypto/ts/ts_rsp_utils.c index 5638331d17..233df867ac 100644 --- a/lib/libcrypto/ts/ts_rsp_utils.c +++ b/lib/libcrypto/ts/ts_rsp_utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_rsp_utils.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ts_rsp_utils.c,v 1.7 2018/05/13 15:35:46 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -398,7 +398,7 @@ TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos) } int -TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos) +TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos); } diff --git a/lib/libcrypto/ui/ui.h b/lib/libcrypto/ui/ui.h index b6b0075e4d..8035fc2baa 100644 --- a/lib/libcrypto/ui/ui.h +++ b/lib/libcrypto/ui/ui.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ui.h,v 1.9 2014/07/10 22:45:58 jsing Exp $ */ +/* $OpenBSD: ui.h,v 1.11 2018/06/02 04:45:21 tb Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ @@ -304,7 +304,7 @@ enum UI_string_types { }; /* Create and manipulate methods */ -UI_METHOD *UI_create_method(char *name); +UI_METHOD *UI_create_method(const char *name); void UI_destroy_method(UI_METHOD *ui_method); int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); @@ -312,12 +312,12 @@ int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name)); -int (*UI_method_get_opener(UI_METHOD *method))(UI*); -int (*UI_method_get_writer(UI_METHOD *method))(UI*, UI_STRING*); -int (*UI_method_get_flusher(UI_METHOD *method))(UI*); -int (*UI_method_get_reader(UI_METHOD *method))(UI*, UI_STRING*); -int (*UI_method_get_closer(UI_METHOD *method))(UI*); -char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*); +int (*UI_method_get_opener(const UI_METHOD *method))(UI*); +int (*UI_method_get_writer(const UI_METHOD *method))(UI*, UI_STRING*); +int (*UI_method_get_flusher(const UI_METHOD *method))(UI*); +int (*UI_method_get_reader(const UI_METHOD *method))(UI*, UI_STRING*); +int (*UI_method_get_closer(const UI_METHOD *method))(UI*); +char * (*UI_method_get_prompt_constructor(const UI_METHOD *method))(UI*, const char*, const char*); /* The following functions are helpers for method writers to access relevant data from a UI_STRING. */ diff --git a/lib/libcrypto/ui/ui_lib.c b/lib/libcrypto/ui/ui_lib.c index e551030729..06b29b8cee 100644 --- a/lib/libcrypto/ui/ui_lib.c +++ b/lib/libcrypto/ui/ui_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_lib.c,v 1.32 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: ui_lib.c,v 1.34 2018/06/02 04:45:21 tb Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ @@ -582,7 +582,7 @@ UI_set_method(UI *ui, const UI_METHOD *meth) UI_METHOD * -UI_create_method(char *name) +UI_create_method(const char *name) { UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); @@ -666,7 +666,7 @@ UI_method_set_prompt_constructor(UI_METHOD *method, } int -(*UI_method_get_opener(UI_METHOD * method))(UI *) +(*UI_method_get_opener(const UI_METHOD * method))(UI *) { if (method) return method->ui_open_session; @@ -675,7 +675,7 @@ int } int -(*UI_method_get_writer(UI_METHOD *method))(UI *, UI_STRING *) +(*UI_method_get_writer(const UI_METHOD *method))(UI *, UI_STRING *) { if (method) return method->ui_write_string; @@ -684,7 +684,7 @@ int } int -(*UI_method_get_flusher(UI_METHOD *method)) (UI *) +(*UI_method_get_flusher(const UI_METHOD *method)) (UI *) { if (method) return method->ui_flush; @@ -693,7 +693,7 @@ int } int -(*UI_method_get_reader(UI_METHOD *method))(UI *, UI_STRING *) +(*UI_method_get_reader(const UI_METHOD *method))(UI *, UI_STRING *) { if (method) return method->ui_read_string; @@ -702,7 +702,7 @@ int } int -(*UI_method_get_closer(UI_METHOD *method))(UI *) +(*UI_method_get_closer(const UI_METHOD *method))(UI *) { if (method) return method->ui_close_session; @@ -711,7 +711,7 @@ int } char * -(*UI_method_get_prompt_constructor(UI_METHOD *method))(UI *, const char *, +(*UI_method_get_prompt_constructor(const UI_METHOD *method))(UI *, const char *, const char *) { if (method) diff --git a/lib/libcrypto/x509/by_dir.c b/lib/libcrypto/x509/by_dir.c index 01a302b538..04eada8ad0 100644 --- a/lib/libcrypto/x509/by_dir.c +++ b/lib/libcrypto/x509/by_dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_dir.c,v 1.38 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: by_dir.c,v 1.39 2018/08/05 14:17:12 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -103,7 +103,7 @@ static X509_LOOKUP_METHOD x509_dir_lookup = { .name = "Load certs from files in a directory", .new_item = new_dir, .free = free_dir, - .init = NULL, + .init = NULL, .shutdown = NULL, .ctrl = dir_ctrl, .get_by_subject = get_cert_by_subject, @@ -316,7 +316,7 @@ get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, X509error(ERR_R_MALLOC_FAILURE); goto finish; } - if (type == X509_LU_CRL && ent->hashes) { + if (type == X509_LU_CRL) { htmp.hash = h; CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp); diff --git a/lib/libcrypto/x509/vpm_int.h b/lib/libcrypto/x509/vpm_int.h index 6c8061c847..7fc9fef761 100644 --- a/lib/libcrypto/x509/vpm_int.h +++ b/lib/libcrypto/x509/vpm_int.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vpm_int.h,v 1.3 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: vpm_int.h,v 1.4 2018/04/06 07:08:20 beck Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project * 2013. @@ -69,6 +69,7 @@ struct X509_VERIFY_PARAM_ID_st { size_t emaillen; unsigned char *ip; /* If not NULL IP address to match */ size_t iplen; /* Length of IP address */ + int poisoned; }; __END_HIDDEN_DECLS diff --git a/lib/libcrypto/x509/x509.h b/lib/libcrypto/x509/x509.h index 5ccaf41114..c66dfa6a48 100644 --- a/lib/libcrypto/x509/x509.h +++ b/lib/libcrypto/x509/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.44 2018/03/17 15:28:27 tb Exp $ */ +/* $OpenBSD: x509.h,v 1.74 2018/08/24 20:26:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -561,19 +561,12 @@ X509_ALGOR *prf; /* PKCS#8 private key info structure */ -struct pkcs8_priv_key_info_st - { - int broken; /* Flag for various broken formats */ -#define PKCS8_OK 0 -#define PKCS8_NO_OCTET 1 -#define PKCS8_EMBEDDED_PARAM 2 -#define PKCS8_NS_DB 3 -#define PKCS8_NEG_PRIVKEY 4 +struct pkcs8_priv_key_info_st { ASN1_INTEGER *version; X509_ALGOR *pkeyalg; - ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ + ASN1_OCTET_STRING *pkey; STACK_OF(X509_ATTRIBUTE) *attributes; - }; +}; #ifdef __cplusplus } @@ -589,29 +582,21 @@ extern "C" { #define X509_EXT_PACK_UNKNOWN 1 #define X509_EXT_PACK_STRING 2 -#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) -/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ -#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) -#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) #define X509_extract_key(x) X509_get_pubkey(x) /*****/ -#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) -#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) #define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) #define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) -#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) - -#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) -#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) -#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) -#define X509_CRL_get_issuer(x) ((x)->crl->issuer) -#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) int X509_CRL_up_ref(X509_CRL *x); int X509_CRL_get_signature_nid(const X509_CRL *crl); const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl); +long X509_CRL_get_version(const X509_CRL *crl); const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl); const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl); +ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl); +ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl); +X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl); +STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl); void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, const X509_ALGOR **palg); @@ -653,8 +638,9 @@ int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); -int X509_signature_dump(BIO *bp,const ASN1_STRING *sig, int indent); -int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig); +int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent); +int X509_signature_print(BIO *bp, const X509_ALGOR *alg, + const ASN1_STRING *sig); int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx); @@ -758,8 +744,8 @@ X509_CRL *X509_CRL_dup(X509_CRL *crl); X509_REQ *X509_REQ_dup(X509_REQ *req); X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval); -void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval, - X509_ALGOR *algor); +void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, const void **ppval, + const X509_ALGOR *algor); void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md); int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b); @@ -907,14 +893,14 @@ void X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, const X509 *x); int X509_get_signature_nid(const X509 *x); -int X509_alias_set1(X509 *x, unsigned char *name, int len); -int X509_keyid_set1(X509 *x, unsigned char *id, int len); -unsigned char * X509_alias_get0(X509 *x, int *len); -unsigned char * X509_keyid_get0(X509 *x, int *len); +int X509_alias_set1(X509 *x, const unsigned char *name, int len); +int X509_keyid_set1(X509 *x, const unsigned char *id, int len); +unsigned char *X509_alias_get0(X509 *x, int *len); +unsigned char *X509_keyid_get0(X509 *x, int *len); int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); int X509_TRUST_set(int *t, int trust); -int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); -int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); +int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj); +int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj); void X509_trust_clear(X509 *x); void X509_reject_clear(X509 *x); @@ -964,7 +950,7 @@ extern const ASN1_ITEM NETSCAPE_CERT_SEQUENCE_it; #ifndef OPENSSL_NO_EVP X509_INFO * X509_INFO_new(void); void X509_INFO_free(X509_INFO *a); -char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); +char * X509_NAME_oneline(const X509_NAME *a, char *buf, int size); int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data, unsigned char *md,unsigned int *len); @@ -983,12 +969,14 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it, const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x); int X509_set_version(X509 *x, long version); +long X509_get_version(const X509 *x); int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); ASN1_INTEGER * X509_get_serialNumber(X509 *x); +const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x); int X509_set_issuer_name(X509 *x, X509_NAME *name); -X509_NAME * X509_get_issuer_name(X509 *a); +X509_NAME * X509_get_issuer_name(const X509 *a); int X509_set_subject_name(X509 *x, X509_NAME *name); -X509_NAME * X509_get_subject_name(X509 *a); +X509_NAME * X509_get_subject_name(const X509 *a); int X509_set_notBefore(X509 *x, const ASN1_TIME *tm); int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm); int X509_set_notAfter(X509 *x, const ASN1_TIME *tm); @@ -999,12 +987,18 @@ const ASN1_TIME *X509_get0_notAfter(const X509 *x); ASN1_TIME *X509_getm_notAfter(const X509 *x); int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); EVP_PKEY * X509_get_pubkey(X509 *x); -EVP_PKEY * X509_get0_pubkey(X509 *x); +EVP_PKEY * X509_get0_pubkey(const X509 *x); ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x); -int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); +int X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey); +int X509_get_signature_type(const X509 *x); + +#define X509_get_notBefore X509_getm_notBefore +#define X509_get_notAfter X509_getm_notAfter int X509_REQ_set_version(X509_REQ *x,long version); -int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); +long X509_REQ_get_version(const X509_REQ *x); +int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name); +X509_NAME *X509_REQ_get_subject_name(const X509_REQ *x); int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); int X509_REQ_extension_nid(int nid); @@ -1017,7 +1011,7 @@ int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); int X509_REQ_get_attr_count(const X509_REQ *req); int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos); -int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, +int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, int lastpos); X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); @@ -1048,7 +1042,7 @@ int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey); -int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); +int X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey); int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); unsigned long X509_issuer_and_serial_hash(X509 *a); @@ -1075,11 +1069,13 @@ int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cfla int X509_print_fp(FILE *bp,X509 *x); int X509_CRL_print_fp(FILE *bp,X509_CRL *x); int X509_REQ_print_fp(FILE *bp,X509_REQ *req); -int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); +int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent, + unsigned long flags); #ifndef OPENSSL_NO_BIO -int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); -int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); +int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase); +int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, + unsigned long flags); int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag); int X509_print(BIO *bp,X509 *x); int X509_ocspid_print(BIO *bp,X509 *x); @@ -1089,47 +1085,48 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long int X509_REQ_print(BIO *bp,X509_REQ *req); #endif -int X509_NAME_entry_count(X509_NAME *name); +int X509_NAME_entry_count(const X509_NAME *name); int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf,int len); -int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, - char *buf,int len); +int X509_NAME_get_text_by_OBJ(X509_NAME *name, + const ASN1_OBJECT *obj, char *buf,int len); /* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use * lastpos, search after that position on. */ -int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); -int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, +int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos); -X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); +int X509_NAME_get_index_by_OBJ(const X509_NAME *name, + const ASN1_OBJECT *obj, int lastpos); +X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc); X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); -int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, +int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, int set); -int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, - unsigned char *bytes, int len, int loc, int set); +int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, + int type, const unsigned char *bytes, int len, int loc, int set); int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, - unsigned char *bytes, int len, int loc, int set); + const unsigned char *bytes, int len, int loc, int set); X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, const char *field, int type, const unsigned char *bytes, int len); X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, - int type,unsigned char *bytes, int len); + int type, const unsigned char *bytes, int len); int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set); X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, - ASN1_OBJECT *obj, int type,const unsigned char *bytes, - int len); + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, - ASN1_OBJECT *obj); + const ASN1_OBJECT *obj); int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, const unsigned char *bytes, int len); -ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); -ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); +ASN1_OBJECT * X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne); +ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne); int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne); int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, int nid, int lastpos); int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, - ASN1_OBJECT *obj,int lastpos); + const ASN1_OBJECT *obj, int lastpos); int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, int crit, int lastpos); X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); @@ -1137,56 +1134,67 @@ X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc); -int X509_get_ext_count(X509 *x); -int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); -int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); -int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); -X509_EXTENSION *X509_get_ext(X509 *x, int loc); +int X509_get_ext_count(const X509 *x); +int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos); +int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, + int lastpos); +int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos); +X509_EXTENSION *X509_get_ext(const X509 *x, int loc); X509_EXTENSION *X509_delete_ext(X509 *x, int loc); int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); -void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); +void * X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx); int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags); -int X509_CRL_get_ext_count(X509_CRL *x); -int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); -int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); -int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); -X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); +int X509_CRL_get_ext_count(const X509_CRL *x); +int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, + int lastpos); +int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, + const ASN1_OBJECT *obj, int lastpos); +int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, + int lastpos); +X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc); X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); -void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); -int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, - unsigned long flags); - -int X509_REVOKED_get_ext_count(X509_REVOKED *x); -int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); -int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); -int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); -X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); +void * X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, + int *idx); +int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, + int crit, unsigned long flags); + +int X509_REVOKED_get_ext_count(const X509_REVOKED *x); +int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, + int lastpos); +int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, + const ASN1_OBJECT *obj, int lastpos); +int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, + int crit, int lastpos); +X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc); X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); -int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); -void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); -int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, - unsigned long flags); +int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, + int loc); +void * X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, + int *crit, int *idx); +int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, + int crit, unsigned long flags); X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, ASN1_OCTET_STRING *data); X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, - ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); -int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj); + const ASN1_OBJECT *obj, int crit, ASN1_OCTET_STRING *data); +int X509_EXTENSION_set_object(X509_EXTENSION *ex, + const ASN1_OBJECT *obj); int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data); ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); -int X509_EXTENSION_get_critical(X509_EXTENSION *ex); +int X509_EXTENSION_get_critical(const X509_EXTENSION *ex); int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, int lastpos); -int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, - int lastpos); +int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, + const ASN1_OBJECT *obj, int lastpos); X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, @@ -1201,7 +1209,7 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, const char *attrname, int type, const unsigned char *bytes, int len); void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, - ASN1_OBJECT *obj, int lastpos, int type); + const ASN1_OBJECT *obj, int lastpos, int type); X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, int atrtype, const void *data, int len); X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, @@ -1212,14 +1220,14 @@ int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, void *data); -int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); +int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr); ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); int EVP_PKEY_get_attr_count(const EVP_PKEY *key); int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos); -int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, +int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj, int lastpos); X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); @@ -1279,18 +1287,17 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a, const unsi int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **out); extern const ASN1_ITEM PKCS8_PRIV_KEY_INFO_it; -EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); +EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8); PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); -PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); -PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); -int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, - int version, int ptype, void *pval, - unsigned char *penc, int penclen); -int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg, - const unsigned char **pk, int *ppklen, - X509_ALGOR **pa, - PKCS8_PRIV_KEY_INFO *p8); +int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version, + int ptype, void *pval, unsigned char *penc, int penclen); +int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, const unsigned char **pk, + int *ppklen, const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8); + +const STACK_OF(X509_ATTRIBUTE) *PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8); +int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type, + const unsigned char *bytes, int len); int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, int ptype, void *pval, @@ -1305,11 +1312,11 @@ int X509_TRUST_get_count(void); X509_TRUST * X509_TRUST_get0(int idx); int X509_TRUST_get_by_id(int id); int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), - char *name, int arg1, void *arg2); + const char *name, int arg1, void *arg2); void X509_TRUST_cleanup(void); -int X509_TRUST_get_flags(X509_TRUST *xp); -char *X509_TRUST_get0_name(X509_TRUST *xp); -int X509_TRUST_get_trust(X509_TRUST *xp); +int X509_TRUST_get_flags(const X509_TRUST *xp); +char *X509_TRUST_get0_name(const X509_TRUST *xp); +int X509_TRUST_get_trust(const X509_TRUST *xp); int X509_up_ref(X509 *x); STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain); diff --git a/lib/libcrypto/x509/x509_att.c b/lib/libcrypto/x509/x509_att.c index 7304118eb3..1479b918c7 100644 --- a/lib/libcrypto/x509/x509_att.c +++ b/lib/libcrypto/x509/x509_att.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_att.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: x509_att.c,v 1.17 2018/05/18 19:21:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -84,8 +84,8 @@ X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, int lastpos) } int -X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, - int lastpos) +X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, + const ASN1_OBJECT *obj, int lastpos) { int n; X509_ATTRIBUTE *ex; @@ -205,7 +205,7 @@ X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, const char *attrname, } void * -X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, ASN1_OBJECT *obj, +X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, const ASN1_OBJECT *obj, int lastpos, int type) { int i; @@ -353,7 +353,7 @@ err: } int -X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr) +X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr) { if (!attr->single) return sk_ASN1_TYPE_num(attr->value.set); diff --git a/lib/libcrypto/x509/x509_cmp.c b/lib/libcrypto/x509/x509_cmp.c index ab0dbcba39..2141f871e5 100644 --- a/lib/libcrypto/x509/x509_cmp.c +++ b/lib/libcrypto/x509/x509_cmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_cmp.c,v 1.30 2018/03/17 14:57:23 jsing Exp $ */ +/* $OpenBSD: x509_cmp.c,v 1.34 2018/08/24 19:59:32 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -145,7 +145,7 @@ X509_CRL_match(const X509_CRL *a, const X509_CRL *b) #endif X509_NAME * -X509_get_issuer_name(X509 *a) +X509_get_issuer_name(const X509 *a) { return (a->cert_info->issuer); } @@ -165,7 +165,7 @@ X509_issuer_name_hash_old(X509 *x) #endif X509_NAME * -X509_get_subject_name(X509 *a) +X509_get_subject_name(const X509 *a) { return (a->cert_info->subject); } @@ -176,6 +176,12 @@ X509_get_serialNumber(X509 *a) return (a->cert_info->serialNumber); } +const ASN1_INTEGER * +X509_get0_serialNumber(const X509 *a) +{ + return (a->cert_info->serialNumber); +} + unsigned long X509_subject_name_hash(X509 *x) { @@ -327,7 +333,7 @@ X509_get_pubkey(X509 *x) } EVP_PKEY * -X509_get0_pubkey(X509 *x) +X509_get0_pubkey(const X509 *x) { if (x == NULL || x->cert_info == NULL) return (NULL); @@ -343,12 +349,12 @@ X509_get0_pubkey_bitstr(const X509 *x) } int -X509_check_private_key(X509 *x, EVP_PKEY *k) +X509_check_private_key(const X509 *x, const EVP_PKEY *k) { - EVP_PKEY *xk; + const EVP_PKEY *xk; int ret; - xk = X509_get_pubkey(x); + xk = X509_get0_pubkey(x); if (xk) ret = EVP_PKEY_cmp(xk, k); @@ -367,7 +373,6 @@ X509_check_private_key(X509 *x, EVP_PKEY *k) case -2: X509error(X509_R_UNKNOWN_KEY_TYPE); } - EVP_PKEY_free(xk); if (ret > 0) return 1; return 0; diff --git a/lib/libcrypto/x509/x509_ext.c b/lib/libcrypto/x509/x509_ext.c index e90befaba1..21374a26e2 100644 --- a/lib/libcrypto/x509/x509_ext.c +++ b/lib/libcrypto/x509/x509_ext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_ext.c,v 1.9 2015/02/10 08:33:10 jsing Exp $ */ +/* $OpenBSD: x509_ext.c,v 1.12 2018/05/18 19:28:27 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,31 +66,31 @@ #include int -X509_CRL_get_ext_count(X509_CRL *x) +X509_CRL_get_ext_count(const X509_CRL *x) { return (X509v3_get_ext_count(x->crl->extensions)); } int -X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos) +X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->crl->extensions, nid, lastpos)); } int -X509_CRL_get_ext_by_OBJ(X509_CRL *x, ASN1_OBJECT *obj, int lastpos) +X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ(x->crl->extensions, obj, lastpos)); } int -X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos) +X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->crl->extensions, crit, lastpos)); } X509_EXTENSION * -X509_CRL_get_ext(X509_CRL *x, int loc) +X509_CRL_get_ext(const X509_CRL *x, int loc) { return (X509v3_get_ext(x->crl->extensions, loc)); } @@ -102,7 +102,7 @@ X509_CRL_delete_ext(X509_CRL *x, int loc) } void * -X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx) +X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->crl->extensions, nid, crit, idx); } @@ -121,32 +121,32 @@ X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) } int -X509_get_ext_count(X509 *x) +X509_get_ext_count(const X509 *x) { return (X509v3_get_ext_count(x->cert_info->extensions)); } int -X509_get_ext_by_NID(X509 *x, int nid, int lastpos) +X509_get_ext_by_NID(const X509 *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->cert_info->extensions, nid, lastpos)); } int -X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos) +X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ(x->cert_info->extensions, obj, lastpos)); } int -X509_get_ext_by_critical(X509 *x, int crit, int lastpos) +X509_get_ext_by_critical(const X509 *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->cert_info->extensions, crit, lastpos)); } X509_EXTENSION * -X509_get_ext(X509 *x, int loc) +X509_get_ext(const X509 *x, int loc) { return (X509v3_get_ext(x->cert_info->extensions, loc)); } @@ -164,7 +164,7 @@ X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc) } void * -X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx) +X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx); } @@ -177,31 +177,32 @@ X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags) } int -X509_REVOKED_get_ext_count(X509_REVOKED *x) +X509_REVOKED_get_ext_count(const X509_REVOKED *x) { return (X509v3_get_ext_count(x->extensions)); } int -X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos) +X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->extensions, nid, lastpos)); } int -X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x, ASN1_OBJECT *obj, int lastpos) +X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, + int lastpos) { return (X509v3_get_ext_by_OBJ(x->extensions, obj, lastpos)); } int -X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos) +X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->extensions, crit, lastpos)); } X509_EXTENSION * -X509_REVOKED_get_ext(X509_REVOKED *x, int loc) +X509_REVOKED_get_ext(const X509_REVOKED *x, int loc) { return (X509v3_get_ext(x->extensions, loc)); } @@ -219,7 +220,7 @@ X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc) } void * -X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx) +X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->extensions, nid, crit, idx); } diff --git a/lib/libcrypto/x509/x509_lu.c b/lib/libcrypto/x509/x509_lu.c index 742eb4d2bf..f21103c700 100644 --- a/lib/libcrypto/x509/x509_lu.c +++ b/lib/libcrypto/x509/x509_lu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lu.c,v 1.28 2018/03/17 15:43:32 tb Exp $ */ +/* $OpenBSD: x509_lu.c,v 1.30 2018/08/24 19:21:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,7 +65,6 @@ #include "x509_lcl.h" static void X509_OBJECT_dec_ref_count(X509_OBJECT *a); -/* static void X509_OBJECT_up_ref_count(X509_OBJECT *a); */ X509_LOOKUP * X509_LOOKUP_new(X509_LOOKUP_METHOD *method) @@ -154,8 +153,8 @@ X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, } int -X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, unsigned char *bytes, - int len, X509_OBJECT *ret) +X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, + const unsigned char *bytes, int len, X509_OBJECT *ret) { if ((ctx->method == NULL) || (ctx->method->get_by_fingerprint == NULL)) return X509_LU_FAIL; @@ -163,7 +162,7 @@ X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, unsigned char *bytes, } int -X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len, +X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, const char *str, int len, X509_OBJECT *ret) { if ((ctx->method == NULL) || (ctx->method->get_by_alias == NULL)) @@ -445,17 +444,16 @@ X509_OBJECT_dec_ref_count(X509_OBJECT *a) } } -/*static*/ void +int X509_OBJECT_up_ref_count(X509_OBJECT *a) { switch (a->type) { case X509_LU_X509: - CRYPTO_add(&a->data.x509->references, 1, CRYPTO_LOCK_X509); - break; + return X509_up_ref(a->data.x509); case X509_LU_CRL: - CRYPTO_add(&a->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); - break; + return X509_CRL_up_ref(a->data.crl); } + return 1; } int diff --git a/lib/libcrypto/x509/x509_obj.c b/lib/libcrypto/x509/x509_obj.c index b34f25b013..5c53799020 100644 --- a/lib/libcrypto/x509/x509_obj.c +++ b/lib/libcrypto/x509/x509_obj.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_obj.c,v 1.17 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: x509_obj.c,v 1.18 2018/05/18 18:19:31 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include char * -X509_NAME_oneline(X509_NAME *a, char *buf, int len) +X509_NAME_oneline(const X509_NAME *a, char *buf, int len) { X509_NAME_ENTRY *ne; int i; diff --git a/lib/libcrypto/x509/x509_req.c b/lib/libcrypto/x509/x509_req.c index f87b35c706..b44306b00d 100644 --- a/lib/libcrypto/x509/x509_req.c +++ b/lib/libcrypto/x509/x509_req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_req.c,v 1.20 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: x509_req.c,v 1.21 2018/05/13 06:48:00 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -286,7 +286,8 @@ X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos) } int -X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, int lastpos) +X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, + int lastpos) { return X509at_get_attr_by_OBJ(req->req_info->attributes, obj, lastpos); } diff --git a/lib/libcrypto/x509/x509_set.c b/lib/libcrypto/x509/x509_set.c index becdaf6ce5..1a4b583ab7 100644 --- a/lib/libcrypto/x509/x509_set.c +++ b/lib/libcrypto/x509/x509_set.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_set.c,v 1.16 2018/02/22 17:09:28 jsing Exp $ */ +/* $OpenBSD: x509_set.c,v 1.17 2018/08/24 19:55:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -87,6 +87,12 @@ X509_set_version(X509 *x, long version) return (ASN1_INTEGER_set(x->cert_info->version, version)); } +long +X509_get_version(const X509 *x) +{ + return ASN1_INTEGER_get(x->cert_info->version); +} + int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) { @@ -204,3 +210,9 @@ X509_set_pubkey(X509 *x, EVP_PKEY *pkey) return (0); return (X509_PUBKEY_set(&(x->cert_info->key), pkey)); } + +int +X509_get_signature_type(const X509 *x) +{ + return EVP_PKEY_type(OBJ_obj2nid(x->sig_alg->algorithm)); +} diff --git a/lib/libcrypto/x509/x509_trs.c b/lib/libcrypto/x509/x509_trs.c index 9af74de1ca..651dc82a52 100644 --- a/lib/libcrypto/x509/x509_trs.c +++ b/lib/libcrypto/x509/x509_trs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_trs.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: x509_trs.c,v 1.23 2018/05/18 18:40:38 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -187,7 +187,7 @@ X509_TRUST_set(int *t, int trust) int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), - char *name, int arg1, void *arg2) + const char *name, int arg1, void *arg2) { int idx; X509_TRUST *trtmp; @@ -274,19 +274,19 @@ X509_TRUST_cleanup(void) } int -X509_TRUST_get_flags(X509_TRUST *xp) +X509_TRUST_get_flags(const X509_TRUST *xp) { return xp->flags; } char * -X509_TRUST_get0_name(X509_TRUST *xp) +X509_TRUST_get0_name(const X509_TRUST *xp) { return xp->name; } int -X509_TRUST_get_trust(X509_TRUST *xp) +X509_TRUST_get_trust(const X509_TRUST *xp) { return xp->trust; } diff --git a/lib/libcrypto/x509/x509_v3.c b/lib/libcrypto/x509/x509_v3.c index 446ef319f8..524d5511ed 100644 --- a/lib/libcrypto/x509/x509_v3.c +++ b/lib/libcrypto/x509/x509_v3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_v3.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: x509_v3.c,v 1.17 2018/05/19 10:54:40 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -86,8 +86,8 @@ X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, int nid, int lastpos) } int -X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, ASN1_OBJECT *obj, - int lastpos) +X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, + const ASN1_OBJECT *obj, int lastpos) { int n; X509_EXTENSION *ex; @@ -209,8 +209,8 @@ X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, } X509_EXTENSION * -X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, ASN1_OBJECT *obj, int crit, - ASN1_OCTET_STRING *data) +X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, const ASN1_OBJECT *obj, + int crit, ASN1_OCTET_STRING *data) { X509_EXTENSION *ret; @@ -240,7 +240,7 @@ err: } int -X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj) +X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj) { if ((ex == NULL) || (obj == NULL)) return (0); @@ -288,7 +288,7 @@ X509_EXTENSION_get_data(X509_EXTENSION *ex) } int -X509_EXTENSION_get_critical(X509_EXTENSION *ex) +X509_EXTENSION_get_critical(const X509_EXTENSION *ex) { if (ex == NULL) return (0); diff --git a/lib/libcrypto/x509/x509_vfy.c b/lib/libcrypto/x509/x509_vfy.c index c8ccae5029..e98272a6c3 100644 --- a/lib/libcrypto/x509/x509_vfy.c +++ b/lib/libcrypto/x509/x509_vfy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vfy.c,v 1.68 2018/02/22 17:11:30 jsing Exp $ */ +/* $OpenBSD: x509_vfy.c,v 1.71 2018/08/19 20:19:31 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -182,10 +182,10 @@ check_id_error(X509_STORE_CTX *ctx, int errcode) static int check_hosts(X509 *x, X509_VERIFY_PARAM_ID *id) { - size_t i; - size_t n = sk_OPENSSL_STRING_num(id->hosts); + size_t i, n; char *name; + n = sk_OPENSSL_STRING_num(id->hosts); free(id->peername); id->peername = NULL; @@ -246,6 +246,15 @@ X509_verify_cert(X509_STORE_CTX *ctx) ctx->error = X509_V_ERR_INVALID_CALL; return -1; } + if (ctx->param->id->poisoned) { + /* + * This X509_STORE_CTX had failures setting + * up verify parameters. We can not use it. + */ + X509error(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + ctx->error = X509_V_ERR_INVALID_CALL; + return -1; + } if (ctx->error != X509_V_ERR_INVALID_CALL) { /* * This X509_STORE_CTX has not been properly initialized. @@ -487,9 +496,10 @@ X509_verify_cert(X509_STORE_CTX *ctx) ctx->current_cert = x; } else { if (!sk_X509_push(ctx->chain, chain_ss)) { - X509_free(chain_ss); X509error(ERR_R_MALLOC_FAILURE); - return 0; + ctx->error = X509_V_ERR_OUT_OF_MEM; + ok = 0; + goto end; } num++; ctx->last_untrusted = num; @@ -539,8 +549,7 @@ X509_verify_cert(X509_STORE_CTX *ctx) ok = ctx->check_policy(ctx); end: - if (sktmp != NULL) - sk_X509_free(sktmp); + sk_X509_free(sktmp); X509_free(chain_ss); /* Safety net, error returns must set ctx->error */ diff --git a/lib/libcrypto/x509/x509_vfy.h b/lib/libcrypto/x509/x509_vfy.h index 9e0730b014..c5eae9d398 100644 --- a/lib/libcrypto/x509/x509_vfy.h +++ b/lib/libcrypto/x509/x509_vfy.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vfy.h,v 1.27 2018/03/20 15:26:22 jsing Exp $ */ +/* $OpenBSD: x509_vfy.h,v 1.30 2018/08/24 19:21:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -134,17 +134,16 @@ typedef struct x509_lookup_method_st void (*free)(X509_LOOKUP *ctx); int (*init)(X509_LOOKUP *ctx); int (*shutdown)(X509_LOOKUP *ctx); - int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl, - char **ret); - int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name, - X509_OBJECT *ret); - int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name, - ASN1_INTEGER *serial,X509_OBJECT *ret); - int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type, - unsigned char *bytes,int len, - X509_OBJECT *ret); - int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len, - X509_OBJECT *ret); + int (*ctrl)(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, + char **ret); + int (*get_by_subject)(X509_LOOKUP *ctx, int type, X509_NAME *name, + X509_OBJECT *ret); + int (*get_by_issuer_serial)(X509_LOOKUP *ctx, int type, X509_NAME *name, + ASN1_INTEGER *serial,X509_OBJECT *ret); + int (*get_by_fingerprint)(X509_LOOKUP *ctx, int type, + const unsigned char *bytes, int len, X509_OBJECT *ret); + int (*get_by_alias)(X509_LOOKUP *ctx, int type, const char *str, + int len, X509_OBJECT *ret); } X509_LOOKUP_METHOD; typedef struct X509_VERIFY_PARAM_ID_st X509_VERIFY_PARAM_ID; @@ -424,7 +423,7 @@ int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, X509_NAME *name); X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name); X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); -void X509_OBJECT_up_ref_count(X509_OBJECT *a); +int X509_OBJECT_up_ref_count(X509_OBJECT *a); int X509_OBJECT_get_type(const X509_OBJECT *a); void X509_OBJECT_free_contents(X509_OBJECT *a); X509 *X509_OBJECT_get0_X509(const X509_OBJECT *xo); @@ -496,8 +495,8 @@ int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, ASN1_INTEGER *serial, X509_OBJECT *ret); int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, - unsigned char *bytes, int len, X509_OBJECT *ret); -int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, + const unsigned char *bytes, int len, X509_OBJECT *ret); +int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, const char *str, int len, X509_OBJECT *ret); int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); diff --git a/lib/libcrypto/x509/x509_vpm.c b/lib/libcrypto/x509/x509_vpm.c index 0897137697..baebcf7bca 100644 --- a/lib/libcrypto/x509/x509_vpm.c +++ b/lib/libcrypto/x509/x509_vpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vpm.c,v 1.17 2018/03/22 15:54:46 beck Exp $ */ +/* $OpenBSD: x509_vpm.c,v 1.18 2018/04/06 07:08:20 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -125,7 +125,7 @@ sk_deep_copy(void *sk_void, void *copy_func_void, void *free_func_void) } static int -int_x509_param_set_hosts(X509_VERIFY_PARAM_ID *id, int mode, +x509_param_set_hosts_internal(X509_VERIFY_PARAM_ID *id, int mode, const char *name, size_t namelen) { char *copy; @@ -134,7 +134,6 @@ int_x509_param_set_hosts(X509_VERIFY_PARAM_ID *id, int mode, namelen = strlen(name); /* * Refuse names with embedded NUL bytes. - * XXX: Do we need to push an error onto the error stack? */ if (name && memchr(name, '\0', namelen)) return 0; @@ -197,6 +196,7 @@ x509_verify_param_zero(X509_VERIFY_PARAM *param) free(paramid->ip); paramid->ip = NULL; paramid->iplen = 0; + paramid->poisoned = 0; } X509_VERIFY_PARAM * @@ -367,24 +367,28 @@ X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from) } static int -int_x509_param_set1(char **pdest, size_t *pdestlen, const char *src, - size_t srclen) +x509_param_set1_internal(char **pdest, size_t *pdestlen, const char *src, + size_t srclen, int nonul) { char *tmp; - if (src) { - if (srclen == 0) { - if ((tmp = strdup(src)) == NULL) - return 0; - srclen = strlen(src); - } else { - if ((tmp = malloc(srclen)) == NULL) - return 0; - memcpy(tmp, src, srclen); - } + + if (src == NULL) + return 0; + + if (srclen == 0) { + srclen = strlen(src); + if (srclen == 0) + return 0; + if ((tmp = strdup(src)) == NULL) + return 0; } else { - tmp = NULL; - srclen = 0; + if (nonul && memchr(src, '\0', srclen)) + return 0; + if ((tmp = malloc(srclen)) == NULL) + return 0; + memcpy(tmp, src, srclen); } + if (*pdest) free(*pdest); *pdest = tmp; @@ -505,14 +509,20 @@ int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, const char *name, size_t namelen) { - return int_x509_param_set_hosts(param->id, SET_HOST, name, namelen); + if (x509_param_set_hosts_internal(param->id, SET_HOST, name, namelen)) + return 1; + param->id->poisoned = 1; + return 0; } int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, const char *name, size_t namelen) { - return int_x509_param_set_hosts(param->id, ADD_HOST, name, namelen); + if (x509_param_set_hosts_internal(param->id, ADD_HOST, name, namelen)) + return 1; + param->id->poisoned = 1; + return 0; } void @@ -531,18 +541,25 @@ int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, const char *email, size_t emaillen) { - return int_x509_param_set1(¶m->id->email, ¶m->id->emaillen, - email, emaillen); + if (x509_param_set1_internal(¶m->id->email, ¶m->id->emaillen, + email, emaillen, 1)) + return 1; + param->id->poisoned = 1; + return 0; } int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, const unsigned char *ip, size_t iplen) { - if (iplen != 0 && iplen != 4 && iplen != 16) - return 0; - return int_x509_param_set1((char **)¶m->id->ip, ¶m->id->iplen, - (char *)ip, iplen); + if (iplen != 4 && iplen != 16) + goto err; + if (x509_param_set1_internal((char **)¶m->id->ip, ¶m->id->iplen, + (char *)ip, iplen, 0)) + return 1; + err: + param->id->poisoned = 1; + return 0; } int @@ -552,8 +569,6 @@ X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, const char *ipasc) size_t iplen; iplen = (size_t)a2i_ipadd(ipout, ipasc); - if (iplen == 0) - return 0; return X509_VERIFY_PARAM_set1_ip(param, ipout, iplen); } diff --git a/lib/libcrypto/x509/x509name.c b/lib/libcrypto/x509/x509name.c index 2ca1a76b64..3649d6ab7c 100644 --- a/lib/libcrypto/x509/x509name.c +++ b/lib/libcrypto/x509/x509name.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509name.c,v 1.15 2018/03/17 15:28:27 tb Exp $ */ +/* $OpenBSD: x509name.c,v 1.26 2018/05/30 15:35:45 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -78,7 +78,7 @@ X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) } int -X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf, +X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, char *buf, int len) { int i; @@ -99,7 +99,7 @@ X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf, } int -X509_NAME_entry_count(X509_NAME *name) +X509_NAME_entry_count(const X509_NAME *name) { if (name == NULL) return (0); @@ -107,7 +107,7 @@ X509_NAME_entry_count(X509_NAME *name) } int -X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos) +X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos) { ASN1_OBJECT *obj; @@ -119,7 +119,8 @@ X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos) /* NOTE: you should be passsing -1, not 0 as lastpos */ int -X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int lastpos) +X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, + int lastpos) { int n; X509_NAME_ENTRY *ne; @@ -140,7 +141,7 @@ X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int lastpos) } X509_NAME_ENTRY * -X509_NAME_get_entry(X509_NAME *name, int loc) +X509_NAME_get_entry(const X509_NAME *name, int loc) { if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc || loc < 0) @@ -188,8 +189,8 @@ X509_NAME_delete_entry(X509_NAME *name, int loc) } int -X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, - unsigned char *bytes, int len, int loc, int set) +X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len, int loc, int set) { X509_NAME_ENTRY *ne; int ret; @@ -204,7 +205,7 @@ X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, - unsigned char *bytes, int len, int loc, int set) + const unsigned char *bytes, int len, int loc, int set) { X509_NAME_ENTRY *ne; int ret; @@ -235,7 +236,8 @@ X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, /* if set is -1, append to previous set, 0 'a new one', and 1, * prepend to the guy we are about to stomp on. */ int -X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc, int set) +X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, + int set) { X509_NAME_ENTRY *new_name = NULL; int n, i, inc; @@ -249,17 +251,15 @@ X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc, int set) loc = n; else if (loc < 0) loc = n; - + inc = (set == 0); name->modified = 1; if (set == -1) { if (loc == 0) { set = 0; inc = 1; - } else { + } else set = sk_X509_NAME_ENTRY_value(sk, loc - 1)->set; - inc = 0; - } } else /* if (set >= 0) */ { if (loc >= n) { if (loc != 0) @@ -268,10 +268,10 @@ X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc, int set) set = 0; } else set = sk_X509_NAME_ENTRY_value(sk, loc)->set; - inc = (set == 0) ? 1 : 0; } - if ((new_name = X509_NAME_ENTRY_dup(ne)) == NULL) + /* OpenSSL has ASN1-generated X509_NAME_ENTRY_dup() without const. */ + if ((new_name = X509_NAME_ENTRY_dup((X509_NAME_ENTRY *)ne)) == NULL) goto err; new_name->set = set; if (!sk_X509_NAME_ENTRY_insert(sk, new_name, loc)) { @@ -281,7 +281,7 @@ X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc, int set) if (inc) { n = sk_X509_NAME_ENTRY_num(sk); for (i = loc + 1; i < n; i++) - sk_X509_NAME_ENTRY_value(sk, i - 1)->set += 1; + sk_X509_NAME_ENTRY_value(sk, i)->set += 1; } return (1); @@ -311,7 +311,7 @@ X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, X509_NAME_ENTRY * X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type, - unsigned char *bytes, int len) + const unsigned char *bytes, int len) { ASN1_OBJECT *obj; X509_NAME_ENTRY *nentry; @@ -327,8 +327,8 @@ X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type, } X509_NAME_ENTRY * -X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len) +X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, const ASN1_OBJECT *obj, + int type, const unsigned char *bytes, int len) { X509_NAME_ENTRY *ret; @@ -354,7 +354,7 @@ err: } int -X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj) +X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj) { if ((ne == NULL) || (obj == NULL)) { X509error(ERR_R_PASSED_NULL_PARAMETER); @@ -391,7 +391,7 @@ X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, } ASN1_OBJECT * -X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne) +X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne) { if (ne == NULL) return (NULL); @@ -399,7 +399,7 @@ X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne) } ASN1_STRING * -X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne) +X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne) { if (ne == NULL) return (NULL); diff --git a/lib/libcrypto/x509/x509rset.c b/lib/libcrypto/x509/x509rset.c index cfac977636..de02a40038 100644 --- a/lib/libcrypto/x509/x509rset.c +++ b/lib/libcrypto/x509/x509rset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509rset.c,v 1.6 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: x509rset.c,v 1.7 2018/08/24 19:55:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,6 +71,12 @@ X509_REQ_set_version(X509_REQ *x, long version) return (ASN1_INTEGER_set(x->req_info->version, version)); } +long +X509_REQ_get_version(const X509_REQ *x) +{ + return ASN1_INTEGER_get(x->req_info->version); +} + int X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) { @@ -79,6 +85,12 @@ X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) return (X509_NAME_set(&x->req_info->subject, name)); } +X509_NAME * +X509_REQ_get_subject_name(const X509_REQ *x) +{ + return x->req_info->subject; +} + int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey) { diff --git a/lib/libcrypto/x509/x509type.c b/lib/libcrypto/x509/x509type.c index d0dcffb290..315a5c2326 100644 --- a/lib/libcrypto/x509/x509type.c +++ b/lib/libcrypto/x509/x509type.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509type.c,v 1.12 2015/06/13 08:38:10 doug Exp $ */ +/* $OpenBSD: x509type.c,v 1.13 2018/05/30 15:59:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,27 +63,22 @@ #include int -X509_certificate_type(X509 *x, EVP_PKEY *pkey) +X509_certificate_type(const X509 *x, const EVP_PKEY *pkey) { - EVP_PKEY *pk; + const EVP_PKEY *pk = pkey; int ret = 0, i; if (x == NULL) return (0); - if (pkey == NULL) - pk = X509_get_pubkey(x); - else - pk = pkey; - - if (pk == NULL) - return (0); + if (pk == NULL) { + if ((pk = X509_get0_pubkey(x)) == NULL) + return (0); + } switch (pk->type) { case EVP_PKEY_RSA: - ret = EVP_PK_RSA|EVP_PKT_SIGN; -/* if (!sign only extension) */ - ret |= EVP_PKT_ENC; + ret = EVP_PK_RSA|EVP_PKT_SIGN|EVP_PKT_ENC; break; case EVP_PKEY_DSA: ret = EVP_PK_DSA|EVP_PKT_SIGN; @@ -124,7 +119,5 @@ X509_certificate_type(X509 *x, EVP_PKEY *pkey) /* /8 because it's 1024 bits we look for, not bytes */ if (EVP_PKEY_size(pk) <= 1024 / 8) ret |= EVP_PKT_EXP; - if (pkey == NULL) - EVP_PKEY_free(pk); return (ret); } diff --git a/lib/libcrypto/x509v3/v3_alt.c b/lib/libcrypto/x509v3/v3_alt.c index 746339bebd..08063d191b 100644 --- a/lib/libcrypto/x509v3/v3_alt.c +++ b/lib/libcrypto/x509v3/v3_alt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_alt.c,v 1.27 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_alt.c,v 1.28 2018/05/18 19:34:37 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -69,8 +69,8 @@ static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p); static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens); -static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx); -static int do_dirname(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx); +static int do_othername(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx); +static int do_dirname(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx); const X509V3_EXT_METHOD v3_alt[] = { { @@ -481,7 +481,7 @@ v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, GENERAL_NAME * a2i_GENERAL_NAME(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, int gen_type, char *value, int is_nc) + X509V3_CTX *ctx, int gen_type, const char *value, int is_nc) { char is_string = 0; GENERAL_NAME *gen = NULL; @@ -553,8 +553,7 @@ a2i_GENERAL_NAME(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, if (is_string) { if (!(gen->d.ia5 = ASN1_IA5STRING_new()) || - !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value, - strlen(value))) { + !ASN1_STRING_set(gen->d.ia5, value, strlen(value))) { X509V3error(ERR_R_MALLOC_FAILURE); goto err; } @@ -609,7 +608,7 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, } static int -do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) +do_othername(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx) { char *objtmp = NULL, *p; int objlen; @@ -638,7 +637,7 @@ do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) } static int -do_dirname(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) +do_dirname(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx) { int ret; STACK_OF(CONF_VALUE) *sk; diff --git a/lib/libcrypto/x509v3/v3_conf.c b/lib/libcrypto/x509v3/v3_conf.c index 27e1bc9f57..78ff19808b 100644 --- a/lib/libcrypto/x509v3/v3_conf.c +++ b/lib/libcrypto/x509v3/v3_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_conf.c,v 1.21 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_conf.c,v 1.23 2018/05/18 19:34:37 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -66,23 +66,27 @@ #include #include -static int v3_check_critical(char **value); -static int v3_check_generic(char **value); +static int v3_check_critical(const char **value); +static int v3_check_generic(const char **value); static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, - int crit, char *value); -static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, + int crit, const char *value); +static X509_EXTENSION *v3_generic_extension(const char *ext, const char *value, int crit, int type, X509V3_CTX *ctx); -static char *conf_lhash_get_string(void *db, char *section, char *value); -static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section); +static char *conf_lhash_get_string(void *db, const char *section, + const char *value); +static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, + const char *section); static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid, int crit, void *ext_struc); -static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len); +static unsigned char *generic_asn1(const char *value, X509V3_CTX *ctx, + long *ext_len); /* CONF *conf: Config file */ /* char *name: Name */ /* char *value: Value */ X509_EXTENSION * -X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value) +X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, + const char *value) { int crit; int ext_type; @@ -102,7 +106,8 @@ X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value) /* CONF *conf: Config file */ /* char *value: Value */ X509_EXTENSION * -X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value) +X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, + const char *value) { int crit; int ext_type; @@ -117,7 +122,8 @@ X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value) /* CONF *conf: Config file */ /* char *value: Value */ static X509_EXTENSION * -do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, int crit, char *value) +do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, int crit, + const char *value) { const X509V3_EXT_METHOD *method; X509_EXTENSION *ext; @@ -233,9 +239,9 @@ X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) /* Check the extension string for critical flag */ static int -v3_check_critical(char **value) +v3_check_critical(const char **value) { - char *p = *value; + const char *p = *value; if ((strlen(p) < 9) || strncmp(p, "critical,", 9)) return 0; @@ -247,10 +253,10 @@ v3_check_critical(char **value) /* Check extension string for generic extension and return the type */ static int -v3_check_generic(char **value) +v3_check_generic(const char **value) { int gen_type = 0; - char *p = *value; + const char *p = *value; if ((strlen(p) >= 4) && !strncmp(p, "DER:", 4)) { p += 4; @@ -269,7 +275,7 @@ v3_check_generic(char **value) /* Create a generic extension: for now just handle DER type */ static X509_EXTENSION * -v3_generic_extension(const char *ext, char *value, int crit, int gen_type, +v3_generic_extension(const char *ext, const char *value, int crit, int gen_type, X509V3_CTX *ctx) { unsigned char *ext_der = NULL; @@ -318,7 +324,7 @@ err: } static unsigned char * -generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len) +generic_asn1(const char *value, X509V3_CTX *ctx, long *ext_len) { ASN1_TYPE *typ; unsigned char *ext_der = NULL; @@ -336,7 +342,7 @@ generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len) */ int -X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, +X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, STACK_OF(X509_EXTENSION) **sk) { X509_EXTENSION *ext; @@ -360,7 +366,8 @@ X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, /* Convenience functions to add extensions to a certificate, CRL and request */ int -X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert) +X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509 *cert) { STACK_OF(X509_EXTENSION) **sk = NULL; @@ -372,7 +379,7 @@ X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert) /* Same as above but for a CRL */ int -X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, +X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, X509_CRL *crl) { STACK_OF(X509_EXTENSION) **sk = NULL; @@ -385,7 +392,7 @@ X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, /* Add extensions to certificate request */ int -X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, +X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, X509_REQ *req) { STACK_OF(X509_EXTENSION) *extlist = NULL, **sk = NULL; @@ -404,27 +411,23 @@ X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, /* Config database functions */ char * -X509V3_get_string(X509V3_CTX *ctx, char *name, char *section) +X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section) { if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_string) { X509V3error(X509V3_R_OPERATION_NOT_DEFINED); return NULL; } - if (ctx->db_meth->get_string) - return ctx->db_meth->get_string(ctx->db, name, section); - return NULL; + return ctx->db_meth->get_string(ctx->db, name, section); } STACK_OF(CONF_VALUE) * -X509V3_get_section(X509V3_CTX *ctx, char *section) +X509V3_get_section(X509V3_CTX *ctx, const char *section) { if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section) { X509V3error(X509V3_R_OPERATION_NOT_DEFINED); return NULL; } - if (ctx->db_meth->get_section) - return ctx->db_meth->get_section(ctx->db, section); - return NULL; + return ctx->db_meth->get_section(ctx->db, section); } void @@ -446,13 +449,13 @@ X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) } static char * -nconf_get_string(void *db, char *section, char *value) +nconf_get_string(void *db, const char *section, const char *value) { return NCONF_get_string(db, section, value); } -static -STACK_OF(CONF_VALUE) *nconf_get_section(void *db, char *section) +static STACK_OF(CONF_VALUE) * +nconf_get_section(void *db, const char *section) { return NCONF_get_section(db, section); } @@ -485,8 +488,8 @@ X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req, /* Old conf compatibility functions */ X509_EXTENSION * -X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *name, - char *value) +X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, const char *name, + const char *value) { CONF ctmp; @@ -498,7 +501,7 @@ X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *name, /* char *value: Value */ X509_EXTENSION * X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int ext_nid, - char *value) + const char *value) { CONF ctmp; @@ -507,13 +510,13 @@ X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int ext_nid, } static char * -conf_lhash_get_string(void *db, char *section, char *value) +conf_lhash_get_string(void *db, const char *section, const char *value) { return CONF_get_string(db, section, value); } static STACK_OF(CONF_VALUE) * -conf_lhash_get_section(void *db, char *section) +conf_lhash_get_section(void *db, const char *section) { return CONF_get_section(db, section); } @@ -533,8 +536,8 @@ X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash) } int -X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *section, - X509 *cert) +X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, + const char *section, X509 *cert) { CONF ctmp; @@ -546,7 +549,7 @@ X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *section, int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - char *section, X509_CRL *crl) + const char *section, X509_CRL *crl) { CONF ctmp; @@ -558,7 +561,7 @@ X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - char *section, X509_REQ *req) + const char *section, X509_REQ *req) { CONF ctmp; diff --git a/lib/libcrypto/x509v3/v3_enum.c b/lib/libcrypto/x509v3/v3_enum.c index af6cebcee9..2ef3ea3e90 100644 --- a/lib/libcrypto/x509v3/v3_enum.c +++ b/lib/libcrypto/x509v3/v3_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_enum.c,v 1.12 2016/12/30 15:54:49 jsing Exp $ */ +/* $OpenBSD: v3_enum.c,v 1.13 2018/05/19 10:37:02 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -93,7 +93,7 @@ const X509V3_EXT_METHOD v3_crl_reason = { }; char * -i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e) +i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, const ASN1_ENUMERATED *e) { ENUMERATED_NAMES *enam; long strval; diff --git a/lib/libcrypto/x509v3/v3_info.c b/lib/libcrypto/x509v3/v3_info.c index 27b5415b2a..ebacbf5b0a 100644 --- a/lib/libcrypto/x509v3/v3_info.c +++ b/lib/libcrypto/x509v3/v3_info.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_info.c,v 1.25 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_info.c,v 1.26 2018/05/19 10:37:02 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -293,7 +293,7 @@ err: } int -i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a) +i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION* a) { i2a_ASN1_OBJECT(bp, a->method); return 2; diff --git a/lib/libcrypto/x509v3/v3_lib.c b/lib/libcrypto/x509v3/v3_lib.c index f0cc93bda6..94f3e4b753 100644 --- a/lib/libcrypto/x509v3/v3_lib.c +++ b/lib/libcrypto/x509v3/v3_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_lib.c,v 1.17 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_lib.c,v 1.18 2018/05/19 10:41:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -227,7 +227,7 @@ X509V3_EXT_d2i(X509_EXTENSION *ext) */ void * -X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) +X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) { int lastpos, i; X509_EXTENSION *ex, *found_ex = NULL; diff --git a/lib/libcrypto/x509v3/v3_prn.c b/lib/libcrypto/x509v3/v3_prn.c index f65c7aaa8a..f294c36b3e 100644 --- a/lib/libcrypto/x509v3/v3_prn.c +++ b/lib/libcrypto/x509v3/v3_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_prn.c,v 1.19 2016/12/30 15:54:49 jsing Exp $ */ +/* $OpenBSD: v3_prn.c,v 1.20 2018/05/19 10:41:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -152,8 +152,8 @@ err: } int -X509V3_extensions_print(BIO *bp, char *title, STACK_OF(X509_EXTENSION) *exts, - unsigned long flag, int indent) +X509V3_extensions_print(BIO *bp, const char *title, + const STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent) { int i, j; diff --git a/lib/libcrypto/x509v3/v3_purp.c b/lib/libcrypto/x509v3/v3_purp.c index d692a19c25..0fdec224a3 100644 --- a/lib/libcrypto/x509v3/v3_purp.c +++ b/lib/libcrypto/x509v3/v3_purp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_purp.c,v 1.30 2017/06/22 17:28:00 jsing Exp $ */ +/* $OpenBSD: v3_purp.c,v 1.31 2018/05/18 18:30:03 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -172,7 +172,7 @@ X509_PURPOSE_get0(int idx) } int -X509_PURPOSE_get_by_sname(char *sname) +X509_PURPOSE_get_by_sname(const char *sname) { int i; X509_PURPOSE *xptmp; @@ -204,8 +204,8 @@ X509_PURPOSE_get_by_id(int purpose) int X509_PURPOSE_add(int id, int trust, int flags, - int (*ck)(const X509_PURPOSE *, const X509 *, int), char *name, - char *sname, void *arg) + int (*ck)(const X509_PURPOSE *, const X509 *, int), const char *name, + const char *sname, void *arg) { int idx; X509_PURPOSE *ptmp; @@ -302,25 +302,25 @@ X509_PURPOSE_cleanup(void) } int -X509_PURPOSE_get_id(X509_PURPOSE *xp) +X509_PURPOSE_get_id(const X509_PURPOSE *xp) { return xp->purpose; } char * -X509_PURPOSE_get0_name(X509_PURPOSE *xp) +X509_PURPOSE_get0_name(const X509_PURPOSE *xp) { return xp->name; } char * -X509_PURPOSE_get0_sname(X509_PURPOSE *xp) +X509_PURPOSE_get0_sname(const X509_PURPOSE *xp) { return xp->sname; } int -X509_PURPOSE_get_trust(X509_PURPOSE *xp) +X509_PURPOSE_get_trust(const X509_PURPOSE *xp) { return xp->trust; } diff --git a/lib/libcrypto/x509v3/v3_skey.c b/lib/libcrypto/x509v3/v3_skey.c index 9dc1741788..aec2d5b7ec 100644 --- a/lib/libcrypto/x509v3/v3_skey.c +++ b/lib/libcrypto/x509v3/v3_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_skey.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_skey.c,v 1.16 2018/05/19 10:37:02 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -83,13 +83,14 @@ const X509V3_EXT_METHOD v3_skey_id = { }; char * -i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *oct) +i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, const ASN1_OCTET_STRING *oct) { return hex_to_string(oct->data, oct->length); } ASN1_OCTET_STRING * -s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str) +s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + const char *str) { ASN1_OCTET_STRING *oct; long length; diff --git a/lib/libcrypto/x509v3/v3_sxnet.c b/lib/libcrypto/x509v3/v3_sxnet.c index 14c6e5c0a4..53db28248a 100644 --- a/lib/libcrypto/x509v3/v3_sxnet.c +++ b/lib/libcrypto/x509v3/v3_sxnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_sxnet.c,v 1.19 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_sxnet.c,v 1.21 2018/05/13 15:03:01 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -253,7 +253,7 @@ sxnet_v2i(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, /* Add an id given the zone as an ASCII number */ int -SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen) +SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen) { ASN1_INTEGER *izone = NULL; @@ -267,7 +267,8 @@ SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen) /* Add an id given the zone as an unsigned long */ int -SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen) +SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, + int userlen) { ASN1_INTEGER *izone = NULL; @@ -286,7 +287,8 @@ SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen) */ int -SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, char *user, int userlen) +SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, const char *user, + int userlen) { SXNET *sx = NULL; SXNETID *id = NULL; @@ -335,7 +337,7 @@ err: } ASN1_OCTET_STRING * -SXNET_get_id_asc(SXNET *sx, char *zone) +SXNET_get_id_asc(SXNET *sx, const char *zone) { ASN1_INTEGER *izone = NULL; ASN1_OCTET_STRING *oct; diff --git a/lib/libcrypto/x509v3/v3_utl.c b/lib/libcrypto/x509v3/v3_utl.c index 67ecc81a44..4f8d16fd00 100644 --- a/lib/libcrypto/x509v3/v3_utl.c +++ b/lib/libcrypto/x509v3/v3_utl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_utl.c,v 1.27 2018/03/20 16:16:59 jsing Exp $ */ +/* $OpenBSD: v3_utl.c,v 1.31 2018/05/19 10:50:08 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -140,7 +140,7 @@ X509V3_add_value_bool(const char *name, int asn1_bool, } int -X509V3_add_value_bool_nf(char *name, int asn1_bool, +X509V3_add_value_bool_nf(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) **extlist) { if (asn1_bool) @@ -150,7 +150,7 @@ X509V3_add_value_bool_nf(char *name, int asn1_bool, char * -i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *a) +i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, const ASN1_ENUMERATED *a) { BIGNUM *bntmp = NULL; char *strtmp = NULL; @@ -165,7 +165,7 @@ i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *a) } char * -i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, ASN1_INTEGER *a) +i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, const ASN1_INTEGER *a) { BIGNUM *bntmp = NULL; char *strtmp = NULL; @@ -180,7 +180,7 @@ i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, ASN1_INTEGER *a) } ASN1_INTEGER * -s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) +s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, const char *value) { BIGNUM *bn = NULL; ASN1_INTEGER *aint; @@ -230,7 +230,7 @@ s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) } int -X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, +X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, STACK_OF(CONF_VALUE) **extlist) { char *strtmp; @@ -246,7 +246,7 @@ X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, } int -X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool) +X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool) { char *btmp; @@ -271,7 +271,7 @@ err: } int -X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint) +X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint) { ASN1_INTEGER *itmp; diff --git a/lib/libcrypto/x509v3/x509v3.h b/lib/libcrypto/x509v3/x509v3.h index fbafd694ed..5d6c588730 100644 --- a/lib/libcrypto/x509v3/x509v3.h +++ b/lib/libcrypto/x509v3/x509v3.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509v3.h,v 1.22 2017/06/22 17:28:00 jsing Exp $ */ +/* $OpenBSD: x509v3.h,v 1.30 2018/05/19 10:50:08 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -121,9 +121,9 @@ void *usr_data; /* Any extension specific data */ }; typedef struct X509V3_CONF_METHOD_st { -char * (*get_string)(void *db, char *section, char *value); -STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); -void (*free_string)(void *db, char * string); +char *(*get_string)(void *db, const char *section, const char *value); +STACK_OF(CONF_VALUE) *(*get_section)(void *db, const char *section); +void (*free_string)(void *db, char *string); void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); } X509V3_CONF_METHOD; @@ -524,11 +524,14 @@ SXNETID *d2i_SXNETID(SXNETID **a, const unsigned char **in, long len); int i2d_SXNETID(SXNETID *a, unsigned char **out); extern const ASN1_ITEM SXNETID_it; -int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); -int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); -int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); +int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, + int userlen); +int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, + int userlen); +int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user, + int userlen); -ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); +ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone); ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); @@ -592,15 +595,17 @@ int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, ASN1_TYPE **pvalue); -char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); -ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); +char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, + const ASN1_OCTET_STRING *ia5); +ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, const char *str); EXTENDED_KEY_USAGE *EXTENDED_KEY_USAGE_new(void); void EXTENDED_KEY_USAGE_free(EXTENDED_KEY_USAGE *a); EXTENDED_KEY_USAGE *d2i_EXTENDED_KEY_USAGE(EXTENDED_KEY_USAGE **a, const unsigned char **in, long len); int i2d_EXTENDED_KEY_USAGE(EXTENDED_KEY_USAGE *a, unsigned char **out); extern const ASN1_ITEM EXTENDED_KEY_USAGE_it; -int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); +int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION* a); CERTIFICATEPOLICIES *CERTIFICATEPOLICIES_new(void); void CERTIFICATEPOLICIES_free(CERTIFICATEPOLICIES *a); @@ -683,7 +688,7 @@ extern const ASN1_ITEM POLICY_CONSTRAINTS_it; GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - int gen_type, char *value, int is_nc); + int gen_type, const char *value, int is_nc); #ifdef HEADER_CONF_H GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, @@ -693,34 +698,41 @@ GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); void X509V3_conf_free(CONF_VALUE *val); -X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); -X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); -int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); -int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); -int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); -int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); +X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, + const char *value); +X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, + const char *value); +int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, + STACK_OF(X509_EXTENSION) **sk); +int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509 *cert); +int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509_REQ *req); +int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509_CRL *crl); X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - int ext_nid, char *value); + int ext_nid, const char *value); X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - char *name, char *value); + const char *name, const char *value); int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - char *section, X509 *cert); + const char *section, X509 *cert); int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - char *section, X509_REQ *req); + const char *section, X509_REQ *req); int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - char *section, X509_CRL *crl); + const char *section, X509_CRL *crl); -int X509V3_add_value_bool_nf(char *name, int asn1_bool, +int X509V3_add_value_bool_nf(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) **extlist); -int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); -int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); +int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool); +int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint); void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash); #endif -char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); -STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); +char *X509V3_get_string(X509V3_CTX *ctx, const char *name, + const char *section); +STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section); void X509V3_string_free(X509V3_CTX *ctx, char *str); void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, @@ -732,12 +744,13 @@ int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist); int X509V3_add_value_bool(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, +int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, STACK_OF(CONF_VALUE) **extlist); -char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); -ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); -char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); -char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint); +ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value); +char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint); +char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, + const ASN1_ENUMERATED *aint); int X509V3_EXT_add(X509V3_EXT_METHOD *ext); int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); int X509V3_EXT_add_alias(int nid_to, int nid_from); @@ -748,7 +761,8 @@ const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); int X509V3_add_standard_extensions(void); STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); void *X509V3_EXT_d2i(X509_EXTENSION *ext); -void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); +void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, + int *idx); X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); @@ -763,7 +777,8 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); -int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); +int X509V3_extensions_print(BIO *out, const char *title, + const STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); int X509_check_ca(X509 *x); int X509_check_purpose(X509 *x, int id, int ca); @@ -773,16 +788,16 @@ int X509_check_issued(X509 *issuer, X509 *subject); int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid); int X509_PURPOSE_get_count(void); X509_PURPOSE * X509_PURPOSE_get0(int idx); -int X509_PURPOSE_get_by_sname(char *sname); +int X509_PURPOSE_get_by_sname(const char *sname); int X509_PURPOSE_get_by_id(int id); int X509_PURPOSE_add(int id, int trust, int flags, int (*ck)(const X509_PURPOSE *, const X509 *, int), - char *name, char *sname, void *arg); -char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); -char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); -int X509_PURPOSE_get_trust(X509_PURPOSE *xp); + const char *name, const char *sname, void *arg); +char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); +char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); +int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); void X509_PURPOSE_cleanup(void); -int X509_PURPOSE_get_id(X509_PURPOSE *); +int X509_PURPOSE_get_id(const X509_PURPOSE *); STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x); STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x); diff --git a/lib/libssl/bio_ssl.c b/lib/libssl/bio_ssl.c index 344ca21786..93cfa0d2a4 100644 --- a/lib/libssl/bio_ssl.c +++ b/lib/libssl/bio_ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ssl.c,v 1.27 2017/02/07 02:08:38 beck Exp $ */ +/* $OpenBSD: bio_ssl.c,v 1.29 2018/08/24 20:30:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -85,7 +85,7 @@ typedef struct bio_ssl_st { time_t last_time; } BIO_SSL; -static BIO_METHOD methods_sslp = { +static const BIO_METHOD methods_sslp = { .type = BIO_TYPE_SSL, .name = "ssl", .bwrite = ssl_write, @@ -97,7 +97,7 @@ static BIO_METHOD methods_sslp = { .callback_ctrl = ssl_callback_ctrl, }; -BIO_METHOD * +const BIO_METHOD * BIO_f_ssl(void) { return (&methods_sslp); @@ -568,7 +568,9 @@ BIO_ssl_copy_session_id(BIO *t, BIO *f) if ((((BIO_SSL *)t->ptr)->ssl == NULL) || (((BIO_SSL *)f->ptr)->ssl == NULL)) return (0); - SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl); + if (!SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, + ((BIO_SSL *)f->ptr)->ssl)) + return (0); return (1); } diff --git a/lib/libssl/bs_cbb.c b/lib/libssl/bs_cbb.c index bf7de3fd33..beb588fe25 100644 --- a/lib/libssl/bs_cbb.c +++ b/lib/libssl/bs_cbb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbb.c,v 1.18 2017/11/28 16:34:20 jsing Exp $ */ +/* $OpenBSD: bs_cbb.c,v 1.19 2018/08/16 18:39:37 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -406,6 +406,15 @@ CBB_add_u24(CBB *cbb, size_t value) } int +CBB_add_u32(CBB *cbb, size_t value) +{ + if (value > 0xffffffffUL) + return 0; + + return cbb_add_u(cbb, (uint32_t)value, 4); +} + +int CBB_add_asn1_uint64(CBB *cbb, uint64_t value) { CBB child; diff --git a/lib/libssl/bytestring.h b/lib/libssl/bytestring.h index 2e89a5791a..20ee43999d 100644 --- a/lib/libssl/bytestring.h +++ b/lib/libssl/bytestring.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bytestring.h,v 1.16 2017/11/28 16:34:20 jsing Exp $ */ +/* $OpenBSD: bytestring.h,v 1.17 2018/08/16 18:39:37 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -462,6 +462,12 @@ int CBB_add_u16(CBB *cbb, size_t value); int CBB_add_u24(CBB *cbb, size_t value); /* + * CBB_add_u32 appends a 32-bit, big-endian number from |value| to |cbb|. It + * returns one on success and zero otherwise. + */ +int CBB_add_u32(CBB *cbb, size_t value); + +/* * CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1| * and writes |value| in its contents. It returns one on success and zero on * error. diff --git a/lib/libssl/d1_both.c b/lib/libssl/d1_both.c index 42f8cbd537..95157630f5 100644 --- a/lib/libssl/d1_both.c +++ b/lib/libssl/d1_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_both.c,v 1.52 2017/10/08 16:24:02 jsing Exp $ */ +/* $OpenBSD: d1_both.c,v 1.55 2018/09/05 16:58:59 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -161,7 +161,8 @@ static unsigned int g_probable_mtu[] = {1500 - 28, 512 - 28, 256 - 28}; static unsigned int dtls1_guess_mtu(unsigned int curr_mtu); static void dtls1_fix_message_header(SSL *s, unsigned long frag_off, unsigned long frag_len); -static unsigned char *dtls1_write_message_header(SSL *s, unsigned char *p); +static int dtls1_write_message_header(const struct hm_header_st *msg_hdr, + unsigned long frag_off, unsigned long frag_len, unsigned char *p); static long dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok); @@ -212,7 +213,7 @@ dtls1_hm_fragment_free(hm_fragment *frag) if (frag->msg_header.is_ccs) { EVP_CIPHER_CTX_free( frag->msg_header.saved_retransmit_state.enc_write_ctx); - EVP_MD_CTX_destroy( + EVP_MD_CTX_free( frag->msg_header.saved_retransmit_state.write_hash); } free(frag->fragment); @@ -301,8 +302,10 @@ dtls1_do_write(SSL *s, int type) dtls1_fix_message_header(s, frag_off, len - DTLS1_HM_HEADER_LENGTH); - dtls1_write_message_header(s, - (unsigned char *)&s->internal->init_buf->data[s->internal->init_off]); + if (!dtls1_write_message_header(&D1I(s)->w_msg_hdr, + D1I(s)->w_msg_hdr.frag_off, D1I(s)->w_msg_hdr.frag_len, + (unsigned char *)&s->internal->init_buf->data[s->internal->init_off])) + return -1; OPENSSL_assert(len >= DTLS1_HM_HEADER_LENGTH); } @@ -348,12 +351,9 @@ dtls1_do_write(SSL *s, int type) * Reconstruct message header is if it * is being sent in single fragment */ - *p++ = msg_hdr->type; - l2n3(msg_hdr->msg_len, p); - s2n (msg_hdr->seq, p); - l2n3(0, p); - l2n3(msg_hdr->msg_len, p); - p -= DTLS1_HM_HEADER_LENGTH; + if (!dtls1_write_message_header(msg_hdr, + 0, msg_hdr->msg_len, p)) + return (-1); xlen = ret; } else { p += DTLS1_HM_HEADER_LENGTH; @@ -431,13 +431,9 @@ again: msg_len = msg_hdr->msg_len; /* reconstruct message header */ - *(p++) = msg_hdr->type; - l2n3(msg_len, p); - s2n (msg_hdr->seq, p); - l2n3(0, p); - l2n3(msg_len, p); + if (!dtls1_write_message_header(msg_hdr, 0, msg_len, p)) + return -1; - p -= DTLS1_HM_HEADER_LENGTH; msg_len += DTLS1_HM_HEADER_LENGTH; tls1_finish_mac(s, p, msg_len); @@ -1167,19 +1163,33 @@ dtls1_fix_message_header(SSL *s, unsigned long frag_off, unsigned long frag_len) msg_hdr->frag_len = frag_len; } -static unsigned char * -dtls1_write_message_header(SSL *s, unsigned char *p) +static int +dtls1_write_message_header(const struct hm_header_st *msg_hdr, + unsigned long frag_off, unsigned long frag_len, unsigned char *p) { - struct hm_header_st *msg_hdr = &D1I(s)->w_msg_hdr; + CBB cbb; - *p++ = msg_hdr->type; - l2n3(msg_hdr->msg_len, p); + /* We assume DTLS1_HM_HEADER_LENGTH bytes are available for now... */ + if (!CBB_init_fixed(&cbb, p, DTLS1_HM_HEADER_LENGTH)) + return 0; + if (!CBB_add_u8(&cbb, msg_hdr->type)) + goto err; + if (!CBB_add_u24(&cbb, msg_hdr->msg_len)) + goto err; + if (!CBB_add_u16(&cbb, msg_hdr->seq)) + goto err; + if (!CBB_add_u24(&cbb, frag_off)) + goto err; + if (!CBB_add_u24(&cbb, frag_len)) + goto err; + if (!CBB_finish(&cbb, NULL, NULL)) + goto err; - s2n(msg_hdr->seq, p); - l2n3(msg_hdr->frag_off, p); - l2n3(msg_hdr->frag_len, p); + return 1; - return p; + err: + CBB_cleanup(&cbb); + return 0; } unsigned int @@ -1243,12 +1253,3 @@ dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr) ccs_hdr->type = *(data++); } - -int -dtls1_shutdown(SSL *s) -{ - int ret; - - ret = ssl3_shutdown(s); - return ret; -} diff --git a/lib/libssl/d1_clnt.c b/lib/libssl/d1_clnt.c index f3a7e5ff22..8f60f4a8c4 100644 --- a/lib/libssl/d1_clnt.c +++ b/lib/libssl/d1_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_clnt.c,v 1.79 2017/10/10 15:13:26 jsing Exp $ */ +/* $OpenBSD: d1_clnt.c,v 1.81 2018/08/30 16:56:16 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -136,11 +136,6 @@ static const SSL_METHOD_INTERNAL DTLSv1_client_method_internal_data = { .ssl_free = dtls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = dtls1_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = dtls1_get_client_method, .get_timeout = dtls1_default_timeout, .ssl_version = ssl_undefined_void_function, diff --git a/lib/libssl/d1_meth.c b/lib/libssl/d1_meth.c index 9ecca0027c..e157dc4d93 100644 --- a/lib/libssl/d1_meth.c +++ b/lib/libssl/d1_meth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_meth.c,v 1.15 2017/10/12 15:52:50 jsing Exp $ */ +/* $OpenBSD: d1_meth.c,v 1.17 2018/08/30 16:56:16 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -74,11 +74,6 @@ static const SSL_METHOD_INTERNAL DTLSv1_method_internal_data = { .ssl_free = dtls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = dtls1_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = dtls1_get_method, .get_timeout = dtls1_default_timeout, .ssl_version = ssl_undefined_void_function, diff --git a/lib/libssl/d1_pkt.c b/lib/libssl/d1_pkt.c index 9f670fadfd..b3104d21e7 100644 --- a/lib/libssl/d1_pkt.c +++ b/lib/libssl/d1_pkt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_pkt.c,v 1.63 2017/05/07 04:22:24 beck Exp $ */ +/* $OpenBSD: d1_pkt.c,v 1.64 2018/08/24 19:35:05 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -825,14 +825,6 @@ start: /* XDTLS: In a pathalogical case, the Client Hello * may be fragmented--don't always expect dest_maxlen bytes */ if (rr->length < dest_maxlen) { -#ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE - /* - * for normal alerts rr->length is 2, while - * dest_maxlen is 7 if we were to handle this - * non-existing alert... - */ - FIX ME -#endif s->internal->rstate = SSL_ST_READ_HEADER; rr->length = 0; goto start; @@ -1396,23 +1388,12 @@ dtls1_dispatch_alert(SSL *s) *ptr++ = s->s3->send_alert[0]; *ptr++ = s->s3->send_alert[1]; -#ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE - if (s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE) { - s2n(D1I(s)->handshake_read_seq, ptr); - l2n3(D1I(s)->r_msg_hdr.frag_off, ptr); - } -#endif - i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf)); if (i <= 0) { s->s3->alert_dispatch = 1; /* fprintf( stderr, "not done with alert\n" ); */ } else { - if (s->s3->send_alert[0] == SSL3_AL_FATAL -#ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE - || s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE -#endif - ) + if (s->s3->send_alert[0] == SSL3_AL_FATAL) (void)BIO_flush(s->wbio); if (s->internal->msg_callback) diff --git a/lib/libssl/d1_srvr.c b/lib/libssl/d1_srvr.c index 57b8ea0e24..c0ee0d00aa 100644 --- a/lib/libssl/d1_srvr.c +++ b/lib/libssl/d1_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_srvr.c,v 1.91 2017/10/12 15:52:50 jsing Exp $ */ +/* $OpenBSD: d1_srvr.c,v 1.94 2018/08/30 16:56:16 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -134,11 +134,6 @@ static const SSL_METHOD_INTERNAL DTLSv1_server_method_internal_data = { .ssl_free = dtls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = dtls1_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = dtls1_get_server_method, .get_timeout = dtls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -188,7 +183,7 @@ dtls1_send_hello_verify_request(SSL *s) return 0; } - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &verify, + if (!ssl3_handshake_msg_start(s, &cbb, &verify, DTLS1_MT_HELLO_VERIFY_REQUEST)) goto err; if (!CBB_add_u16(&verify, s->version)) @@ -197,7 +192,7 @@ dtls1_send_hello_verify_request(SSL *s) goto err; if (!CBB_add_bytes(&cookie, D1I(s)->cookie, D1I(s)->cookie_len)) goto err; - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B; diff --git a/lib/libssl/dtls1.h b/lib/libssl/dtls1.h index c7b2d3af76..cc672a5934 100644 --- a/lib/libssl/dtls1.h +++ b/lib/libssl/dtls1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dtls1.h,v 1.21 2017/01/22 07:16:39 beck Exp $ */ +/* $OpenBSD: dtls1.h,v 1.22 2018/08/24 19:35:05 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -87,11 +87,7 @@ extern "C" { #define DTLS1_CCS_HEADER_LENGTH 1 -#ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE -#define DTLS1_AL_HEADER_LENGTH 7 -#else #define DTLS1_AL_HEADER_LENGTH 2 -#endif #ifndef OPENSSL_NO_SSL_INTERN diff --git a/lib/libssl/man/BIO_f_ssl.3 b/lib/libssl/man/BIO_f_ssl.3 index 6826441e81..ef579c731b 100644 --- a/lib/libssl/man/BIO_f_ssl.3 +++ b/lib/libssl/man/BIO_f_ssl.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_ssl.3,v 1.8 2018/03/21 08:06:34 schwarze Exp $ +.\" $OpenBSD: BIO_f_ssl.3,v 1.10 2018/05/01 16:45:38 schwarze Exp $ .\" full merge up to: OpenSSL f672aee4 Feb 9 11:52:40 2016 -0500 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: May 1 2018 $ .Dt BIO_F_SSL 3 .Os .Sh NAME @@ -71,7 +71,7 @@ .Sh SYNOPSIS .In openssl/bio.h .In openssl/ssl.h -.Ft BIO_METHOD * +.Ft const BIO_METHOD * .Fn BIO_f_ssl void .Ft long .Fo BIO_set_ssl @@ -568,14 +568,18 @@ BIO_free_all(sbio); .Sh HISTORY .Fn BIO_f_ssl , .Fn BIO_set_ssl , -.Fn BIO_get_ssl , +and +.Fn BIO_get_ssl +first appeared in SSLeay 0.6.0. .Fn BIO_set_ssl_mode , .Fn BIO_new_ssl , -.Fn BIO_ssl_copy_session_id , -.Fn BIO_ssl_shutdown , +and +.Fn BIO_ssl_copy_session_id +first appeared in SSLeay 0.8.0. +.Fn BIO_ssl_shutdown and .Fn BIO_do_handshake -appeared before SSLeay 0.8. +first appeared in SSLeay 0.8.1. .Fn BIO_set_ssl_renegotiate_bytes , .Fn BIO_get_num_renegotiates , .Fn BIO_set_ssl_renegotiate_timeout , diff --git a/lib/libssl/man/DTLSv1_listen.3 b/lib/libssl/man/DTLSv1_listen.3 index 26a874a347..047ec0a7ff 100644 --- a/lib/libssl/man/DTLSv1_listen.3 +++ b/lib/libssl/man/DTLSv1_listen.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DTLSv1_listen.3,v 1.3 2018/03/23 02:21:08 schwarze Exp $ +.\" $OpenBSD: DTLSv1_listen.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 7795475f Dec 18 13:18:31 2015 -0500 .\" .\" This file was written by Matt Caswell . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt DTLSV1_LISTEN 3 .Os .Sh NAME @@ -183,5 +183,5 @@ non-fatal), whilst return codes >0 indicate success. .Xr SSL_get_error 3 .Sh HISTORY .Fn DTLSv1_listen -first appeared in OpenSSL 0.9.8m and have been available since +first appeared in OpenSSL 0.9.8m and has been available since .Ox 4.9 . diff --git a/lib/libssl/man/PEM_read_SSL_SESSION.3 b/lib/libssl/man/PEM_read_SSL_SESSION.3 index 1412672caa..b9987ebfb0 100644 --- a/lib/libssl/man/PEM_read_SSL_SESSION.3 +++ b/lib/libssl/man/PEM_read_SSL_SESSION.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: PEM_read_SSL_SESSION.3,v 1.2 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: PEM_read_SSL_SESSION.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL doc/man3/PEM_read_CMS.pod b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Rich Salz . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt PEM_READ_SSL_SESSION 3 .Os .Sh NAME @@ -134,10 +134,13 @@ return the number of bytes written or 0 on error. .Sh SEE ALSO .Xr PEM_read 3 .Sh HISTORY -.Fn PEM_read_SSL_SESSION , -.Fn PEM_read_bio_SSL_SESSION , -.Fn PEM_write_SSL_SESSION , +.Fn PEM_read_SSL_SESSION +and +.Fn PEM_write_SSL_SESSION +first appeared in SSLeay 0.5.2. +.Fn PEM_read_bio_SSL_SESSION and .Fn PEM_write_bio_SSL_SESSION -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CIPHER_get_name.3 b/lib/libssl/man/SSL_CIPHER_get_name.3 index d69590922c..37707566e4 100644 --- a/lib/libssl/man/SSL_CIPHER_get_name.3 +++ b/lib/libssl/man/SSL_CIPHER_get_name.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CIPHER_get_name.3,v 1.8 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_CIPHER_get_name.3,v 1.10 2018/04/25 13:51:34 schwarze Exp $ .\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -52,7 +52,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt SSL_CIPHER_GET_NAME 3 .Os .Sh NAME @@ -73,7 +73,7 @@ .Fn SSL_CIPHER_get_name "const SSL_CIPHER *cipher" .Ft int .Fn SSL_CIPHER_get_bits "const SSL_CIPHER *cipher" "int *alg_bits" -.Ft char * +.Ft const char * .Fn SSL_CIPHER_get_version "const SSL_CIPHER *cipher" .Ft int .Fn SSL_CIPHER_get_cipher_nid "const SSL_CIPHER *cipher" @@ -322,12 +322,14 @@ A complete list can be retrieved by invoking the following command: .Xr SSL_get_ciphers 3 , .Xr SSL_get_current_cipher 3 .Sh HISTORY +.Fn SSL_CIPHER_description +first appeared in SSLeay 0.8.0. .Fn SSL_CIPHER_get_name , .Fn SSL_CIPHER_get_bits , -.Fn SSL_CIPHER_get_version , and -.Fn SSL_CIPHER_description -appeared before SSLeay 0.8 and have been available since +.Fn SSL_CIPHER_get_version +first appeared in SSLeay 0.8.1. +These functions have been available since .Ox 2.4 . .Pp .Fn SSL_CIPHER_get_id diff --git a/lib/libssl/man/SSL_CTX_add_session.3 b/lib/libssl/man/SSL_CTX_add_session.3 index 285c7fbbba..443bdb542a 100644 --- a/lib/libssl/man/SSL_CTX_add_session.3 +++ b/lib/libssl/man/SSL_CTX_add_session.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_add_session.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_add_session.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL SSL_CTX_add_session.pod 1722496f Jun 8 15:18:38 2017 -0400 .\" .\" This file was written by Lutz Jaenicke and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_ADD_SESSION 3 .Os .Sh NAME @@ -128,5 +128,5 @@ The operation succeeded. .Fn SSL_CTX_add_session and .Fn SSL_CTX_remove_session -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_ctrl.3 b/lib/libssl/man/SSL_CTX_ctrl.3 index f5a28a4223..c91ddff374 100644 --- a/lib/libssl/man/SSL_CTX_ctrl.3 +++ b/lib/libssl/man/SSL_CTX_ctrl.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_ctrl.3,v 1.6 2018/03/22 16:07:53 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_ctrl.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_CTRL 3 .Os .Sh NAME @@ -112,7 +112,7 @@ parameter. .Fn SSL_CTX_ctrl and .Fn SSL_ctrl -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn SSL_CTX_callback_ctrl diff --git a/lib/libssl/man/SSL_CTX_flush_sessions.3 b/lib/libssl/man/SSL_CTX_flush_sessions.3 index b017b9d563..2ef781cb4a 100644 --- a/lib/libssl/man/SSL_CTX_flush_sessions.3 +++ b/lib/libssl/man/SSL_CTX_flush_sessions.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_flush_sessions.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_flush_sessions.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL SSL_CTX_flush_sessions.pod 1722496f Jun 8 15:18:38 2017 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_FLUSH_SESSIONS 3 .Os .Sh NAME @@ -96,5 +96,5 @@ is however called to synchronize with the external cache (see .Xr SSL_CTX_set_timeout 3 .Sh HISTORY .Fn SSL_CTX_flush_sessions -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_free.3 b/lib/libssl/man/SSL_CTX_free.3 index dec89699e0..47f247631b 100644 --- a/lib/libssl/man/SSL_CTX_free.3 +++ b/lib/libssl/man/SSL_CTX_free.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_free.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_free.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_FREE 3 .Os .Sh NAME @@ -97,5 +97,5 @@ prior to calling .Xr SSL_CTX_sess_set_get_cb 3 .Sh HISTORY .Fn SSL_CTX_free -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_get_verify_mode.3 b/lib/libssl/man/SSL_CTX_get_verify_mode.3 index bcfed50648..7c87775069 100644 --- a/lib/libssl/man/SSL_CTX_get_verify_mode.3 +++ b/lib/libssl/man/SSL_CTX_get_verify_mode.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_get_verify_mode.3,v 1.4 2018/03/21 17:58:58 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_get_verify_mode.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_GET_VERIFY_MODE 3 .Os .Sh NAME @@ -121,7 +121,7 @@ pointer is returned and the default callback will be used. .Fn SSL_get_verify_callback , and .Fn SSL_CTX_get_verify_callback -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn SSL_CTX_get_verify_depth diff --git a/lib/libssl/man/SSL_CTX_load_verify_locations.3 b/lib/libssl/man/SSL_CTX_load_verify_locations.3 index ab0374ecfc..373df2402e 100644 --- a/lib/libssl/man/SSL_CTX_load_verify_locations.3 +++ b/lib/libssl/man/SSL_CTX_load_verify_locations.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_load_verify_locations.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_load_verify_locations.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_LOAD_VERIFY_LOCATIONS 3 .Os .Sh NAME @@ -225,7 +225,7 @@ $ for c in *.pem; do .Fn SSL_CTX_load_verify_locations and .Fn SSL_CTX_set_default_verify_paths -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Sh CAVEATS If several CA certificates matching the name, key identifier, and serial diff --git a/lib/libssl/man/SSL_CTX_new.3 b/lib/libssl/man/SSL_CTX_new.3 index 78b64f0631..1d28fc847d 100644 --- a/lib/libssl/man/SSL_CTX_new.3 +++ b/lib/libssl/man/SSL_CTX_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_new.3,v 1.9 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_new.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 21cd6e00 Oct 21 14:40:15 2015 +0100 .\" selective merge up to: OpenSSL eb43101f Dec 9 18:07:09 2016 +0100 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_NEW 3 .Os .Sh NAME @@ -239,12 +239,13 @@ returns 1 for success or 0 for failure. .Xr SSL_CTX_set_options 3 , .Xr SSL_set_connect_state 3 .Sh HISTORY -.Fn SSL_CTX_new , +.Fn SSL_CTX_new +first appeared in SSLeay 0.5.1. .Fn SSLv23_method , .Fn SSLv23_server_method , and .Fn SSLv23_client_method -appeared before SSLeay 0.8. +first appeared in SSLeay 0.8.0. .Fn TLSv1_method , .Fn TLSv1_server_method , and diff --git a/lib/libssl/man/SSL_CTX_sess_number.3 b/lib/libssl/man/SSL_CTX_sess_number.3 index d4b5f8fa2c..4c0e0c3767 100644 --- a/lib/libssl/man/SSL_CTX_sess_number.3 +++ b/lib/libssl/man/SSL_CTX_sess_number.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_sess_number.3,v 1.7 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_sess_number.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL SSL_CTX_sess_number.pod 7bd27895 Mar 29 11:45:29 2017 +1000 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SESS_NUMBER 3 .Os .Sh NAME @@ -152,11 +152,12 @@ cache size was exceeded. .Fn SSL_CTX_sess_accept , .Fn SSL_CTX_sess_accept_good , .Fn SSL_CTX_sess_hits , -.Fn SSL_CTX_sess_cb_hits , .Fn SSL_CTX_sess_misses , and .Fn SSL_CTX_sess_timeouts -appeared before SSLeay 0.8. +first appeared in SSLeay 0.5.2. +.Fn SSL_CTX_sess_cb_hits +first appeared in SSLeay 0.6.0. .Fn SSL_CTX_sess_connect_renegotiate , .Fn SSL_CTX_sess_accept_renegotiate , and diff --git a/lib/libssl/man/SSL_CTX_sess_set_get_cb.3 b/lib/libssl/man/SSL_CTX_sess_set_get_cb.3 index e54b49bbcd..5b2b4ba9da 100644 --- a/lib/libssl/man/SSL_CTX_sess_set_get_cb.3 +++ b/lib/libssl/man/SSL_CTX_sess_set_get_cb.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_sess_set_get_cb.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_sess_set_get_cb.3,v 1.6 2018/04/25 14:07:57 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt SSL_CTX_SESS_SET_GET_CB 3 .Os .Sh NAME @@ -75,38 +75,38 @@ .Ft void .Fo SSL_CTX_sess_set_get_cb .Fa "SSL_CTX *ctx" -.Fa "SSL_SESSION (*get_session_cb)(SSL *, unsigned char *, int, int *)" +.Fa "SSL_SESSION (*get_session_cb)(SSL *, const unsigned char *, int, int *)" .Fc .Ft int .Fo "(*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))" -.Fa "struct ssl_st *ssl" +.Fa "SSL *ssl" .Fa "SSL_SESSION *sess" .Fc .Ft void .Fo "(*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))" -.Fa "struct ssl_ctx_st *ctx" +.Fa "SSL_CTX *ctx" .Fa "SSL_SESSION *sess" .Fc .Ft SSL_SESSION * .Fo "(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))" -.Fa "struct ssl_st *ssl" -.Fa "unsigned char *data" +.Fa "SSL *ssl" +.Fa "const unsigned char *data" .Fa "int len" .Fa "int *copy" .Fc .Ft int .Fo "(*new_session_cb)" -.Fa "struct ssl_st *ssl" +.Fa "SSL *ssl" .Fa "SSL_SESSION *sess" .Fc .Ft void .Fo "(*remove_session_cb)" -.Fa "struct ssl_ctx_st *ctx" +.Fa "SSL_CTX *ctx" .Fa "SSL_SESSION *sess" .Fc .Ft SSL_SESSION * .Fo "(*get_session_cb)" -.Fa "struct ssl_st *ssl" +.Fa "SSL *ssl" .Fa "unsigned char *data" .Fa "int len" .Fa "int *copy" @@ -206,5 +206,15 @@ not be explicitly freed with .Xr SSL_CTX_set_session_cache_mode 3 , .Xr SSL_SESSION_free 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +.Fn SSL_CTX_sess_set_new_cb , +.Fn SSL_CTX_sess_set_get_cb , +.Fn SSL_CTX_sess_get_new_cb , +and +.Fn SSL_CTX_sess_get_get_cb +first appeared in SSLeay 0.6.0. +.Fn SSL_CTX_sess_set_remove_cb +and +.Fn SSL_CTX_sess_get_remove_cb +first appeared in SSLeay 0.8.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_sessions.3 b/lib/libssl/man/SSL_CTX_sessions.3 index 3d5db2e68a..964d1a7346 100644 --- a/lib/libssl/man/SSL_CTX_sessions.3 +++ b/lib/libssl/man/SSL_CTX_sessions.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_sessions.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_sessions.3,v 1.5 2018/04/25 14:19:39 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt SSL_CTX_SESSIONS 3 .Os .Sh NAME @@ -56,7 +56,7 @@ .Nd access internal session cache .Sh SYNOPSIS .In openssl/ssl.h -.Ft struct lhash_st * +.Ft LHASH_OF(SSL_SESSION) * .Fn SSL_CTX_sessions "SSL_CTX *ctx" .Sh DESCRIPTION .Fn SSL_CTX_sessions @@ -82,5 +82,5 @@ family of functions. .Xr SSL_CTX_set_session_cache_mode 3 .Sh HISTORY .Fn SSL_CTX_sessions -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.2 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_cert_store.3 b/lib/libssl/man/SSL_CTX_set_cert_store.3 index 28a4df1d79..b23e3c4a12 100644 --- a/lib/libssl/man/SSL_CTX_set_cert_store.3 +++ b/lib/libssl/man/SSL_CTX_set_cert_store.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_cert_store.3,v 1.6 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_cert_store.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_CERT_STORE 3 .Os .Sh NAME @@ -126,5 +126,5 @@ returns the current setting. .Fn SSL_CTX_set_cert_store and .Fn SSL_CTX_get_cert_store -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.1 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3 b/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3 index 1f2188a6f2..e3ca5ff4ff 100644 --- a/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3 +++ b/lib/libssl/man/SSL_CTX_set_cert_verify_callback.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_cert_verify_callback.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_cert_verify_callback.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_CERT_VERIFY_CALLBACK 3 .Os .Sh NAME @@ -128,7 +128,7 @@ function set using .Xr SSL_get_verify_result 3 .Sh HISTORY .Fn SSL_CTX_set_cert_verify_callback -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.1 and has been available since .Ox 2.4 . .Pp Previous to OpenSSL 0.9.7, the diff --git a/lib/libssl/man/SSL_CTX_set_cipher_list.3 b/lib/libssl/man/SSL_CTX_set_cipher_list.3 index 75895ae2a8..a64826e578 100644 --- a/lib/libssl/man/SSL_CTX_set_cipher_list.3 +++ b/lib/libssl/man/SSL_CTX_set_cipher_list.3 @@ -1,7 +1,24 @@ -.\" $OpenBSD: SSL_CTX_set_cipher_list.3,v 1.5 2018/03/21 05:07:04 schwarze Exp $ -.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" $OpenBSD: SSL_CTX_set_cipher_list.3,v 1.7 2018/04/10 21:37:20 schwarze Exp $ +.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" -.\" This file was written by Lutz Jaenicke . +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2018 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Lutz Jaenicke . .\" Copyright (c) 2000, 2001, 2013 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -48,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 10 2018 $ .Dt SSL_CTX_SET_CIPHER_LIST 3 .Os .Sh NAME @@ -58,43 +75,268 @@ .Sh SYNOPSIS .In openssl/ssl.h .Ft int -.Fn SSL_CTX_set_cipher_list "SSL_CTX *ctx" "const char *str" +.Fn SSL_CTX_set_cipher_list "SSL_CTX *ctx" "const char *control" .Ft int -.Fn SSL_set_cipher_list "SSL *ssl" "const char *str" +.Fn SSL_set_cipher_list "SSL *ssl" "const char *control" .Sh DESCRIPTION .Fn SSL_CTX_set_cipher_list -sets the list of available ciphers for +sets the list of available cipher suites for .Fa ctx -using the control string -.Fa str . -The format of the string is described -in -.Xr openssl 1 . -The list of ciphers is inherited by all +using the +.Fa control +string. +The list of cipher suites is inherited by all .Fa ssl objects created from .Fa ctx . .Pp .Fn SSL_set_cipher_list -sets the list of ciphers only for +sets the list of cipher suites only for .Fa ssl . .Pp -The control string -.Fa str -should be universally usable and not depend on details of the library -configuration (ciphers compiled in). -Thus no syntax checking takes place. -Items that are not recognized, because the corresponding ciphers are not -compiled in or because they are mistyped, are simply ignored. -Failure is only flagged if no ciphers could be collected at all. +The control string consists of one or more control words +separated by colon characters +.Pq Ql \&: . +Space +.Pq Ql \ \& , +semicolon +.Pq Ql \&; , +and comma +.Pq Ql \&, +characters can also be used as separators. +Each control words selects a set of cipher suites +and can take one of the following optional prefix characters: +.Bl -tag -width Ds +.It \&No prefix: +Those of the selected cipher suites that have not been made available +yet are added to the end of the list of available cipher suites, +preserving their order. +.It Prefixed minus sign Pq Ql \- : +Those of the selected cipher suites that have been made available +earlier are moved back from the list of available cipher suites to +the beginning of the list of unavailable cipher suites, +also preserving their order. +.It Prefixed plus sign Pq Ql + : +Those of the selected cipher suites have been made available earlier +are moved to end of the list of available cipher suites, reducing +their priority, but preserving the order among themselves. +.It Prefixed exclamation mark Pq Ql \&! : +The selected cipher suites are permanently deleted, no matter whether +they had earlier been made available or not, and can no longer +be added or re-added by later words. +.El +.Pp +The following special words can only be used without a prefix: +.Bl -tag -width Ds +.It Cm DEFAULT +An alias for +.Sm off +.Cm ALL No :! Cm aNULL No :! Cm eNULL . +.Sm on +It can only be used as the first word. +.It Cm @STRENGTH +Sort the list by decreasing encryption strength, +preserving the order of cipher suites that have the same strength. +It is usally given as the last word. +.El +.Pp +The following words can be used to select groups of cipher suites, +with or without a prefix character. +If two or more of these words are joined with plus signs +.Pq Ql + +to form a longer word, only the intersection of the specified sets +is selected. +.Bl -tag -width Ds +.It Cm ADH +Cipher suites using ephemeral DH for key exchange +without doing any server authentication. +Equivalent to +.Cm kEDH Ns + Ns Cm aNULL . +.It Cm aDSS +Cipher suites using DSS server authentication. +LibreSSL does not provide any such cipher suites. +.It Cm AEAD +Cipher suites using Authenticated Encryption with Additional Data. +.It Cm AECDH +Cipher suites using ephemeral ECDH for key exchange +without doing any server authentication. +Equivalent to +.Cm kEECDH Ns + Ns Cm aNULL . +.It Cm aECDSA +Cipher suites using ECDSA server authentication. +.It Cm AES +Cipher suites using AES or AESGCM for symmetric encryption. +.It Cm AES128 +Cipher suites using AES(128) or AESGCM(128) for symmetric encryption. +.It Cm AES256 +Cipher suites using AES(256) or AESGCM(256) for symmetric encryption. +.It Cm AESGCM +Cipher suites using AESGCM for symmetric encryption. +.It Cm aGOST +An alias for +.Cm aGOST01 . +.It Cm aGOST01 +Cipher suites using GOST R 34.10-2001 server authentication. +.It Cm ALL +All cipher suites except those selected by +.Cm eNULL . +.It Cm aNULL +Cipher suites that don't do any server authentication. +Not enabled by +.Cm DEFAULT . +Beware of man-in-the-middle attacks. +.It Cm aRSA +Cipher suites using RSA server authentication. +.It Cm CAMELLIA +Cipher suites using Camellia for symmetric encryption. +.It Cm CAMELLIA128 +Cipher suites using Camellia(128) for symmetric encryption. +.It Cm CAMELLIA256 +Cipher suites using Camellia(256) for symmetric encryption. +.It Cm CHACHA20 +Cipher suites using ChaCha20-Poly1305 for symmetric encryption. +.It Cm COMPLEMENTOFALL +Cipher suites that are not included in +.Cm ALL . +Currently an alias for +.Cm eNULL . +.It Cm COMPLEMENTOFDEFAULT +Cipher suites that are included in +.Cm ALL , +but not included in +.Cm DEFAULT . +Currently similar to +.Cm aNULL Ns :! Ns Cm eNULL +except for the order of the cipher suites which are +.Em not +selected. +.It Cm DES +Cipher suites using single DES for symmetric encryption. +.It Cm 3DES +Cipher suites using triple DES for symmetric encryption. +.It Cm DH +An alias for +.Cm kEDH . +.It Cm DHE +Cipher suites using ephemeral DH for key exchange, +but excluding those that don't do any server authentication. +Similar to +.Cm kEDH Ns :! Ns Cm aNULL +except for the order of the cipher suites which are +.Em not +selected. +.It Cm DSS +An alias for +.Cm aDSS . +.It Cm ECDH +An alias for +.Cm kEECHD . +.It Cm ECDHE +Cipher suites using ephemeral ECDH for key exchange, +but excluding those that don't do any server authentication. +Similar to +.Cm kEECDH Ns :! Ns Cm aNULL +except for the order of the cipher suites which are +.Em not +selected. +.It Cm ECDSA +An alias for +.Cm aECDSA . +.It Cm EDH +An alias for +.Cm DHE . +.It Cm EECHD +An alias for +.Cm ECDHE . +.It Cm eNULL +Cipher suites that do not use any encryption. +Not enabled by +.Cm DEFAULT , +and not even included in +.Cm ALL . +.It Cm GOST89MAC +Cipher suites using GOST 28147-89 for message authentication +instead of HMAC. +.It Cm GOST94 +Cipher suites using HMAC based on GOST R 34.11-94 +for message authentication. +.It Cm HIGH +Cipher suites of high strength. +Currently, these are cipher suites using +.Cm CHACHA20 , +.Cm AES , +.Cm CAMELLIA , +or GOST-28178-89-CNT symmetric encryption. +.It Cm IDEA +Cipher suites using IDEA for symmetric encryption. +LibreSSL does not provide any such cipher suites. +.It Cm kEDH +Cipher suites using ephemeral DH for key exchange. +.It Cm kEECDH +Cipher suites using ephemeral ECDH for key exchange. +.It Cm kGOST +Cipher suites using VKO 34.10 key exchange, specified in RFC 4357. +.It Cm kRSA +Cipher suites using RSA key exchange. +.It Cm LOW +Cipher suites of low strength. +Currently, these are cipher suites using +.Cm DES +or +.Cm RC4 +symmetric encryption. +.It Cm MD5 +Cipher suites using MD5 for message authentication. +.It Cm MEDIUM +Cipher suites of medium strength. +Currently, these are cipher suites using +.Cm 3DES +symmetric encryption. +.It Cm NULL +An alias for +.Cm eNULL . +.It Cm RC4 +Cipher suites using RC4 for symmetric encryption. +.It Cm RSA +Cipher suites using RSA for both key exchange and server authentication. +Equivalent to +.Cm kRSA Ns + Ns Cm aRSA . +.It Cm SHA +An alias for +.Cm SHA1 . +.It Cm SHA1 +Cipher suites using SHA1 for message authentication. +.It Cm SHA256 +Cipher suites using SHA256 for message authentication. +.It Cm SHA384 +Cipher suites using SHA384 for message authentication. +.It Cm SSLv3 +An alias for +.Cm TLSv1 . +.It Cm STREEBOG256 +Cipher suites using STREEBOG256 for message authentication. +.It Cm TLSv1 +Cipher suites usable with any TLS protocol. +.It Cm TLSv1.2 +Cipher suites for the TLSv1.2 protocol. +.El +.Pp +The full words returned by the +.Xr openssl 1 +.Cm ciphers +command can be used to select individual cipher suites. +.Pp +Unknown words are silently ignored, selecting no cipher suites. +Failure is only flagged if the +.Fa control +string contains invalid bytes +or if no matching cipher suites are available at all. .Pp -It should be noted that inclusion of a cipher to be used into the list is a -necessary condition. -On the client side, the inclusion into the list is also sufficient. -On the server side, additional restrictions apply. -All ciphers have additional requirements. +On the client side, including a cipher suite into the list of +available cipher suites is sufficient for using it. +On the server side, all cipher suites have additional requirements. ADH ciphers don't need a certificate, but DH-parameters must have been set. -All other ciphers need a corresponding certificate and key. +All other cipher suites need a corresponding certificate and key. .Pp A RSA cipher can only be chosen when a RSA certificate is available. RSA ciphers using DHE need a certificate and key and additional DH-parameters @@ -105,7 +347,8 @@ A DSA cipher can only be chosen when a DSA certificate is available. DSA ciphers always use DH key exchange and therefore need DH-parameters (see .Xr SSL_CTX_set_tmp_dh_callback 3 ) . .Pp -When these conditions are not met for any cipher in the list (for example, a +When these conditions are not met +for any cipher suite in the list (for example, a client only supports export RSA ciphers with an asymmetric key length of 512 bits and the server is not configured to use temporary RSA keys), the .Dq no shared cipher @@ -115,7 +358,7 @@ error is generated and the handshake will fail. .Fn SSL_CTX_set_cipher_list and .Fn SSL_set_cipher_list -return 1 if any cipher could be selected and 0 on complete failure. +return 1 if any cipher suite could be selected and 0 on complete failure. .Sh SEE ALSO .Xr ssl 3 , .Xr SSL_CTX_set1_groups 3 , @@ -126,5 +369,5 @@ return 1 if any cipher could be selected and 0 on complete failure. .Fn SSL_CTX_set_cipher_list and .Fn SSL_set_cipher_list -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.2 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_client_CA_list.3 b/lib/libssl/man/SSL_CTX_set_client_CA_list.3 index 7f40e15b0d..274a673b0f 100644 --- a/lib/libssl/man/SSL_CTX_set_client_CA_list.3 +++ b/lib/libssl/man/SSL_CTX_set_client_CA_list.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_client_CA_list.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_client_CA_list.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_CLIENT_CA_LIST 3 .Os .Sh NAME @@ -184,5 +184,5 @@ SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(CAfile)); .Fn SSL_CTX_add_client_CA , and .Fn SSL_add_client_CA -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_client_cert_cb.3 b/lib/libssl/man/SSL_CTX_set_client_cert_cb.3 index f1f76af8c9..a2433b5e92 100644 --- a/lib/libssl/man/SSL_CTX_set_client_cert_cb.3 +++ b/lib/libssl/man/SSL_CTX_set_client_cert_cb.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_client_cert_cb.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_client_cert_cb.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_CLIENT_CERT_CB 3 .Os .Sh NAME @@ -150,7 +150,7 @@ certificate. .Fn SSL_CTX_set_client_cert_cb and .Fn SSL_CTX_get_client_cert_cb -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.6 and have been available since .Ox 2.4 . .Sh BUGS The diff --git a/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 b/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 index ff0773adb0..7ab9633f5c 100644 --- a/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 +++ b/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 @@ -1,8 +1,10 @@ -.\" $OpenBSD: SSL_CTX_set_default_passwd_cb.3,v 1.5 2018/03/21 21:20:26 schwarze Exp $ -.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 +.\" $OpenBSD: SSL_CTX_set_default_passwd_cb.3,v 1.7 2018/04/02 02:06:14 schwarze Exp $ +.\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 +.\" selective merge up to: OpenSSL 2947af32 Nov 19 00:10:05 2016 +0100 .\" -.\" This file was written by Lutz Jaenicke . -.\" Copyright (c) 2000, 2001 The OpenSSL Project. All rights reserved. +.\" This file was written by Lutz Jaenicke +.\" and Christian Heimes . +.\" Copyright (c) 2000, 2001, 2016 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -48,20 +50,26 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 2 2018 $ .Dt SSL_CTX_SET_DEFAULT_PASSWD_CB 3 .Os .Sh NAME .Nm SSL_CTX_set_default_passwd_cb , .Nm SSL_CTX_set_default_passwd_cb_userdata , +.Nm SSL_CTX_get_default_passwd_cb , +.Nm SSL_CTX_get_default_passwd_cb_userdata , .Nm pem_password_cb -.Nd set passwd callback for encrypted PEM file handling +.Nd set or get passwd callback for encrypted PEM file handling .Sh SYNOPSIS .In openssl/ssl.h .Ft void .Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb" .Ft void .Fn SSL_CTX_set_default_passwd_cb_userdata "SSL_CTX *ctx" "void *u" +.Ft pem_password_cb * +.Fn SSL_CTX_get_default_passwd_cb "SSL_CTX *ctx" +.Ft void * +.Fn SSL_CTX_get_default_passwd_cb_userdata "SSL_CTX *ctx" .In openssl/pem.h .Ft typedef int .Fn pem_password_cb "char *buf" "int size" "int rwflag" "void *userdata" @@ -114,6 +122,20 @@ comparison in order to catch typos which would make decryption impossible. .Pp Other items in PEM formatting (certificates) can also be encrypted; it is however atypical, as certificate information is considered public. +.Sh RETURN VALUES +.Fn SSL_CTX_get_default_passwd_cb +returns a function pointer to the password callback currently set in +.Fa ctx , +or +.Dv NULL +if none is set. +.Pp +.Fn SSL_CTX_get_default_passwd_cb_userdata +returns a pointer to the userdata currently set in +.Fa ctx , +or +.Dv NULL +if none is set. .Sh EXAMPLES The following example returns the password provided as .Fa userdata @@ -135,9 +157,15 @@ int pem_passwd_cb(char *buf, int size, int rwflag, void *password) .Xr SSL_CTX_use_certificate 3 .Sh HISTORY .Fn SSL_CTX_set_default_passwd_cb -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.2 and has been available since .Ox 2.4 . .Pp .Fn SSL_CTX_set_default_passwd_cb_userdata first appeared in OpenSSL 0.9.4 and has been available since .Ox 2.6 . +.Pp +.Fn SSL_CTX_get_default_passwd_cb +and +.Fn SSL_CTX_get_default_passwd_cb_userdata +first appeared in OpenSSL 1.1.0 and have been available since +.Ox 6.3 . diff --git a/lib/libssl/man/SSL_CTX_set_info_callback.3 b/lib/libssl/man/SSL_CTX_set_info_callback.3 index 1bb248135f..76eb8bee61 100644 --- a/lib/libssl/man/SSL_CTX_set_info_callback.3 +++ b/lib/libssl/man/SSL_CTX_set_info_callback.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_info_callback.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_info_callback.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_INFO_CALLBACK 3 .Os .Sh NAME @@ -228,5 +228,6 @@ apps_ssl_info_callback(SSL *s, int where, int ret) .Xr SSL_alert_type_string 3 , .Xr SSL_state_string 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +These functions first appeared in SSLeay 0.6.0 +and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_options.3 b/lib/libssl/man/SSL_CTX_set_options.3 index 090a767874..4535eee573 100644 --- a/lib/libssl/man/SSL_CTX_set_options.3 +++ b/lib/libssl/man/SSL_CTX_set_options.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_options.3,v 1.11 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_options.3,v 1.12 2018/04/11 18:05:49 schwarze Exp $ .\" full merge up to: OpenSSL 7946ab33 Dec 6 17:56:41 2015 +0100 .\" selective merge up to: OpenSSL edb79c3a Mar 29 10:07:14 2017 +1000 .\" @@ -52,7 +52,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: April 11 2018 $ .Dt SSL_CTX_SET_OPTIONS 3 .Os .Sh NAME @@ -209,17 +209,6 @@ Do not use the TLSv1.2 protocol. Deprecated; use .Xr SSL_CTX_set_max_proto_version 3 instead. -.It Dv SSL_OP_TLS_ROLLBACK_BUG -Disable version rollback attack detection. -.Pp -During the client key exchange, the client must send the same information -about acceptable SSL/TLS protocol levels as during the first hello. -Some clients violate this rule by adapting to the server's answer. -(Example: the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, -the server only understands up to SSLv3. -In this case the client must still use the same SSLv3.1=TLSv1 announcement. -Some clients step down to SSLv3 with respect to the server's answer and violate -the version rollback protection.) .El .Pp The following options used to be supported at some point in the past @@ -244,6 +233,7 @@ and no longer have any effect: .Dv SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG , .Dv SSL_OP_TLS_BLOCK_PADDING_BUG , .Dv SSL_OP_TLS_D5_BUG , +.Dv SSL_OP_TLS_ROLLBACK_BUG , .Dv SSL_OP_TLSEXT_PADDING . .Sh SECURE RENEGOTIATION OpenSSL 0.9.8m and later always attempts to use secure renegotiation as diff --git a/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3 b/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3 index 6856d364ce..feea399bca 100644 --- a/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3 +++ b/lib/libssl/man/SSL_CTX_set_quiet_shutdown.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_quiet_shutdown.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_quiet_shutdown.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_QUIET_SHUTDOWN 3 .Os .Sh NAME @@ -161,5 +161,6 @@ return the current setting. .Xr SSL_set_shutdown 3 , .Xr SSL_shutdown 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +These functions first appeared in SSLeay 0.8.1 +and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_read_ahead.3 b/lib/libssl/man/SSL_CTX_set_read_ahead.3 index 8948d47e49..eae76eb472 100644 --- a/lib/libssl/man/SSL_CTX_set_read_ahead.3 +++ b/lib/libssl/man/SSL_CTX_set_read_ahead.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_read_ahead.3,v 1.3 2018/03/21 16:12:41 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_read_ahead.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Matt Caswell . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_READ_AHEAD 3 .Os .Sh NAME @@ -129,7 +129,7 @@ except that the return values are undefined for DTLS. .Fn SSL_set_read_ahead and .Fn SSL_get_read_ahead -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier and have been available since .Ox 2.4 . .Pp .Fn SSL_CTX_set_read_ahead , diff --git a/lib/libssl/man/SSL_CTX_set_session_cache_mode.3 b/lib/libssl/man/SSL_CTX_set_session_cache_mode.3 index 9e8e8500e8..0f8ee90b0a 100644 --- a/lib/libssl/man/SSL_CTX_set_session_cache_mode.3 +++ b/lib/libssl/man/SSL_CTX_set_session_cache_mode.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_session_cache_mode.3,v 1.5 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_session_cache_mode.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 67adf0a7 Dec 25 19:58:38 2016 +0100 .\" .\" This file was written by Lutz Jaenicke and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_SESSION_CACHE_MODE 3 .Os .Sh NAME @@ -188,7 +188,7 @@ returns the currently set cache mode. .Fn SSL_CTX_set_session_cache_mode and .Fn SSL_CTX_get_session_cache_mode -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.1 and have been available since .Ox 2.4 . .Pp .Dv SSL_SESS_CACHE_NO_INTERNAL_STORE diff --git a/lib/libssl/man/SSL_CTX_set_ssl_version.3 b/lib/libssl/man/SSL_CTX_set_ssl_version.3 index 6633ccd177..eb29af620c 100644 --- a/lib/libssl/man/SSL_CTX_set_ssl_version.3 +++ b/lib/libssl/man/SSL_CTX_set_ssl_version.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_ssl_version.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_ssl_version.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_SSL_VERSION 3 .Os .Sh NAME @@ -131,5 +131,5 @@ The operation succeeded. .Fn SSL_set_ssl_method , and .Fn SSL_get_ssl_method -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_timeout.3 b/lib/libssl/man/SSL_CTX_set_timeout.3 index 3ccd3ebbd9..ab99e2016e 100644 --- a/lib/libssl/man/SSL_CTX_set_timeout.3 +++ b/lib/libssl/man/SSL_CTX_set_timeout.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_timeout.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_timeout.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_TIMEOUT 3 .Os .Sh NAME @@ -114,5 +114,5 @@ returns the currently set timeout value. .Fn SSL_CTX_set_timeout and .Fn SSL_CTX_get_timeout -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.1 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3 b/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3 index a901b2515e..23786f7663 100644 --- a/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3 +++ b/lib/libssl/man/SSL_CTX_set_tlsext_use_srtp.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: SSL_CTX_set_tlsext_use_srtp.3,v 1.2 2018/03/24 00:55:37 schwarze Exp $ -.\" full merge up to: OpenSSL 3733ce61 Aug 21 08:44:14 2017 +0100 +.\" $OpenBSD: SSL_CTX_set_tlsext_use_srtp.3,v 1.3 2018/03/30 19:31:11 schwarze Exp $ +.\" full merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000 .\" .\" This file was written by Matt Caswell . .\" Copyright (c) 2017 The OpenSSL Project. All rights reserved. @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: March 30 2018 $ .Dt SSL_CTX_SET_TLSEXT_USE_SRTP 3 .Os .Sh NAME @@ -143,7 +143,7 @@ if no SRTP protection profile was negotiated. The memory returned from this function should not be freed by the caller. .Pp -If an SRTP protection profile has been sucessfully negotiated, +If an SRTP protection profile has been successfully negotiated, then the SRTP keying material (on both the client and server) should be obtained by calling .Xr SSL_export_keying_material 3 diff --git a/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 b/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 index 2456dd500d..b4f54eab3d 100644 --- a/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 +++ b/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.6 2018/03/21 16:12:41 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_TMP_DH_CALLBACK 3 .Os .Sh NAME @@ -225,7 +225,7 @@ if (SSL_CTX_set_tmp_dh(ctx, dh_2048) != 1) { .Fn SSL_CTX_set_tmp_dh_callback and .Fn SSL_CTX_set_tmp_dh -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn SSL_set_tmp_dh_callback diff --git a/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3 b/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3 index ab32d41d97..0181634fe3 100644 --- a/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3 +++ b/lib/libssl/man/SSL_CTX_set_tmp_rsa_callback.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_tmp_rsa_callback.3,v 1.7 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_tmp_rsa_callback.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 0b30fc90 Dec 19 15:23:05 2013 -0500 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_TMP_RSA_CALLBACK 3 .Os .Sh NAME @@ -103,7 +103,7 @@ These functions always return 0, indicating failure. .Fn SSL_CTX_set_tmp_rsa , and .Fn SSL_CTX_need_tmp_RSA -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . .Pp .Fn SSL_set_tmp_rsa_callback diff --git a/lib/libssl/man/SSL_CTX_set_verify.3 b/lib/libssl/man/SSL_CTX_set_verify.3 index 4c3b5dd749..40a09de902 100644 --- a/lib/libssl/man/SSL_CTX_set_verify.3 +++ b/lib/libssl/man/SSL_CTX_set_verify.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_verify.3,v 1.6 2018/03/21 17:58:58 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_verify.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" selective merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CTX_SET_VERIFY 3 .Os .Sh NAME @@ -445,10 +445,11 @@ if (peer = SSL_get_peer_certificate(ssl)) { .Xr SSL_get_verify_result 3 , .Xr SSL_new 3 .Sh HISTORY -.Fn SSL_CTX_set_verify -and .Fn SSL_set_verify -appeared before SSLeay 0.8 and have been available since +appeared in SSLeay 0.4 or earlier. +.Fn SSL_CTX_set_verify +first appeared in SSLeay 0.6.4. +Both functions have been available since .Ox 2.4 . .Pp .Fn SSL_CTX_set_verify_depth diff --git a/lib/libssl/man/SSL_CTX_use_certificate.3 b/lib/libssl/man/SSL_CTX_use_certificate.3 index f51b5d960f..b1b7df5a9a 100644 --- a/lib/libssl/man/SSL_CTX_use_certificate.3 +++ b/lib/libssl/man/SSL_CTX_use_certificate.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_use_certificate.3,v 1.7 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_use_certificate.3,v 1.9 2018/04/25 13:51:34 schwarze Exp $ .\" OpenSSL e248596b Apr 8 22:49:57 2005 +0000 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt SSL_CTX_USE_CERTIFICATE 3 .Os .Sh NAME @@ -117,7 +117,7 @@ .Ft int .Fn SSL_use_RSAPrivateKey "SSL *ssl" "RSA *rsa" .Ft int -.Fn SSL_use_RSAPrivateKey_ASN1 "SSL *ssl" "unsigned char *d" "long len" +.Fn SSL_use_RSAPrivateKey_ASN1 "SSL *ssl" "const unsigned char *d" "long len" .Ft int .Fn SSL_use_RSAPrivateKey_file "SSL *ssl" "const char *file" "int type" .Ft int @@ -392,28 +392,37 @@ Otherwise check out the error stack to find out the reason. .Xr SSL_new 3 , .Xr X509_check_private_key 3 .Sh HISTORY +.Fn SSL_use_certificate , +.Fn SSL_use_certificate_file , +.Fn SSL_use_RSAPrivateKey , +and +.Fn SSL_use_RSAPrivateKey_file +appeared in SSLeay 0.4 or earlier. +.Fn SSL_use_certificate_ASN1 +and +.Fn SSL_use_RSAPrivateKey_ASN1 +first appeared in SSLeay 0.5.1. +.Fn SSL_use_PrivateKey_file , +.Fn SSL_use_PrivateKey_ASN1 , +and +.Fn SSL_use_PrivateKey +first appeared in SSLeay 0.6.0. .Fn SSL_CTX_use_certificate , .Fn SSL_CTX_use_certificate_ASN1 , .Fn SSL_CTX_use_certificate_file , -.Fn SSL_use_certificate , -.Fn SSL_use_certificate_ASN1 , -.Fn SSL_use_certificate_file , .Fn SSL_CTX_use_PrivateKey , .Fn SSL_CTX_use_PrivateKey_ASN1 , .Fn SSL_CTX_use_PrivateKey_file , .Fn SSL_CTX_use_RSAPrivateKey , .Fn SSL_CTX_use_RSAPrivateKey_ASN1 , -.Fn SSL_CTX_use_RSAPrivateKey_file , -.Fn SSL_use_PrivateKey_file , -.Fn SSL_use_PrivateKey_ASN1 , -.Fn SSL_use_PrivateKey , -.Fn SSL_use_RSAPrivateKey , -.Fn SSL_use_RSAPrivateKey_ASN1 , -.Fn SSL_use_RSAPrivateKey_file , -.Fn SSL_CTX_check_private_key , +and +.Fn SSL_CTX_use_RSAPrivateKey_file +first appeared in SSLeay 0.6.1. +.Fn SSL_CTX_check_private_key and .Fn SSL_check_private_key -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.5. +All these functions have been available since .Ox 2.4 . .Pp .Fn SSL_CTX_use_certificate_chain_file diff --git a/lib/libssl/man/SSL_SESSION_free.3 b/lib/libssl/man/SSL_SESSION_free.3 index 1a4b8af456..14c6b3c43f 100644 --- a/lib/libssl/man/SSL_SESSION_free.3 +++ b/lib/libssl/man/SSL_SESSION_free.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_SESSION_free.3,v 1.5 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_SESSION_free.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL b31db505 Mar 24 16:01:50 2017 +0000 .\" .\" This file was written by Lutz Jaenicke @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SESSION_FREE 3 .Os .Sh NAME @@ -139,7 +139,7 @@ returns 1 on success or 0 on error. .Xr SSL_SESSION_new 3 .Sh HISTORY .Fn SSL_SESSION_free -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.2 and has been available since .Ox 2.4 . .Pp .Fn SSL_SESSION_up_ref diff --git a/lib/libssl/man/SSL_SESSION_get_time.3 b/lib/libssl/man/SSL_SESSION_get_time.3 index c15ba3dfbb..fe6f0858ba 100644 --- a/lib/libssl/man/SSL_SESSION_get_time.3 +++ b/lib/libssl/man/SSL_SESSION_get_time.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_SESSION_get_time.3,v 1.6 2018/03/21 08:06:34 schwarze Exp $ +.\" $OpenBSD: SSL_SESSION_get_time.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SESSION_GET_TIME 3 .Os .Sh NAME @@ -149,11 +149,12 @@ pointer for the session .Xr SSL_SESSION_new 3 .Sh HISTORY .Fn SSL_get_time , -.Fn SSL_set_time , .Fn SSL_get_timeout , and .Fn SSL_set_timeout -appeared before SSLeay 0.8. +appeared in SSLeay 0.4 or earlier. +.Fn SSL_set_time +first appeared in SSLeay 0.5.2. .Fn SSL_SESSION_get_time , .Fn SSL_SESSION_set_time , .Fn SSL_SESSION_get_timeout , diff --git a/lib/libssl/man/SSL_SESSION_new.3 b/lib/libssl/man/SSL_SESSION_new.3 index 98e22d4896..ca26921429 100644 --- a/lib/libssl/man/SSL_SESSION_new.3 +++ b/lib/libssl/man/SSL_SESSION_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_SESSION_new.3,v 1.5 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_SESSION_new.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SESSION_NEW 3 .Os .Sh NAME @@ -72,5 +72,5 @@ returns .Xr SSL_set_session 3 .Sh HISTORY .Fn SSL_SESSION_new -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.2 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_SESSION_print.3 b/lib/libssl/man/SSL_SESSION_print.3 index d842437434..f9f2281469 100644 --- a/lib/libssl/man/SSL_SESSION_print.3 +++ b/lib/libssl/man/SSL_SESSION_print.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_SESSION_print.3,v 1.2 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_SESSION_print.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SESSION_PRINT 3 .Os .Sh NAME @@ -66,7 +66,8 @@ In some cases, the reason for failure can be determined with .Xr SSL_SESSION_new 3 .Sh HISTORY .Fn SSL_SESSION_print -and +first appeared in SSLeay 0.5.2. .Fn SSL_SESSION_print_fp -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0. +Both functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_accept.3 b/lib/libssl/man/SSL_accept.3 index 3a550369e2..4d36e536bc 100644 --- a/lib/libssl/man/SSL_accept.3 +++ b/lib/libssl/man/SSL_accept.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_accept.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_accept.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_ACCEPT 3 .Os .Sh NAME @@ -151,5 +151,5 @@ to find out the reason. .Xr SSL_shutdown 3 .Sh HISTORY .Fn SSL_accept -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_alert_type_string.3 b/lib/libssl/man/SSL_alert_type_string.3 index 4db6b67170..79cbdaa988 100644 --- a/lib/libssl/man/SSL_alert_type_string.3 +++ b/lib/libssl/man/SSL_alert_type_string.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_alert_type_string.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_alert_type_string.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_ALERT_TYPE_STRING 3 .Os .Sh NAME @@ -239,5 +239,6 @@ does not contain a correct alert message. .Xr ssl 3 , .Xr SSL_CTX_set_info_callback 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +These functions first appeared in SSLeay 0.8.0 +and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_clear.3 b/lib/libssl/man/SSL_clear.3 index 43faa404ba..1f2f0a5e52 100644 --- a/lib/libssl/man/SSL_clear.3 +++ b/lib/libssl/man/SSL_clear.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_clear.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_clear.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CLEAR 3 .Os .Sh NAME @@ -121,7 +121,7 @@ operation was successful. .Xr SSL_shutdown 3 .Sh HISTORY .Fn SSL_clear -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.4.5b and has been available since .Ox 2.4 . .Sh CAVEATS .Fn SSL_clear diff --git a/lib/libssl/man/SSL_connect.3 b/lib/libssl/man/SSL_connect.3 index 4529afba13..d5b962a480 100644 --- a/lib/libssl/man/SSL_connect.3 +++ b/lib/libssl/man/SSL_connect.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_connect.3,v 1.5 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_connect.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_CONNECT 3 .Os .Sh NAME @@ -150,5 +150,5 @@ to find out the reason. .Xr SSL_shutdown 3 .Sh HISTORY .Fn SSL_connect -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_copy_session_id.3 b/lib/libssl/man/SSL_copy_session_id.3 index d6e25a586a..65483799d4 100644 --- a/lib/libssl/man/SSL_copy_session_id.3 +++ b/lib/libssl/man/SSL_copy_session_id.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_copy_session_id.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_copy_session_id.3,v 1.6 2018/08/24 21:29:51 jmc Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: August 24 2018 $ .Dt SSL_COPY_SESSION_ID 3 .Os .Sh NAME @@ -22,7 +22,7 @@ .Nd copy session details between SSL objects .Sh SYNOPSIS .In openssl/ssl.h -.Ft void +.Ft int .Fo SSL_copy_session_id .Fa "SSL *to" .Fa "const SSL *from" @@ -55,6 +55,9 @@ This function is used internally by .Xr SSL_dup 3 and by .Xr BIO_ssl_copy_session_id 3 . +.Sh RETURN VALUES +.Fn SSL_copy_session_id +returns 1 on success and 0 on error. .Sh SEE ALSO .Xr BIO_ssl_copy_session_id 3 , .Xr SSL_dup 3 , @@ -65,15 +68,11 @@ and by .Xr SSL_set_session_id_context 3 .Sh HISTORY .Fn SSL_copy_session_id -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . .Sh BUGS Failures of -.Xr SSL_set_session 3 , -.Xr SSL_set_session_id_context 3 , -.Xr CRYPTO_add 3 , -and reinitialization of protocol-specific data are silently ignored -and may leave +.Xr CRYPTO_add 3 +are silently ignored and may leave .Fa to in an invalid or inconsistent state. -An improved version reporting failure is available in OpenSSL 1.1.0. diff --git a/lib/libssl/man/SSL_do_handshake.3 b/lib/libssl/man/SSL_do_handshake.3 index 88d4677fc8..e9327b4229 100644 --- a/lib/libssl/man/SSL_do_handshake.3 +++ b/lib/libssl/man/SSL_do_handshake.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_do_handshake.3,v 1.5 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_do_handshake.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Martin Sjoegren . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_DO_HANDSHAKE 3 .Os .Sh NAME @@ -148,5 +148,5 @@ to find out the reason. .Xr SSL_set_connect_state 3 .Sh HISTORY .Fn SSL_do_handshake -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_dup.3 b/lib/libssl/man/SSL_dup.3 index 448979360f..a752af13e3 100644 --- a/lib/libssl/man/SSL_dup.3 +++ b/lib/libssl/man/SSL_dup.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_dup.3,v 1.2 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_dup.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_DUP 3 .Os .Sh NAME @@ -56,5 +56,5 @@ on failure. .Xr SSL_new 3 .Sh HISTORY .Fn SSL_dup -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_dup_CA_list.3 b/lib/libssl/man/SSL_dup_CA_list.3 index 92787a32f4..2c3250844f 100644 --- a/lib/libssl/man/SSL_dup_CA_list.3 +++ b/lib/libssl/man/SSL_dup_CA_list.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_dup_CA_list.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_dup_CA_list.3,v 1.5 2018/04/25 13:51:34 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt SSL_DUP_CA_LIST 3 .Os .Sh NAME @@ -24,7 +24,7 @@ .Sh SYNOPSIS .Ft STACK_OF(X509_NAME) * .Fo SSL_dup_CA_list -.Fa "STACK_OF(X509_NAME) *sk" +.Fa "const STACK_OF(X509_NAME) *sk" .Fc .Sh DESCRIPTION .Fn SSL_dup_CA_list @@ -49,5 +49,5 @@ on failure. .Xr X509_NAME_new 3 .Sh HISTORY .Fn SSL_dup_CA_list -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_free.3 b/lib/libssl/man/SSL_free.3 index a39078e474..38694a0625 100644 --- a/lib/libssl/man/SSL_free.3 +++ b/lib/libssl/man/SSL_free.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_free.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_free.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_FREE 3 .Os .Sh NAME @@ -114,5 +114,5 @@ does not provide diagnostic information. .Xr SSL_shutdown 3 .Sh HISTORY .Fn SSL_free -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_SSL_CTX.3 b/lib/libssl/man/SSL_get_SSL_CTX.3 index 9af9698329..60fda555bc 100644 --- a/lib/libssl/man/SSL_get_SSL_CTX.3 +++ b/lib/libssl/man/SSL_get_SSL_CTX.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_SSL_CTX.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_SSL_CTX.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_SSL_CTX 3 .Os .Sh NAME @@ -75,5 +75,5 @@ object is returned. .Xr SSL_new 3 .Sh HISTORY .Fn SSL_get_SSL_CTX -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.1 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_certificate.3 b/lib/libssl/man/SSL_get_certificate.3 index 4576a2dbcb..e3730c2150 100644 --- a/lib/libssl/man/SSL_get_certificate.3 +++ b/lib/libssl/man/SSL_get_certificate.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_certificate.3,v 1.2 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_certificate.3,v 1.4 2018/04/25 13:51:34 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 25 2018 $ .Dt SSL_GET_CERTIFICATE 3 .Os .Sh NAME @@ -29,7 +29,7 @@ .Fc .Ft EVP_PKEY * .Fo SSL_get_privatekey -.Fa "SSL *ssl" +.Fa "const SSL *ssl" .Fc .Sh DESCRIPTION These functions retrieve certificate and key data from an @@ -56,7 +56,8 @@ if none is active. .Xr SSL_use_certificate 3 .Sh HISTORY .Fn SSL_get_certificate -and +first appeared in SSLeay 0.5.2a. .Fn SSL_get_privatekey -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0. +Both functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_ciphers.3 b/lib/libssl/man/SSL_get_ciphers.3 index a9e955be18..cbbf62b35e 100644 --- a/lib/libssl/man/SSL_get_ciphers.3 +++ b/lib/libssl/man/SSL_get_ciphers.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_ciphers.3,v 1.5 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_get_ciphers.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL c3e64028 Mar 30 11:50:14 2005 +0000 .\" selective merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" @@ -51,7 +51,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_CIPHERS 3 .Os .Sh NAME @@ -136,10 +136,11 @@ is returned. .Xr SSL_CIPHER_get_name 3 , .Xr SSL_CTX_set_cipher_list 3 .Sh HISTORY -.Fn SSL_get_ciphers -and .Fn SSL_get_cipher_list -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.2. +.Fn SSL_get_ciphers +first appeared in SSLeay 0.8.0. +Both functions have been available since .Ox 2.4 . .Pp .Fn SSL_CTX_get_ciphers diff --git a/lib/libssl/man/SSL_get_client_CA_list.3 b/lib/libssl/man/SSL_get_client_CA_list.3 index 6ed419aad9..e80e5cb6f5 100644 --- a/lib/libssl/man/SSL_get_client_CA_list.3 +++ b/lib/libssl/man/SSL_get_client_CA_list.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_client_CA_list.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_client_CA_list.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_CLIENT_CA_LIST 3 .Os .Sh NAME @@ -92,5 +92,5 @@ returns the list of client CAs sent from the server, if any. .Fn SSL_get_client_CA_list and .Fn SSL_CTX_get_client_CA_list -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_current_cipher.3 b/lib/libssl/man/SSL_get_current_cipher.3 index 8ff6a7bd0b..6b951d03ca 100644 --- a/lib/libssl/man/SSL_get_current_cipher.3 +++ b/lib/libssl/man/SSL_get_current_cipher.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_current_cipher.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_current_cipher.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_CURRENT_CIPHER 3 .Os .Sh NAME @@ -108,5 +108,15 @@ if no session has been established. .Xr ssl 3 , .Xr SSL_CIPHER_get_name 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +.Fn SSL_get_cipher +appeared in SSLeay 0.4 or earlier. +.Fn SSL_get_cipher_bits +first appeared in SSLeay 0.6.4. +.Fn SSL_get_cipher_name +and +.Fn SSL_get_cipher_version +first appeared in SSLeay 0.8.0. +.Fn SSL_get_current_cipher +first appeared in SSLeay 0.8.1. +These functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_default_timeout.3 b/lib/libssl/man/SSL_get_default_timeout.3 index b8e53dc9b4..47737d8ee0 100644 --- a/lib/libssl/man/SSL_get_default_timeout.3 +++ b/lib/libssl/man/SSL_get_default_timeout.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_default_timeout.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_default_timeout.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_DEFAULT_TIMEOUT 3 .Os .Sh NAME @@ -81,5 +81,5 @@ protocols (SSLv2, SSLv3, and TLSv1). .Xr SSL_SESSION_get_time 3 .Sh HISTORY .Fn SSL_get_default_timeout -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_error.3 b/lib/libssl/man/SSL_get_error.3 index 3afa3ce61f..5d325b3f56 100644 --- a/lib/libssl/man/SSL_get_error.3 +++ b/lib/libssl/man/SSL_get_error.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_error.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_error.3,v 1.5 2018/04/29 07:37:01 guenther Exp $ .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" .\" This file was written by Bodo Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: April 29 2018 $ .Dt SSL_GET_ERROR 3 .Os .Sh NAME @@ -98,7 +98,7 @@ The following return values can currently occur: The TLS/SSL I/O operation completed. This result code is returned if and only if .Fa ret -< 0. +> 0. .It Dv SSL_ERROR_ZERO_RETURN The TLS/SSL connection has been closed. If the protocol version is SSL 3.0 or TLS 1.0, this result code is returned @@ -213,5 +213,5 @@ The OpenSSL error queue contains more information on the error. .Xr ssl 3 .Sh HISTORY .Fn SSL_get_error -first appeared in SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_ex_new_index.3 b/lib/libssl/man/SSL_get_ex_new_index.3 index c4af30a208..cecd25fa44 100644 --- a/lib/libssl/man/SSL_get_ex_new_index.3 +++ b/lib/libssl/man/SSL_get_ex_new_index.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_ex_new_index.3,v 1.3 2018/03/21 08:06:34 schwarze Exp $ +.\" $OpenBSD: SSL_get_ex_new_index.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_EX_NEW_INDEX 3 .Os .Sh NAME @@ -122,6 +122,12 @@ in .Xr ssl 3 , .Xr SSL_CTX_set_verify 3 .Sh HISTORY +Precursor functions +.Fn SSL_set_app_data +and +.Fn SSL_get_app_data +first appeared in SSLeay 0.6.1. +.Pp .Fn SSL_get_ex_new_index , .Fn SSL_set_ex_data , and diff --git a/lib/libssl/man/SSL_get_fd.3 b/lib/libssl/man/SSL_get_fd.3 index 9aa5150dbc..1e093424cb 100644 --- a/lib/libssl/man/SSL_get_fd.3 +++ b/lib/libssl/man/SSL_get_fd.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_fd.3,v 1.5 2018/03/22 17:38:41 schwarze Exp $ +.\" $OpenBSD: SSL_get_fd.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_FD 3 .Os .Sh NAME @@ -93,7 +93,7 @@ The file descriptor linked to .Xr SSL_set_fd 3 .Sh HISTORY .Fn SSL_get_fd -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . .Pp .Fn SSL_get_rfd diff --git a/lib/libssl/man/SSL_get_peer_cert_chain.3 b/lib/libssl/man/SSL_get_peer_cert_chain.3 index b63859dfe2..eb2ae53dc4 100644 --- a/lib/libssl/man/SSL_get_peer_cert_chain.3 +++ b/lib/libssl/man/SSL_get_peer_cert_chain.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_peer_cert_chain.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_peer_cert_chain.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL SSL_get_peer_cert_chain.pod 1f164c6f Jan 18 01:40:36 2017 +0100 .\" OpenSSL SSL_get_peer_cert_chain.pod 9b86974e Aug 17 15:21:33 2015 -0400 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_PEER_CERT_CHAIN 3 .Os .Sh NAME @@ -103,5 +103,5 @@ The return value points to the certificate chain presented by the peer. .Xr SSL_get_peer_certificate 3 .Sh HISTORY .Fn SSL_get_peer_cert_chain -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_peer_certificate.3 b/lib/libssl/man/SSL_get_peer_certificate.3 index 49d992363b..5e7247f4d1 100644 --- a/lib/libssl/man/SSL_get_peer_certificate.3 +++ b/lib/libssl/man/SSL_get_peer_certificate.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_peer_certificate.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_peer_certificate.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_PEER_CERTIFICATE 3 .Os .Sh NAME @@ -100,5 +100,5 @@ The return value points to the certificate presented by the peer. .Xr SSL_get_verify_result 3 .Sh HISTORY .Fn SSL_get_peer_certificate -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_rbio.3 b/lib/libssl/man/SSL_get_rbio.3 index 540c13990c..38096fbecf 100644 --- a/lib/libssl/man/SSL_get_rbio.3 +++ b/lib/libssl/man/SSL_get_rbio.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_rbio.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_rbio.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_RBIO 3 .Os .Sh NAME @@ -94,5 +94,5 @@ linked to .Fn SSL_get_rbio and .Fn SSL_get_wbio -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_session.3 b/lib/libssl/man/SSL_get_session.3 index 96d597a734..4cde129bc2 100644 --- a/lib/libssl/man/SSL_get_session.3 +++ b/lib/libssl/man/SSL_get_session.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_session.3,v 1.6 2018/03/22 16:07:53 schwarze Exp $ +.\" $OpenBSD: SSL_get_session.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_SESSION 3 .Os .Sh NAME @@ -153,7 +153,7 @@ session. .Xr SSL_set_session 3 .Sh HISTORY .Fn SSL_get_session -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.2 and has been available since .Ox 2.4 . .Pp .Fn SSL_get0_session diff --git a/lib/libssl/man/SSL_get_shared_ciphers.3 b/lib/libssl/man/SSL_get_shared_ciphers.3 index 86ec0be660..45228921f9 100644 --- a/lib/libssl/man/SSL_get_shared_ciphers.3 +++ b/lib/libssl/man/SSL_get_shared_ciphers.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_shared_ciphers.3,v 1.2 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_shared_ciphers.3,v 1.3 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_SHARED_CIPHERS 3 .Os .Sh NAME @@ -55,7 +55,7 @@ Otherwise, it returns .Fa buf . .Sh HISTORY .Fn SSL_get_shared_ciphers -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.4.5b and has been available since .Ox 2.4 . .Sh BUGS If the list is too long to fit into diff --git a/lib/libssl/man/SSL_get_state.3 b/lib/libssl/man/SSL_get_state.3 index 1d586df7de..d284691af1 100644 --- a/lib/libssl/man/SSL_get_state.3 +++ b/lib/libssl/man/SSL_get_state.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_state.3,v 1.3 2018/03/21 08:06:34 schwarze Exp $ +.\" $OpenBSD: SSL_get_state.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_STATE 3 .Os .Sh NAME @@ -143,15 +143,18 @@ All these functions may be implemented as macros. .Xr SSL_renegotiate 3 , .Xr SSL_set_connect_state 3 .Sh HISTORY -.Fn SSL_state , +.Fn SSL_is_init_finished +first appeared in SSLeay 0.4.5b. +.Fn SSL_state +first appeared in SSLeay 0.5.2. .Fn SSL_in_accept_init , -.Fn SSL_in_before , .Fn SSL_in_connect_init , -.Fn SSL_in_init , and -.Fn SSL_is_init_finished -appeared before SSLeay 0.8. +.Fn SSL_in_init +first appeared in SSLeay 0.6.0. +.Fn SSL_in_before +first appeared in SSLeay 0.8.0. .Fn SSL_get_state first appeared in SSLeay 0.9.0. -These functions have been available since +All these functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_get_verify_result.3 b/lib/libssl/man/SSL_get_verify_result.3 index dac7faac2a..ec4df2d38e 100644 --- a/lib/libssl/man/SSL_get_verify_result.3 +++ b/lib/libssl/man/SSL_get_verify_result.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_verify_result.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_verify_result.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_VERIFY_RESULT 3 .Os .Sh NAME @@ -88,7 +88,7 @@ Documented in .Xr SSL_set_verify_result 3 .Sh HISTORY .Fn SSL_get_verify_result -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.1 and has been available since .Ox 2.4 . .Sh BUGS If no peer certificate was presented, the returned result code is diff --git a/lib/libssl/man/SSL_get_version.3 b/lib/libssl/man/SSL_get_version.3 index f903e44fcf..00291ac4ad 100644 --- a/lib/libssl/man/SSL_get_version.3 +++ b/lib/libssl/man/SSL_get_version.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_get_version.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_get_version.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_GET_VERSION 3 .Os .Sh NAME @@ -88,5 +88,5 @@ This indicates that no version has been set (no connection established). .Fn SSL_get_version and .Fn SSL_version -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_library_init.3 b/lib/libssl/man/SSL_library_init.3 index a45e91e043..42f19adc28 100644 --- a/lib/libssl/man/SSL_library_init.3 +++ b/lib/libssl/man/SSL_library_init.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_library_init.3,v 1.5 2018/03/22 16:07:53 schwarze Exp $ +.\" $OpenBSD: SSL_library_init.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 22 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_LIBRARY_INIT 3 .Os .Sh NAME @@ -98,7 +98,7 @@ SSL_library_init(); /* initialize library */ .Xr SSL_load_error_strings 3 .Sh HISTORY .Fn SSLeay_add_ssl_algorithms -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . .Pp .Fn SSL_library_init diff --git a/lib/libssl/man/SSL_load_client_CA_file.3 b/lib/libssl/man/SSL_load_client_CA_file.3 index b8cf94f9d9..e893d63e28 100644 --- a/lib/libssl/man/SSL_load_client_CA_file.3 +++ b/lib/libssl/man/SSL_load_client_CA_file.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_load_client_CA_file.3,v 1.7 2018/03/21 16:12:41 schwarze Exp $ +.\" $OpenBSD: SSL_load_client_CA_file.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_LOAD_CLIENT_CA_FILE 3 .Os .Sh NAME @@ -146,7 +146,7 @@ else .Xr X509_NAME_new 3 .Sh HISTORY .Fn SSL_load_client_CA_file -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . .Pp .Fn SSL_add_file_cert_subjects_to_stack diff --git a/lib/libssl/man/SSL_new.3 b/lib/libssl/man/SSL_new.3 index b0d55eca71..f84eed7df8 100644 --- a/lib/libssl/man/SSL_new.3 +++ b/lib/libssl/man/SSL_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_new.3,v 1.5 2018/03/24 00:55:37 schwarze Exp $ +.\" $OpenBSD: SSL_new.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to: OpenSSL 1c7ae3dd Mar 29 19:17:55 2017 +1000 .\" .\" This file was written by Richard Levitte @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 24 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_NEW 3 .Os .Sh NAME @@ -101,7 +101,7 @@ returns 1 for success or 0 for failure. .Xr SSL_get_SSL_CTX 3 .Sh HISTORY .Fn SSL_new -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . .Pp .Fn SSL_up_ref diff --git a/lib/libssl/man/SSL_pending.3 b/lib/libssl/man/SSL_pending.3 index 57e6237878..b3efa4260d 100644 --- a/lib/libssl/man/SSL_pending.3 +++ b/lib/libssl/man/SSL_pending.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_pending.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_pending.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" .\" This file was written by Lutz Jaenicke , @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_PENDING 3 .Os .Sh NAME @@ -101,7 +101,7 @@ bytes that are pending and are available for immediate read. .Xr SSL_read 3 .Sh HISTORY .Fn SSL_pending -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . .Sh BUGS Up to OpenSSL 0.9.6, diff --git a/lib/libssl/man/SSL_read.3 b/lib/libssl/man/SSL_read.3 index cdb12746b0..d773065a81 100644 --- a/lib/libssl/man/SSL_read.3 +++ b/lib/libssl/man/SSL_read.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_read.3,v 1.5 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_read.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Lutz Jaenicke and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_READ 3 .Os .Sh NAME @@ -225,7 +225,8 @@ with the return value to find out the reason. .Xr SSL_write 3 .Sh HISTORY .Fn SSL_read -and +appeared in SSLeay 0.4 or earlier. .Fn SSL_peek -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.6. +Both functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_renegotiate.3 b/lib/libssl/man/SSL_renegotiate.3 index 2c90b3ef04..cf6308f283 100644 --- a/lib/libssl/man/SSL_renegotiate.3 +++ b/lib/libssl/man/SSL_renegotiate.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_renegotiate.3,v 1.7 2018/03/23 05:50:30 schwarze Exp $ +.\" $OpenBSD: SSL_renegotiate.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL SSL_key_update.pod 4fbfe86a Feb 16 17:04:40 2017 +0000 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_RENEGOTIATE 3 .Os .Sh NAME @@ -153,7 +153,7 @@ scheduled but not yet acted on, or 0 otherwise. .Xr SSL_write 3 .Sh HISTORY .Fn SSL_renegotiate -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . .Pp .Fn SSL_renegotiate_pending diff --git a/lib/libssl/man/SSL_rstate_string.3 b/lib/libssl/man/SSL_rstate_string.3 index ebc97616f5..99613ba3c0 100644 --- a/lib/libssl/man/SSL_rstate_string.3 +++ b/lib/libssl/man/SSL_rstate_string.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_rstate_string.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_rstate_string.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_RSTATE_STRING 3 .Os .Sh NAME @@ -104,5 +104,5 @@ This should never happen. .Fn SSL_rstate_string and .Fn SSL_rstate_string_long -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_session_reused.3 b/lib/libssl/man/SSL_session_reused.3 index d46b32a084..0fdf776f60 100644 --- a/lib/libssl/man/SSL_session_reused.3 +++ b/lib/libssl/man/SSL_session_reused.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_session_reused.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_session_reused.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SESSION_REUSED 3 .Os .Sh NAME @@ -79,5 +79,5 @@ A session was reused. .Xr SSL_set_session 3 .Sh HISTORY .Fn SSL_session_reused -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_set_bio.3 b/lib/libssl/man/SSL_set_bio.3 index 6b035ac82b..f3ea507d00 100644 --- a/lib/libssl/man/SSL_set_bio.3 +++ b/lib/libssl/man/SSL_set_bio.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_set_bio.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_set_bio.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL acb5b343 Sep 16 16:00:38 2000 +0000 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SET_BIO 3 .Os .Sh NAME @@ -98,5 +98,5 @@ cannot fail. .Xr SSL_shutdown 3 .Sh HISTORY .Fn SSL_set_bio -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_set_connect_state.3 b/lib/libssl/man/SSL_set_connect_state.3 index 7e3a39985b..c2072c4370 100644 --- a/lib/libssl/man/SSL_set_connect_state.3 +++ b/lib/libssl/man/SSL_set_connect_state.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_set_connect_state.3,v 1.5 2018/03/23 14:28:16 schwarze Exp $ +.\" $OpenBSD: SSL_set_connect_state.3,v 1.6 2018/03/27 17:35:50 schwarze Exp $ .\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" selective merge up to: OpenSSL dbd007d7 Jul 28 13:31:27 2017 +0800 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SET_CONNECT_STATE 3 .Os .Sh NAME @@ -145,7 +145,7 @@ is set to server mode or 0 if it is set to client mode. .Fn SSL_set_connect_state and .Fn SSL_set_accept_state -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . .Pp .Fn SSL_is_server diff --git a/lib/libssl/man/SSL_set_fd.3 b/lib/libssl/man/SSL_set_fd.3 index 5f2b4be3c7..7b9727e9ad 100644 --- a/lib/libssl/man/SSL_set_fd.3 +++ b/lib/libssl/man/SSL_set_fd.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_set_fd.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_set_fd.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SET_FD 3 .Os .Sh NAME @@ -119,5 +119,11 @@ The operation succeeded. .Xr SSL_set_bio 3 , .Xr SSL_shutdown 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +.Fn SSL_set_fd +appeared in SSLeay 0.4 or earlier. +.Fn SSL_set_rfd +and +.Fn SSL_set_wfd +first appeared in SSLeay 0.6.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_set_session.3 b/lib/libssl/man/SSL_set_session.3 index 80efd4f12b..7d85f5ad0c 100644 --- a/lib/libssl/man/SSL_set_session.3 +++ b/lib/libssl/man/SSL_set_session.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_set_session.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_set_session.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SET_SESSION 3 .Os .Sh NAME @@ -115,5 +115,5 @@ The operation succeeded. .Xr SSL_session_reused 3 .Sh HISTORY .Fn SSL_set_session -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.5.2 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_set_shutdown.3 b/lib/libssl/man/SSL_set_shutdown.3 index 87f7a92d09..1a4d9de4d3 100644 --- a/lib/libssl/man/SSL_set_shutdown.3 +++ b/lib/libssl/man/SSL_set_shutdown.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_set_shutdown.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_set_shutdown.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SET_SHUTDOWN 3 .Os .Sh NAME @@ -137,5 +137,5 @@ returns the current setting. .Fn SSL_set_shutdown and .Fn SSL_get_shutdown -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.8.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_set_verify_result.3 b/lib/libssl/man/SSL_set_verify_result.3 index 2b30b892cd..1ff8101ff9 100644 --- a/lib/libssl/man/SSL_set_verify_result.3 +++ b/lib/libssl/man/SSL_set_verify_result.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_set_verify_result.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_set_verify_result.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SET_VERIFY_RESULT 3 .Os .Sh NAME @@ -89,5 +89,5 @@ does not provide a return value. .Xr SSL_get_verify_result 3 .Sh HISTORY .Fn SSL_set_verify_result -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.6.1 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_shutdown.3 b/lib/libssl/man/SSL_shutdown.3 index c5432679b3..bfb1e91ea7 100644 --- a/lib/libssl/man/SSL_shutdown.3 +++ b/lib/libssl/man/SSL_shutdown.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_shutdown.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_shutdown.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_SHUTDOWN 3 .Os .Sh NAME @@ -249,5 +249,5 @@ to find out the reason. .Xr SSL_set_shutdown 3 .Sh HISTORY .Fn SSL_shutdown -appeared before SSLeay 0.8 and has been available since +first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_state_string.3 b/lib/libssl/man/SSL_state_string.3 index 7e9d40a847..1070335448 100644 --- a/lib/libssl/man/SSL_state_string.3 +++ b/lib/libssl/man/SSL_state_string.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_state_string.3,v 1.3 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_state_string.3,v 1.4 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_STATE_STRING 3 .Os .Sh NAME @@ -106,5 +106,5 @@ Detailed description of possible states to be included later. .Fn SSL_state_string and .Fn SSL_state_string_long -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.6.0 and have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_want.3 b/lib/libssl/man/SSL_want.3 index f2ef1986b6..24e8645ba8 100644 --- a/lib/libssl/man/SSL_want.3 +++ b/lib/libssl/man/SSL_want.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_want.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_want.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_WANT 3 .Os .Sh NAME @@ -149,5 +149,13 @@ return 1 when the corresponding condition is true or 0 otherwise. .Xr ssl 3 , .Xr SSL_get_error 3 .Sh HISTORY -These functions appeared before SSLeay 0.8 and have been available since +.Fn SSL_want , +.Fn SSL_want_nothing , +.Fn SSL_want_read , +and +.Fn SSL_want_write +first appeared in SSLeay 0.5.2. +.Fn SSL_want_x509_lookup +first appeared in SSLeay 0.6.0. +These functions have been available since .Ox 2.4 . diff --git a/lib/libssl/man/SSL_write.3 b/lib/libssl/man/SSL_write.3 index 80c3997433..d5e985e42a 100644 --- a/lib/libssl/man/SSL_write.3 +++ b/lib/libssl/man/SSL_write.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_write.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: SSL_write.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: March 27 2018 $ .Dt SSL_WRITE 3 .Os .Sh NAME @@ -220,5 +220,5 @@ with the return value to find out the reason. .Xr SSL_set_connect_state 3 .Sh HISTORY .Fn SSL_write -appeared before SSLeay 0.8 and has been available since +appeared in SSLeay 0.4 or earlier and has been available since .Ox 2.4 . diff --git a/lib/libssl/man/d2i_SSL_SESSION.3 b/lib/libssl/man/d2i_SSL_SESSION.3 index 82f7b66f40..9c5c2285fa 100644 --- a/lib/libssl/man/d2i_SSL_SESSION.3 +++ b/lib/libssl/man/d2i_SSL_SESSION.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: d2i_SSL_SESSION.3,v 1.4 2018/03/21 05:07:04 schwarze Exp $ +.\" $OpenBSD: d2i_SSL_SESSION.3,v 1.6 2018/08/27 15:42:39 jsing Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Lutz Jaenicke . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 21 2018 $ +.Dd $Mdocdate: August 27 2018 $ .Dt D2I_SSL_SESSION 3 .Os .Sh NAME @@ -131,31 +131,29 @@ the memory location pointed to by .Fa pp must be large enough to hold the binary representation of the session. There is no known limit on the size of the created ASN1 representation, -so the necessary amount of space should be obtained by first calling +so call .Fn i2d_SSL_SESSION -with -.Fa pp Ns -= Ns -.Dv NULL , -and obtain the size needed, then allocate the memory and call +first with +.Fa pp Ns = Ns Dv NULL +to obtain the encoded size, before allocating the required amount of memory and +calling .Fn i2d_SSL_SESSION again. Note that this will advance the value contained in .Fa *pp so it is necessary to save a copy of the original allocation. For example: -.Bd -literal -int i, j; +.Bd -literal -offset indent +char *p, *pp; +int elen, len; -char *p, *temp; - - i = i2d_SSL_SESSION(sess, NULL); - p = temp = malloc(i); - if (temp != NULL) { - j = i2d_SSL_SESSION(sess, &temp); - assert(i == j); - assert(p + i == temp); - } +elen = i2d_SSL_SESSION(sess, NULL); +p = pp = malloc(elen); +if (p != NULL) { + len = i2d_SSL_SESSION(sess, &pp); + assert(elen == len); + assert(p + len == pp); +} .Ed .Sh RETURN VALUES .Fn d2i_SSL_SESSION @@ -179,5 +177,5 @@ When the session is not valid, 0 is returned and no operation is performed. .Fn d2i_SSL_SESSION and .Fn i2d_SSL_SESSION -appeared before SSLeay 0.8 and have been available since +first appeared in SSLeay 0.5.2 and have been available since .Ox 2.4 . diff --git a/lib/libssl/s3_cbc.c b/lib/libssl/s3_cbc.c index 8c910c5f86..a1c0ce6b90 100644 --- a/lib/libssl/s3_cbc.c +++ b/lib/libssl/s3_cbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_cbc.c,v 1.16 2017/01/23 08:08:06 beck Exp $ */ +/* $OpenBSD: s3_cbc.c,v 1.17 2018/09/08 14:39:41 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2012 The OpenSSL Project. All rights reserved. * @@ -135,12 +135,6 @@ tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD *rec, unsigned block_size, padding_length = rec->data[rec->length - 1]; - if (EVP_CIPHER_flags(s->enc_read_ctx->cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) { - /* padding is already verified */ - rec->length -= padding_length + 1; - return 1; - } - good = constant_time_ge(rec->length, overhead + padding_length); /* The padding consists of a length byte at the end of the record and * then that many bytes of padding, all with the same value as the diff --git a/lib/libssl/s3_lib.c b/lib/libssl/s3_lib.c index 52e0c52410..02e6c66a47 100644 --- a/lib/libssl/s3_lib.c +++ b/lib/libssl/s3_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_lib.c,v 1.165 2018/03/15 12:27:00 jca Exp $ */ +/* $OpenBSD: s3_lib.c,v 1.170 2018/09/06 16:40:45 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -237,22 +237,6 @@ SSL_CIPHER ssl3_ciphers[] = { .alg_bits = 128, }, - /* Cipher 09 */ - { - .valid = 1, - .name = SSL3_TXT_RSA_DES_64_CBC_SHA, - .id = SSL3_CK_RSA_DES_64_CBC_SHA, - .algorithm_mkey = SSL_kRSA, - .algorithm_auth = SSL_aRSA, - .algorithm_enc = SSL_DES, - .algorithm_mac = SSL_SHA1, - .algorithm_ssl = SSL_SSLV3, - .algo_strength = SSL_LOW, - .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, - .strength_bits = 56, - .alg_bits = 56, - }, - /* Cipher 0A */ { .valid = 1, @@ -273,22 +257,6 @@ SSL_CIPHER ssl3_ciphers[] = { * Ephemeral DH (DHE) ciphers. */ - /* Cipher 15 */ - { - .valid = 1, - .name = SSL3_TXT_EDH_RSA_DES_64_CBC_SHA, - .id = SSL3_CK_EDH_RSA_DES_64_CBC_SHA, - .algorithm_mkey = SSL_kDHE, - .algorithm_auth = SSL_aRSA, - .algorithm_enc = SSL_DES, - .algorithm_mac = SSL_SHA1, - .algorithm_ssl = SSL_SSLV3, - .algo_strength = SSL_LOW, - .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, - .strength_bits = 56, - .alg_bits = 56, - }, - /* Cipher 16 */ { .valid = 1, @@ -321,22 +289,6 @@ SSL_CIPHER ssl3_ciphers[] = { .alg_bits = 128, }, - /* Cipher 1A */ - { - .valid = 1, - .name = SSL3_TXT_ADH_DES_64_CBC_SHA, - .id = SSL3_CK_ADH_DES_64_CBC_SHA, - .algorithm_mkey = SSL_kDHE, - .algorithm_auth = SSL_aNULL, - .algorithm_enc = SSL_DES, - .algorithm_mac = SSL_SHA1, - .algorithm_ssl = SSL_SSLV3, - .algo_strength = SSL_LOW, - .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, - .strength_bits = 56, - .alg_bits = 56, - }, - /* Cipher 1B */ { .valid = 1, @@ -722,7 +674,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, @@ -740,7 +692,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, @@ -758,7 +710,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, @@ -776,7 +728,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, @@ -794,7 +746,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, @@ -812,7 +764,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, @@ -1239,7 +1191,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, @@ -1257,7 +1209,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, @@ -1275,7 +1227,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, @@ -1293,7 +1245,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| + FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, @@ -1311,7 +1263,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(12), + FIXED_NONCE_LEN(12), .strength_bits = 256, .alg_bits = 256, }, @@ -1328,7 +1280,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(12), + FIXED_NONCE_LEN(12), .strength_bits = 256, .alg_bits = 256, }, @@ -1345,7 +1297,7 @@ SSL_CIPHER ssl3_ciphers[] = { .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| - SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(12), + FIXED_NONCE_LEN(12), .strength_bits = 256, .alg_bits = 256, }, @@ -1445,44 +1397,8 @@ ssl3_handshake_msg_hdr_len(SSL *s) SSL3_HM_HEADER_LENGTH); } -unsigned char * -ssl3_handshake_msg_start(SSL *s, uint8_t msg_type) -{ - unsigned char *d, *p; - - d = p = (unsigned char *)s->internal->init_buf->data; - - /* Handshake message type and length. */ - *(p++) = msg_type; - l2n3(0, p); - - return (d + ssl3_handshake_msg_hdr_len(s)); -} - -void -ssl3_handshake_msg_finish(SSL *s, unsigned int len) -{ - unsigned char *p; - uint8_t msg_type; - - p = (unsigned char *)s->internal->init_buf->data; - - /* Handshake message length. */ - msg_type = *(p++); - l2n3(len, p); - - s->internal->init_num = ssl3_handshake_msg_hdr_len(s) + (int)len; - s->internal->init_off = 0; - - if (SSL_IS_DTLS(s)) { - dtls1_set_message_header(s, msg_type, len, 0, len); - dtls1_buffer_message(s, 0); - } -} - int -ssl3_handshake_msg_start_cbb(SSL *s, CBB *handshake, CBB *body, - uint8_t msg_type) +ssl3_handshake_msg_start(SSL *s, CBB *handshake, CBB *body, uint8_t msg_type) { int ret = 0; @@ -1507,7 +1423,7 @@ ssl3_handshake_msg_start_cbb(SSL *s, CBB *handshake, CBB *body, } int -ssl3_handshake_msg_finish_cbb(SSL *s, CBB *handshake) +ssl3_handshake_msg_finish(SSL *s, CBB *handshake) { unsigned char *data = NULL; size_t outlen; @@ -2166,14 +2082,14 @@ _SSL_CTX_add_extra_chain_cert(SSL_CTX *ctx, X509 *cert) return 1; } -int +static int _SSL_CTX_get_extra_chain_certs(SSL_CTX *ctx, STACK_OF(X509) **certs) { *certs = ctx->extra_certs; return 1; } -int +static int _SSL_CTX_clear_extra_chain_certs(SSL_CTX *ctx) { sk_X509_pop_free(ctx->extra_certs, X509_free); @@ -2524,56 +2440,13 @@ ssl3_shutdown(SSL *s) int ssl3_write(SSL *s, const void *buf, int len) { - int ret, n; - -#if 0 - if (s->internal->shutdown & SSL_SEND_SHUTDOWN) { - s->internal->rwstate = SSL_NOTHING; - return (0); - } -#endif errno = 0; + if (S3I(s)->renegotiate) ssl3_renegotiate_check(s); - /* - * This is an experimental flag that sends the - * last handshake message in the same packet as the first - * use data - used to see if it helps the TCP protocol during - * session-id reuse - */ - /* The second test is because the buffer may have been removed */ - if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio)) { - /* First time through, we write into the buffer */ - if (S3I(s)->delay_buf_pop_ret == 0) { - ret = ssl3_write_bytes(s, SSL3_RT_APPLICATION_DATA, - buf, len); - if (ret <= 0) - return (ret); - - S3I(s)->delay_buf_pop_ret = ret; - } - - s->internal->rwstate = SSL_WRITING; - n = BIO_flush(s->wbio); - if (n <= 0) - return (n); - s->internal->rwstate = SSL_NOTHING; - - /* We have flushed the buffer, so remove it */ - ssl_free_wbio_buffer(s); - s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER; - - ret = S3I(s)->delay_buf_pop_ret; - S3I(s)->delay_buf_pop_ret = 0; - } else { - ret = s->method->internal->ssl_write_bytes(s, - SSL3_RT_APPLICATION_DATA, buf, len); - if (ret <= 0) - return (ret); - } - - return (ret); + return s->method->internal->ssl_write_bytes(s, + SSL3_RT_APPLICATION_DATA, buf, len); } static int diff --git a/lib/libssl/shlib_version b/lib/libssl/shlib_version index d31fc35547..25f1cb4022 100644 --- a/lib/libssl/shlib_version +++ b/lib/libssl/shlib_version @@ -1,3 +1,3 @@ # Don't forget to give libtls the same type of bump! -major=45 +major=46 minor=1 diff --git a/lib/libssl/ssl.h b/lib/libssl/ssl.h index 78a6787d43..324691485b 100644 --- a/lib/libssl/ssl.h +++ b/lib/libssl/ssl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.h,v 1.154 2018/03/20 15:28:12 tb Exp $ */ +/* $OpenBSD: ssl.h,v 1.159 2018/08/24 20:30:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -507,11 +507,6 @@ struct ssl_session_st { /* Set on servers to choose the cipher according to the server's * preferences */ #define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L -/* If set, a server will allow a client to issue a SSLv3.0 version number - * as latest version supported in the premaster secret, even when TLSv1.0 - * (version 3.1) was announced in the client hello. Normally this is - * forbidden to prevent version rollback attacks. */ -#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L #define SSL_OP_NO_TLSv1 0x04000000L #define SSL_OP_NO_TLSv1_2 0x08000000L @@ -545,6 +540,7 @@ struct ssl_session_st { #define SSL_OP_TLSEXT_PADDING 0x0 #define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0 #define SSL_OP_TLS_D5_BUG 0x0 +#define SSL_OP_TLS_ROLLBACK_BUG 0x0 /* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success * when just a single record has been written): */ @@ -731,10 +727,10 @@ void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess); void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, - SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data, - int len, int *copy)); + SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, + const unsigned char *data, int len, int *copy)); SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, - unsigned char *Data, int len, int *copy); + const unsigned char *data, int len, int *copy); void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl, int type, int val)); void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type, @@ -750,7 +746,7 @@ void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len)); void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, - int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, + int (*app_verify_cookie_cb)(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len)); void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s, int (*cb)(SSL *ssl, const unsigned char **out, unsigned int *outlen, void *arg), void *arg); @@ -1225,7 +1221,7 @@ int SSL_set_max_proto_version(SSL *ssl, uint16_t version); #define SSL_set_max_proto_version SSL_set_max_proto_version #endif -BIO_METHOD *BIO_f_ssl(void); +const BIO_METHOD *BIO_f_ssl(void); BIO *BIO_new_ssl(SSL_CTX *ctx, int client); BIO *BIO_new_ssl_connect(SSL_CTX *ctx); BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); @@ -1251,7 +1247,7 @@ const SSL_CIPHER *SSL_get_current_cipher(const SSL *s); const SSL_CIPHER *SSL_CIPHER_get_by_id(unsigned int id); const SSL_CIPHER *SSL_CIPHER_get_by_value(uint16_t value); int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits); -char * SSL_CIPHER_get_version(const SSL_CIPHER *c); +const char * SSL_CIPHER_get_version(const SSL_CIPHER *c); const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); unsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c); uint16_t SSL_CIPHER_get_value(const SSL_CIPHER *c); @@ -1283,7 +1279,7 @@ void SSL_set_verify(SSL *s, int mode, int (*callback)(int ok, X509_STORE_CTX *ctx)); void SSL_set_verify_depth(SSL *s, int depth); int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); -int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); +int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d, long len); int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, long len); int SSL_use_certificate(SSL *ssl, X509 *x); @@ -1315,7 +1311,7 @@ long SSL_SESSION_get_time(const SSL_SESSION *s); long SSL_SESSION_set_time(SSL_SESSION *s, long t); long SSL_SESSION_get_timeout(const SSL_SESSION *s); long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); -void SSL_copy_session_id(SSL *to, const SSL *from); +int SSL_copy_session_id(SSL *to, const SSL *from); X509 *SSL_SESSION_get0_peer(SSL_SESSION *s); int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid, unsigned int sid_len); @@ -1461,12 +1457,12 @@ long SSL_get_default_timeout(const SSL *s); int SSL_library_init(void ); char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size); -STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); +STACK_OF(X509_NAME) *SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk); SSL *SSL_dup(SSL *ssl); X509 *SSL_get_certificate(const SSL *ssl); -/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl); +/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl); void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode); int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); diff --git a/lib/libssl/ssl3.h b/lib/libssl/ssl3.h index 12ef56b522..f8833fa1bb 100644 --- a/lib/libssl/ssl3.h +++ b/lib/libssl/ssl3.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl3.h,v 1.46 2017/08/28 17:36:58 jsing Exp $ */ +/* $OpenBSD: ssl3.h,v 1.47 2018/04/07 16:55:13 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -348,11 +348,7 @@ typedef struct ssl3_buffer_st { */ #define SSL3_CT_NUMBER 11 - #define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 -#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 -#define SSL3_FLAGS_POP_BUFFER 0x0004 -#define TLS1_FLAGS_TLS_PADDING_BUG 0x0 #define TLS1_FLAGS_SKIP_CERT_VERIFY 0x0010 #define TLS1_FLAGS_KEEP_HANDSHAKE 0x0020 #define SSL3_FLAGS_CCS_OK 0x0080 diff --git a/lib/libssl/ssl_asn1.c b/lib/libssl/ssl_asn1.c index 0ca442faa0..94fc8685fc 100644 --- a/lib/libssl/ssl_asn1.c +++ b/lib/libssl/ssl_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_asn1.c,v 1.56 2018/03/20 16:10:57 jsing Exp $ */ +/* $OpenBSD: ssl_asn1.c,v 1.57 2018/08/27 16:42:48 jsing Exp $ */ /* * Copyright (c) 2016 Joel Sing * @@ -44,23 +44,16 @@ time_max(void) return 0; } -int -i2d_SSL_SESSION(SSL_SESSION *s, unsigned char **pp) +static int +SSL_SESSION_encode(SSL_SESSION *s, unsigned char **out, size_t *out_len, + int ticket_encoding) { CBB cbb, session, cipher_suite, session_id, master_key, time, timeout; - CBB peer_cert, sidctx, verify_result, hostname, lifetime, ticket; - CBB value; - unsigned char *data = NULL, *peer_cert_bytes = NULL; - size_t data_len = 0; - int len, rv = -1; + CBB peer_cert, sidctx, verify_result, hostname, lifetime, ticket, value; + unsigned char *peer_cert_bytes = NULL; + int len, rv = 0; uint16_t cid; - if (s == NULL) - return (0); - - if (s->cipher == NULL && s->cipher_id == 0) - return (0); - if (!CBB_init(&cbb, 0)) goto err; @@ -87,10 +80,11 @@ i2d_SSL_SESSION(SSL_SESSION *s, unsigned char **pp) if (!CBB_add_u16(&cipher_suite, cid)) goto err; - /* Session ID. */ + /* Session ID - zero length for a ticket. */ if (!CBB_add_asn1(&session, &session_id, CBS_ASN1_OCTETSTRING)) goto err; - if (!CBB_add_bytes(&session_id, s->session_id, s->session_id_length)) + if (!CBB_add_bytes(&session_id, s->session_id, + ticket_encoding ? 0 : s->session_id_length)) goto err; /* Master key. */ @@ -173,7 +167,7 @@ i2d_SSL_SESSION(SSL_SESSION *s, unsigned char **pp) } /* Ticket [10]. */ - if (s->tlsext_tick) { + if (s->tlsext_tick != NULL) { if (!CBB_add_asn1(&session, &ticket, SSLASN1_TICKET_TAG)) goto err; if (!CBB_add_asn1(&ticket, &value, CBS_ASN1_OCTETSTRING)) @@ -185,7 +179,44 @@ i2d_SSL_SESSION(SSL_SESSION *s, unsigned char **pp) /* Compression method [11]. */ /* SRP username [12]. */ - if (!CBB_finish(&cbb, &data, &data_len)) + if (!CBB_finish(&cbb, out, out_len)) + goto err; + + rv = 1; + + err: + CBB_cleanup(&cbb); + free(peer_cert_bytes); + + return rv; +} + +int +SSL_SESSION_ticket(SSL_SESSION *ss, unsigned char **out, size_t *out_len) +{ + if (ss == NULL) + return 0; + + if (ss->cipher == NULL && ss->cipher_id == 0) + return 0; + + return SSL_SESSION_encode(ss, out, out_len, 1); +} + +int +i2d_SSL_SESSION(SSL_SESSION *ss, unsigned char **pp) +{ + unsigned char *data = NULL; + size_t data_len = 0; + int rv = -1; + + if (ss == NULL) + return 0; + + if (ss->cipher == NULL && ss->cipher_id == 0) + return 0; + + if (!SSL_SESSION_encode(ss, &data, &data_len, 0)) goto err; if (data_len > INT_MAX) @@ -204,9 +235,7 @@ i2d_SSL_SESSION(SSL_SESSION *s, unsigned char **pp) rv = (int)data_len; err: - CBB_cleanup(&cbb); freezero(data, data_len); - free(peer_cert_bytes); return rv; } diff --git a/lib/libssl/ssl_both.c b/lib/libssl/ssl_both.c index 03f95977f7..788505e602 100644 --- a/lib/libssl/ssl_both.c +++ b/lib/libssl/ssl_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_both.c,v 1.11 2017/10/08 16:24:02 jsing Exp $ */ +/* $OpenBSD: ssl_both.c,v 1.12 2018/08/24 17:30:32 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -191,12 +191,12 @@ ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) S3I(s)->previous_server_finished_len = md_len; } - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &finished, + if (!ssl3_handshake_msg_start(s, &cbb, &finished, SSL3_MT_FINISHED)) goto err; if (!CBB_add_bytes(&finished, S3I(s)->tmp.finish_md, md_len)) goto err; - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = b; diff --git a/lib/libssl/ssl_cert.c b/lib/libssl/ssl_cert.c index a244353b88..a01f484578 100644 --- a/lib/libssl/ssl_cert.c +++ b/lib/libssl/ssl_cert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_cert.c,v 1.66 2017/08/12 02:55:22 jsing Exp $ */ +/* $OpenBSD: ssl_cert.c,v 1.67 2018/04/25 07:10:39 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -454,7 +454,7 @@ set_client_CA_list(STACK_OF(X509_NAME) **ca_list, } STACK_OF(X509_NAME) * -SSL_dup_CA_list(STACK_OF(X509_NAME) *sk) +SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk) { int i; STACK_OF(X509_NAME) *ret; diff --git a/lib/libssl/ssl_ciph.c b/lib/libssl/ssl_ciph.c index 271d77f38b..e54fbacdd8 100644 --- a/lib/libssl/ssl_ciph.c +++ b/lib/libssl/ssl_ciph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_ciph.c,v 1.98 2018/03/17 14:40:45 jsing Exp $ */ +/* $OpenBSD: ssl_ciph.c,v 1.105 2018/09/08 14:39:41 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -150,36 +150,28 @@ #include "ssl_locl.h" -#define SSL_ENC_DES_IDX 0 -#define SSL_ENC_3DES_IDX 1 -#define SSL_ENC_RC4_IDX 2 -#define SSL_ENC_IDEA_IDX 3 -#define SSL_ENC_NULL_IDX 4 -#define SSL_ENC_AES128_IDX 5 -#define SSL_ENC_AES256_IDX 6 -#define SSL_ENC_CAMELLIA128_IDX 7 -#define SSL_ENC_CAMELLIA256_IDX 8 -#define SSL_ENC_GOST89_IDX 9 -#define SSL_ENC_AES128GCM_IDX 10 -#define SSL_ENC_AES256GCM_IDX 11 -#define SSL_ENC_NUM_IDX 12 - +#define SSL_ENC_3DES_IDX 0 +#define SSL_ENC_RC4_IDX 1 +#define SSL_ENC_NULL_IDX 2 +#define SSL_ENC_AES128_IDX 3 +#define SSL_ENC_AES256_IDX 4 +#define SSL_ENC_CAMELLIA128_IDX 5 +#define SSL_ENC_CAMELLIA256_IDX 6 +#define SSL_ENC_GOST89_IDX 7 +#define SSL_ENC_NUM_IDX 8 static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; -#define SSL_MD_MD5_IDX 0 -#define SSL_MD_SHA1_IDX 1 -#define SSL_MD_GOST94_IDX 2 -#define SSL_MD_GOST89MAC_IDX 3 -#define SSL_MD_SHA256_IDX 4 -#define SSL_MD_SHA384_IDX 5 -#define SSL_MD_STREEBOG256_IDX 6 -/*Constant SSL_MAX_DIGEST equal to size of digests array should be - * defined in the - * ssl_locl.h */ -#define SSL_MD_NUM_IDX SSL_MAX_DIGEST +#define SSL_MD_MD5_IDX 0 +#define SSL_MD_SHA1_IDX 1 +#define SSL_MD_GOST94_IDX 2 +#define SSL_MD_GOST89MAC_IDX 3 +#define SSL_MD_SHA256_IDX 4 +#define SSL_MD_SHA384_IDX 5 +#define SSL_MD_STREEBOG256_IDX 6 +#define SSL_MD_NUM_IDX 7 static const EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; @@ -339,10 +331,6 @@ static const SSL_CIPHER cipher_aliases[] = { /* symmetric encryption aliases */ { - .name = SSL_TXT_DES, - .algorithm_enc = SSL_DES, - }, - { .name = SSL_TXT_3DES, .algorithm_enc = SSL_3DES, }, @@ -351,10 +339,6 @@ static const SSL_CIPHER cipher_aliases[] = { .algorithm_enc = SSL_RC4, }, { - .name = SSL_TXT_IDEA, - .algorithm_enc = SSL_IDEA, - }, - { .name = SSL_TXT_eNULL, .algorithm_enc = SSL_eNULL, }, @@ -461,13 +445,10 @@ static const SSL_CIPHER cipher_aliases[] = { void ssl_load_ciphers(void) { - ssl_cipher_methods[SSL_ENC_DES_IDX] = - EVP_get_cipherbyname(SN_des_cbc); ssl_cipher_methods[SSL_ENC_3DES_IDX] = EVP_get_cipherbyname(SN_des_ede3_cbc); ssl_cipher_methods[SSL_ENC_RC4_IDX] = EVP_get_cipherbyname(SN_rc4); - ssl_cipher_methods[SSL_ENC_IDEA_IDX] = NULL; ssl_cipher_methods[SSL_ENC_AES128_IDX] = EVP_get_cipherbyname(SN_aes_128_cbc); ssl_cipher_methods[SSL_ENC_AES256_IDX] = @@ -479,11 +460,6 @@ ssl_load_ciphers(void) ssl_cipher_methods[SSL_ENC_GOST89_IDX] = EVP_get_cipherbyname(SN_gost89_cnt); - ssl_cipher_methods[SSL_ENC_AES128GCM_IDX] = - EVP_get_cipherbyname(SN_aes_128_gcm); - ssl_cipher_methods[SSL_ENC_AES256GCM_IDX] = - EVP_get_cipherbyname(SN_aes_256_gcm); - ssl_digest_methods[SSL_MD_MD5_IDX] = EVP_get_digestbyname(SN_md5); ssl_mac_secret_size[SSL_MD_MD5_IDX] = @@ -536,25 +512,19 @@ ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, * This function does not handle EVP_AEAD. * See ssl_cipher_get_aead_evp instead. */ - if (c->algorithm2 & SSL_CIPHER_ALGORITHM2_AEAD) + if (c->algorithm_mac & SSL_AEAD) return(0); if ((enc == NULL) || (md == NULL)) return (0); switch (c->algorithm_enc) { - case SSL_DES: - i = SSL_ENC_DES_IDX; - break; case SSL_3DES: i = SSL_ENC_3DES_IDX; break; case SSL_RC4: i = SSL_ENC_RC4_IDX; break; - case SSL_IDEA: - i = SSL_ENC_IDEA_IDX; - break; case SSL_eNULL: i = SSL_ENC_NULL_IDX; break; @@ -573,12 +543,6 @@ ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, case SSL_eGOST2814789CNT: i = SSL_ENC_GOST89_IDX; break; - case SSL_AES128GCM: - i = SSL_ENC_AES128GCM_IDX; - break; - case SSL_AES256GCM: - i = SSL_ENC_AES256GCM_IDX; - break; default: i = -1; break; @@ -626,8 +590,6 @@ ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, *mac_pkey_type = NID_undef; if (mac_secret_size != NULL) *mac_secret_size = 0; - if (c->algorithm_mac == SSL_AEAD) - mac_pkey_type = NULL; } else { *md = ssl_digest_methods[i]; if (mac_pkey_type != NULL) @@ -636,30 +598,20 @@ ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, *mac_secret_size = ssl_mac_secret_size[i]; } - if ((*enc != NULL) && - (*md != NULL || (EVP_CIPHER_flags(*enc)&EVP_CIPH_FLAG_AEAD_CIPHER)) && - (!mac_pkey_type || *mac_pkey_type != NID_undef)) { - const EVP_CIPHER *evp; - - if (s->ssl_version >> 8 != TLS1_VERSION_MAJOR || - s->ssl_version < TLS1_VERSION) - return 1; - - if (c->algorithm_enc == SSL_RC4 && - c->algorithm_mac == SSL_MD5 && - (evp = EVP_get_cipherbyname("RC4-HMAC-MD5"))) - *enc = evp, *md = NULL; - else if (c->algorithm_enc == SSL_AES128 && - c->algorithm_mac == SSL_SHA1 && - (evp = EVP_get_cipherbyname("AES-128-CBC-HMAC-SHA1"))) - *enc = evp, *md = NULL; - else if (c->algorithm_enc == SSL_AES256 && - c->algorithm_mac == SSL_SHA1 && - (evp = EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA1"))) - *enc = evp, *md = NULL; - return (1); - } else - return (0); + if (*enc == NULL || *md == NULL || + (mac_pkey_type != NULL && *mac_pkey_type == NID_undef)) + return 0; + + /* + * EVP_CIPH_FLAG_AEAD_CIPHER and EVP_CIPH_GCM_MODE ciphers are not + * supported via EVP_CIPHER (they should be using EVP_AEAD instead). + */ + if (EVP_CIPHER_flags(*enc) & EVP_CIPH_FLAG_AEAD_CIPHER) + return 0; + if (EVP_CIPHER_mode(*enc) == EVP_CIPH_GCM_MODE) + return 0; + + return 1; } /* @@ -675,18 +627,16 @@ ssl_cipher_get_evp_aead(const SSL_SESSION *s, const EVP_AEAD **aead) if (c == NULL) return 0; - if ((c->algorithm2 & SSL_CIPHER_ALGORITHM2_AEAD) == 0) + if ((c->algorithm_mac & SSL_AEAD) == 0) return 0; switch (c->algorithm_enc) { -#ifndef OPENSSL_NO_AES case SSL_AES128GCM: *aead = EVP_aead_aes_128_gcm(); return 1; case SSL_AES256GCM: *aead = EVP_aead_aes_256_gcm(); return 1; -#endif case SSL_CHACHA20POLY1305: *aead = EVP_aead_chacha20_poly1305(); return 1; @@ -787,14 +737,10 @@ ssl_cipher_get_disabled(unsigned long *mkey, unsigned long *auth, *enc |= SSL_eNULL; #endif - *enc |= (ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL) ? SSL_DES : 0; *enc |= (ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL) ? SSL_3DES : 0; *enc |= (ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL) ? SSL_RC4 : 0; - *enc |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA : 0; *enc |= (ssl_cipher_methods[SSL_ENC_AES128_IDX] == NULL) ? SSL_AES128 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_AES256_IDX] == NULL) ? SSL_AES256 : 0; - *enc |= (ssl_cipher_methods[SSL_ENC_AES128GCM_IDX] == NULL) ? SSL_AES128GCM : 0; - *enc |= (ssl_cipher_methods[SSL_ENC_AES256GCM_IDX] == NULL) ? SSL_AES256GCM : 0; *enc |= (ssl_cipher_methods[SSL_ENC_CAMELLIA128_IDX] == NULL) ? SSL_CAMELLIA128 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_CAMELLIA256_IDX] == NULL) ? SSL_CAMELLIA256 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_GOST89_IDX] == NULL) ? SSL_eGOST2814789CNT : 0; @@ -1585,18 +1531,12 @@ SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len) } switch (alg_enc) { - case SSL_DES: - enc = "DES(56)"; - break; case SSL_3DES: enc = "3DES(168)"; break; case SSL_RC4: enc = alg2 & SSL2_CF_8_BYTE_ENC ? "RC4(64)" : "RC4(128)"; break; - case SSL_IDEA: - enc = "IDEA(128)"; - break; case SSL_eNULL: enc = "None"; break; @@ -1674,7 +1614,7 @@ SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len) return (ret); } -char * +const char * SSL_CIPHER_get_version(const SSL_CIPHER *c) { if (c == NULL) diff --git a/lib/libssl/ssl_clnt.c b/lib/libssl/ssl_clnt.c index 10dbe83cd5..77211b622b 100644 --- a/lib/libssl/ssl_clnt.c +++ b/lib/libssl/ssl_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_clnt.c,v 1.23 2018/02/08 11:30:30 jsing Exp $ */ +/* $OpenBSD: ssl_clnt.c,v 1.34 2018/09/05 16:58:59 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -510,15 +510,8 @@ ssl3_connect(SSL *s) S3I(s)->hs.state = SSL3_ST_CW_FLUSH; /* clear flags */ - s->s3->flags &= ~SSL3_FLAGS_POP_BUFFER; if (s->internal->hit) { S3I(s)->hs.next_state = SSL_ST_OK; - if (s->s3->flags & - SSL3_FLAGS_DELAY_CLIENT_FINISHED) { - S3I(s)->hs.state = SSL_ST_OK; - s->s3->flags |= SSL3_FLAGS_POP_BUFFER; - S3I(s)->delay_buf_pop_ret = 0; - } } else { /* Allow NewSessionTicket if ticket expected */ if (s->internal->tlsext_ticket_expected) @@ -595,13 +588,7 @@ ssl3_connect(SSL *s) s->internal->init_buf = NULL; } - /* - * If we are not 'joining' the last two packets, - * remove the buffering now - */ - if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER)) - ssl_free_wbio_buffer(s); - /* else do it later in ssl3_write */ + ssl_free_wbio_buffer(s); s->internal->init_num = 0; s->internal->renegotiate = 0; @@ -696,7 +683,7 @@ ssl3_send_client_hello(SSL *s) if (!SSL_IS_DTLS(s) || D1I(s)->send_cookie == 0) arc4random_buf(s->s3->client_random, SSL3_RANDOM_SIZE); - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &client_hello, + if (!ssl3_handshake_msg_start(s, &cbb, &client_hello, SSL3_MT_CLIENT_HELLO)) goto err; @@ -788,7 +775,7 @@ ssl3_send_client_hello(SSL *s) goto err; } - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_CW_CLNT_HELLO_B; @@ -1202,9 +1189,9 @@ err: } static int -ssl3_get_server_kex_dhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) +ssl3_get_server_kex_dhe(SSL *s, EVP_PKEY **pkey, CBS *cbs) { - CBS cbs, dhp, dhg, dhpk; + CBS dhp, dhg, dhpk; BN_CTX *bn_ctx = NULL; SESS_CERT *sc = NULL; DH *dh = NULL; @@ -1214,31 +1201,26 @@ ssl3_get_server_kex_dhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) alg_a = S3I(s)->hs.new_cipher->algorithm_auth; sc = SSI(s)->sess_cert; - if (*nn < 0) - goto err; - - CBS_init(&cbs, *pp, *nn); - if ((dh = DH_new()) == NULL) { SSLerror(s, ERR_R_DH_LIB); goto err; } - if (!CBS_get_u16_length_prefixed(&cbs, &dhp)) + if (!CBS_get_u16_length_prefixed(cbs, &dhp)) goto truncated; if ((dh->p = BN_bin2bn(CBS_data(&dhp), CBS_len(&dhp), NULL)) == NULL) { SSLerror(s, ERR_R_BN_LIB); goto err; } - if (!CBS_get_u16_length_prefixed(&cbs, &dhg)) + if (!CBS_get_u16_length_prefixed(cbs, &dhg)) goto truncated; if ((dh->g = BN_bin2bn(CBS_data(&dhg), CBS_len(&dhg), NULL)) == NULL) { SSLerror(s, ERR_R_BN_LIB); goto err; } - if (!CBS_get_u16_length_prefixed(&cbs, &dhpk)) + if (!CBS_get_u16_length_prefixed(cbs, &dhpk)) goto truncated; if ((dh->pub_key = BN_bin2bn(CBS_data(&dhpk), CBS_len(&dhpk), NULL)) == NULL) { @@ -1263,9 +1245,6 @@ ssl3_get_server_kex_dhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) sc->peer_dh_tmp = dh; - *nn = CBS_len(&cbs); - *pp = (unsigned char *)CBS_data(&cbs); - return (1); truncated: @@ -1366,9 +1345,9 @@ ssl3_get_server_kex_ecdhe_ecx(SSL *s, SESS_CERT *sc, int nid, CBS *public) } static int -ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) +ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, CBS *cbs) { - CBS cbs, public; + CBS public; uint8_t curve_type; uint16_t curve_id; SESS_CERT *sc; @@ -1379,15 +1358,10 @@ ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) alg_a = S3I(s)->hs.new_cipher->algorithm_auth; sc = SSI(s)->sess_cert; - if (*nn < 0) - goto err; - - CBS_init(&cbs, *pp, *nn); - /* Only named curves are supported. */ - if (!CBS_get_u8(&cbs, &curve_type) || + if (!CBS_get_u8(cbs, &curve_type) || curve_type != NAMED_CURVE_TYPE || - !CBS_get_u16(&cbs, &curve_id)) { + !CBS_get_u16(cbs, &curve_id)) { al = SSL_AD_DECODE_ERROR; SSLerror(s, SSL_R_LENGTH_TOO_SHORT); goto f_err; @@ -1409,7 +1383,7 @@ ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) goto f_err; } - if (!CBS_get_u8_length_prefixed(&cbs, &public)) + if (!CBS_get_u8_length_prefixed(cbs, &public)) goto truncated; if (nid == NID_X25519) { @@ -1433,9 +1407,6 @@ ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) /* XXX - Anonymous ECDH, so no certificate or pkey. */ *pkey = NULL; - *nn = CBS_len(&cbs); - *pp = (unsigned char *)CBS_data(&cbs); - return (1); truncated: @@ -1452,14 +1423,17 @@ ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn) int ssl3_get_server_key_exchange(SSL *s) { - unsigned char *q, md_buf[EVP_MAX_MD_SIZE*2]; - EVP_MD_CTX md_ctx; - unsigned char *param, *p; - int al, i, j, param_len, ok; - long n, alg_k, alg_a; - EVP_PKEY *pkey = NULL; - const EVP_MD *md = NULL; - RSA *rsa = NULL; + CBS cbs, signature; + const EVP_MD *md = NULL; + EVP_PKEY *pkey = NULL; + EVP_MD_CTX md_ctx; + const unsigned char *param; + uint8_t hash_id, sig_id; + long n, alg_k, alg_a; + int al, ok, sigalg; + size_t param_len; + + EVP_MD_CTX_init(&md_ctx); alg_k = S3I(s)->hs.new_cipher->algorithm_mkey; alg_a = S3I(s)->hs.new_cipher->algorithm_auth; @@ -1473,7 +1447,10 @@ ssl3_get_server_key_exchange(SSL *s) if (!ok) return ((int)n); - EVP_MD_CTX_init(&md_ctx); + if (n < 0) + goto err; + + CBS_init(&cbs, s->internal->init_msg, n); if (S3I(s)->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { /* @@ -1506,14 +1483,14 @@ ssl3_get_server_key_exchange(SSL *s) goto err; } - param = p = (unsigned char *)s->internal->init_msg; - param_len = n; + param = CBS_data(&cbs); + param_len = CBS_len(&cbs); if (alg_k & SSL_kDHE) { - if (ssl3_get_server_kex_dhe(s, &pkey, &p, &n) != 1) + if (ssl3_get_server_kex_dhe(s, &pkey, &cbs) != 1) goto err; } else if (alg_k & SSL_kECDHE) { - if (ssl3_get_server_kex_ecdhe(s, &pkey, &p, &n) != 1) + if (ssl3_get_server_kex_ecdhe(s, &pkey, &cbs) != 1) goto err; } else if (alg_k != 0) { al = SSL_AD_UNEXPECTED_MESSAGE; @@ -1521,93 +1498,62 @@ ssl3_get_server_key_exchange(SSL *s) goto f_err; } - param_len = param_len - n; + param_len -= CBS_len(&cbs); /* if it was signed, check the signature */ if (pkey != NULL) { if (SSL_USE_SIGALGS(s)) { - int sigalg = tls12_get_sigid(pkey); - /* Should never happen */ - if (sigalg == -1) { - SSLerror(s, ERR_R_INTERNAL_ERROR); - goto err; - } - /* - * Check key type is consistent - * with signature - */ - if (2 > n) + if (!CBS_get_u8(&cbs, &hash_id)) goto truncated; - if (sigalg != (int)p[1]) { - SSLerror(s, SSL_R_WRONG_SIGNATURE_TYPE); + if (!CBS_get_u8(&cbs, &sig_id)) + goto truncated; + + if ((md = tls12_get_hash(hash_id)) == NULL) { + SSLerror(s, SSL_R_UNKNOWN_DIGEST); al = SSL_AD_DECODE_ERROR; goto f_err; } - md = tls12_get_hash(p[0]); - if (md == NULL) { - SSLerror(s, SSL_R_UNKNOWN_DIGEST); + + /* Check key type is consistent with signature. */ + if ((sigalg = tls12_get_sigid(pkey)) == -1) { + /* Should never happen */ + SSLerror(s, ERR_R_INTERNAL_ERROR); + goto err; + } + if (sigalg != sig_id) { + SSLerror(s, SSL_R_WRONG_SIGNATURE_TYPE); al = SSL_AD_DECODE_ERROR; goto f_err; } - p += 2; - n -= 2; - } else + } else if (pkey->type == EVP_PKEY_RSA) { + md = EVP_md5_sha1(); + } else { md = EVP_sha1(); + } - if (2 > n) + if (!CBS_get_u16_length_prefixed(&cbs, &signature)) goto truncated; - n2s(p, i); - n -= 2; - j = EVP_PKEY_size(pkey); - - if (i != n || n > j) { - /* wrong packet length */ + if (CBS_len(&signature) > EVP_PKEY_size(pkey)) { al = SSL_AD_DECODE_ERROR; SSLerror(s, SSL_R_WRONG_SIGNATURE_LENGTH); goto f_err; } - if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) { - j = 0; - q = md_buf; - if (!EVP_DigestInit_ex(&md_ctx, EVP_md5_sha1(), NULL)) { - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - EVP_DigestUpdate(&md_ctx, s->s3->client_random, - SSL3_RANDOM_SIZE); - EVP_DigestUpdate(&md_ctx, s->s3->server_random, - SSL3_RANDOM_SIZE); - EVP_DigestUpdate(&md_ctx, param, param_len); - EVP_DigestFinal_ex(&md_ctx, q, (unsigned int *)&i); - q += i; - j += i; - i = RSA_verify(NID_md5_sha1, md_buf, j, - p, n, pkey->pkey.rsa); - if (i < 0) { - al = SSL_AD_DECRYPT_ERROR; - SSLerror(s, SSL_R_BAD_RSA_DECRYPT); - goto f_err; - } - if (i == 0) { - /* bad signature */ - al = SSL_AD_DECRYPT_ERROR; - SSLerror(s, SSL_R_BAD_SIGNATURE); - goto f_err; - } - } else { - EVP_VerifyInit_ex(&md_ctx, md, NULL); - EVP_VerifyUpdate(&md_ctx, s->s3->client_random, - SSL3_RANDOM_SIZE); - EVP_VerifyUpdate(&md_ctx, s->s3->server_random, - SSL3_RANDOM_SIZE); - EVP_VerifyUpdate(&md_ctx, param, param_len); - if (EVP_VerifyFinal(&md_ctx, p,(int)n, pkey) <= 0) { - /* bad signature */ - al = SSL_AD_DECRYPT_ERROR; - SSLerror(s, SSL_R_BAD_SIGNATURE); - goto f_err; - } + if (!EVP_VerifyInit_ex(&md_ctx, md, NULL)) + goto err; + if (!EVP_VerifyUpdate(&md_ctx, s->s3->client_random, + SSL3_RANDOM_SIZE)) + goto err; + if (!EVP_VerifyUpdate(&md_ctx, s->s3->server_random, + SSL3_RANDOM_SIZE)) + goto err; + if (!EVP_VerifyUpdate(&md_ctx, param, param_len)) + goto err; + if (EVP_VerifyFinal(&md_ctx, CBS_data(&signature), + CBS_len(&signature), pkey) <= 0) { + al = SSL_AD_DECRYPT_ERROR; + SSLerror(s, SSL_R_BAD_SIGNATURE); + goto f_err; } } else { /* aNULL does not need public keys. */ @@ -1615,12 +1561,12 @@ ssl3_get_server_key_exchange(SSL *s) SSLerror(s, ERR_R_INTERNAL_ERROR); goto err; } - /* still data left over */ - if (n != 0) { - al = SSL_AD_DECODE_ERROR; - SSLerror(s, SSL_R_EXTRA_DATA_IN_MESSAGE); - goto f_err; - } + } + + if (CBS_len(&cbs) != 0) { + al = SSL_AD_DECODE_ERROR; + SSLerror(s, SSL_R_EXTRA_DATA_IN_MESSAGE); + goto f_err; } EVP_PKEY_free(pkey); @@ -1629,7 +1575,6 @@ ssl3_get_server_key_exchange(SSL *s) return (1); truncated: - /* wrong packet length */ al = SSL_AD_DECODE_ERROR; SSLerror(s, SSL_R_BAD_PACKET_LENGTH); @@ -1638,7 +1583,6 @@ ssl3_get_server_key_exchange(SSL *s) err: EVP_PKEY_free(pkey); - RSA_free(rsa); EVP_MD_CTX_cleanup(&md_ctx); return (-1); @@ -2062,13 +2006,15 @@ ssl3_send_client_kex_dhe(SSL *s, SESS_CERT *sess_cert, CBB *cbb) SSLerror(s, ERR_R_DH_LIB); goto err; } - key_size = DH_size(dh_clnt); + if ((key_size = DH_size(dh_clnt)) <= 0) { + SSLerror(s, ERR_R_DH_LIB); + goto err; + } if ((key = malloc(key_size)) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } - key_len = DH_compute_key(key, dh_srvr->pub_key, dh_clnt); - if (key_len <= 0) { + if ((key_len = DH_compute_key(key, dh_srvr->pub_key, dh_clnt)) <= 0) { SSLerror(s, ERR_R_DH_LIB); goto err; } @@ -2126,7 +2072,7 @@ ssl3_send_client_kex_ecdhe_ecp(SSL *s, SESS_CERT *sc, CBB *cbb) } /* Generate a new ECDH key pair. */ - if (!(EC_KEY_generate_key(ecdh))) { + if (!EC_KEY_generate_key(ecdh)) { SSLerror(s, ERR_R_ECDH_LIB); goto err; } @@ -2136,6 +2082,7 @@ ssl3_send_client_kex_ecdhe_ecp(SSL *s, SESS_CERT *sc, CBB *cbb) } if ((key = malloc(key_size)) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); + goto err; } key_len = ECDH_compute_key(key, key_size, point, ecdh, NULL); if (key_len <= 0) { @@ -2296,7 +2243,7 @@ ssl3_send_client_kex_gost(SSL *s, SESS_CERT *sess_cert, CBB *cbb) /* * Compute shared IV and store it in algorithm-specific context data. */ - ukm_hash = EVP_MD_CTX_create(); + ukm_hash = EVP_MD_CTX_new(); if (ukm_hash == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; @@ -2311,7 +2258,7 @@ ssl3_send_client_kex_gost(SSL *s, SESS_CERT *sess_cert, CBB *cbb) EVP_DigestUpdate(ukm_hash, s->s3->client_random, SSL3_RANDOM_SIZE); EVP_DigestUpdate(ukm_hash, s->s3->server_random, SSL3_RANDOM_SIZE); EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len); - EVP_MD_CTX_destroy(ukm_hash); + EVP_MD_CTX_free(ukm_hash); if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_SET_IV, 8, shared_ukm) < 0) { SSLerror(s, SSL_R_LIBRARY_BUG); @@ -2374,7 +2321,7 @@ ssl3_send_client_key_exchange(SSL *s) goto err; } - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &kex, + if (!ssl3_handshake_msg_start(s, &cbb, &kex, SSL3_MT_CLIENT_KEY_EXCHANGE)) goto err; @@ -2397,7 +2344,7 @@ ssl3_send_client_key_exchange(SSL *s) goto err; } - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_CW_KEY_EXCH_B; @@ -2415,19 +2362,25 @@ err: int ssl3_send_client_verify(SSL *s) { - unsigned char *p; - unsigned char data[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; - EVP_PKEY *pkey; - EVP_PKEY_CTX *pctx = NULL; - EVP_MD_CTX mctx; - unsigned u = 0; - unsigned long n; - int j; + CBB cbb, cert_verify, cbb_signature; + unsigned char data[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; + unsigned char *signature = NULL; + unsigned int signature_len; + EVP_PKEY_CTX *pctx = NULL; + EVP_PKEY *pkey; + EVP_MD_CTX mctx; + const EVP_MD *md; + long hdatalen; + void *hdata; EVP_MD_CTX_init(&mctx); + memset(&cbb, 0, sizeof(cbb)); + if (S3I(s)->hs.state == SSL3_ST_CW_CERT_VRFY_A) { - p = ssl3_handshake_msg_start(s, SSL3_MT_CERTIFICATE_VERIFY); + if (!ssl3_handshake_msg_start(s, &cbb, &cert_verify, + SSL3_MT_CERTIFICATE_VERIFY)) + goto err; /* * Create context from key and test if sha1 is allowed as @@ -2441,6 +2394,9 @@ ssl3_send_client_verify(SSL *s) if (EVP_PKEY_CTX_set_signature_md(pctx, EVP_sha1()) <= 0) ERR_clear_error(); + if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL) + goto err; + if (!SSL_USE_SIGALGS(s)) { if (S3I(s)->handshake_buffer) { if (!tls1_digest_cached_records(s)) @@ -2456,55 +2412,44 @@ ssl3_send_client_verify(SSL *s) * using agreed digest and cached handshake records. */ if (SSL_USE_SIGALGS(s)) { - long hdatalen = 0; - void *hdata; - const EVP_MD *md = s->cert->key->digest; hdatalen = BIO_get_mem_data(S3I(s)->handshake_buffer, &hdata); + md = s->cert->key->digest; if (hdatalen <= 0 || - !tls12_get_sigandhash(p, pkey, md)) { + !tls12_get_hashandsig(&cert_verify, pkey, md)) { SSLerror(s, ERR_R_INTERNAL_ERROR); goto err; } - p += 2; if (!EVP_SignInit_ex(&mctx, md, NULL) || !EVP_SignUpdate(&mctx, hdata, hdatalen) || - !EVP_SignFinal(&mctx, p + 2, &u, pkey)) { + !EVP_SignFinal(&mctx, signature, &signature_len, + pkey)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } - s2n(u, p); - n = u + 4; if (!tls1_digest_cached_records(s)) goto err; } else if (pkey->type == EVP_PKEY_RSA) { if (RSA_sign(NID_md5_sha1, data, - MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, &(p[2]), - &u, pkey->pkey.rsa) <= 0 ) { + MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, signature, + &signature_len, pkey->pkey.rsa) <= 0 ) { SSLerror(s, ERR_R_RSA_LIB); goto err; } - s2n(u, p); - n = u + 2; } else if (pkey->type == EVP_PKEY_EC) { if (!ECDSA_sign(pkey->save_type, - &(data[MD5_DIGEST_LENGTH]), - SHA_DIGEST_LENGTH, &(p[2]), - (unsigned int *)&j, pkey->pkey.ec)) { + &data[MD5_DIGEST_LENGTH], SHA_DIGEST_LENGTH, + signature, &signature_len, pkey->pkey.ec)) { SSLerror(s, ERR_R_ECDSA_LIB); goto err; } - s2n(j, p); - n = j + 2; #ifndef OPENSSL_NO_GOST } else if (pkey->type == NID_id_GostR3410_94 || - pkey->type == NID_id_GostR3410_2001) { + pkey->type == NID_id_GostR3410_2001) { unsigned char signbuf[128]; - long hdatalen = 0; - void *hdata; - const EVP_MD *md; - int nid; + unsigned int u; size_t sigsize; + int nid; hdatalen = BIO_get_mem_data(S3I(s)->handshake_buffer, &hdata); if (hdatalen <= 0) { @@ -2521,38 +2466,47 @@ ssl3_send_client_verify(SSL *s) !EVP_DigestFinal(&mctx, signbuf, &u) || (EVP_PKEY_CTX_set_signature_md(pctx, md) <= 0) || (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_SIGN, - EVP_PKEY_CTRL_GOST_SIG_FORMAT, - GOST_SIG_FORMAT_RS_LE, - NULL) <= 0) || - (EVP_PKEY_sign(pctx, &(p[2]), &sigsize, - signbuf, u) <= 0)) { + EVP_PKEY_CTRL_GOST_SIG_FORMAT, + GOST_SIG_FORMAT_RS_LE, NULL) <= 0) || + (EVP_PKEY_sign(pctx, signature, &sigsize, + signbuf, u) <= 0)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } + if (sigsize > UINT_MAX) + goto err; + signature_len = sigsize; if (!tls1_digest_cached_records(s)) goto err; - j = sigsize; - s2n(j, p); - n = j + 2; #endif } else { SSLerror(s, ERR_R_INTERNAL_ERROR); goto err; } - S3I(s)->hs.state = SSL3_ST_CW_CERT_VRFY_B; + if (!CBB_add_u16_length_prefixed(&cert_verify, &cbb_signature)) + goto err; + if (!CBB_add_bytes(&cbb_signature, signature, signature_len)) + goto err; + + if (!ssl3_handshake_msg_finish(s, &cbb)) + goto err; - ssl3_handshake_msg_finish(s, n); + S3I(s)->hs.state = SSL3_ST_CW_CERT_VRFY_B; } EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_CTX_free(pctx); + free(signature); return (ssl3_handshake_write(s)); -err: + err: + CBB_cleanup(&cbb); EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_CTX_free(pctx); + free(signature); + return (-1); } @@ -2607,13 +2561,13 @@ ssl3_send_client_certificate(SSL *s) } if (S3I(s)->hs.state == SSL3_ST_CW_CERT_C) { - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &client_cert, + if (!ssl3_handshake_msg_start(s, &cbb, &client_cert, SSL3_MT_CERTIFICATE)) goto err; if (!ssl3_output_cert_chain(s, &client_cert, (S3I(s)->tmp.cert_req == 2) ? NULL : s->cert->key->x509)) goto err; - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_CW_CERT_D; diff --git a/lib/libssl/ssl_init.c b/lib/libssl/ssl_init.c index 0ef80956ed..b521d22d07 100644 --- a/lib/libssl/ssl_init.c +++ b/lib/libssl/ssl_init.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ssl_init.c,v 1.2 2018/03/30 14:59:46 jsing Exp $ */ /* * Copyright (c) 2018 Bob Beck * diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c index 573e63c934..d8415bcf6d 100644 --- a/lib/libssl/ssl_lib.c +++ b/lib/libssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.182 2018/03/17 16:20:01 beck Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.189 2018/09/05 16:58:59 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -191,9 +191,7 @@ SSL_clear(SSL *s) BUF_MEM_free(s->internal->init_buf); s->internal->init_buf = NULL; - ssl_clear_cipher_ctx(s); - ssl_clear_hash_ctx(&s->read_hash); - ssl_clear_hash_ctx(&s->internal->write_hash); + ssl_clear_cipher_state(s); s->internal->first_packet = 0; @@ -534,9 +532,7 @@ SSL_free(SSL *s) SSL_SESSION_free(s->session); } - ssl_clear_cipher_ctx(s); - ssl_clear_hash_ctx(&s->read_hash); - ssl_clear_hash_ctx(&s->internal->write_hash); + ssl_clear_cipher_state(s); ssl_cert_free(s->cert); @@ -809,7 +805,7 @@ SSL_pending(const SSL *s) * (Note that SSL_pending() is often used as a boolean value, * so we'd better not return -1.) */ - return (s->method->internal->ssl_pending(s)); + return (ssl3_pending(s)); } X509 * @@ -853,22 +849,21 @@ SSL_get_peer_cert_chain(const SSL *s) * Now in theory, since the calling process own 't' it should be safe to * modify. We need to be able to read f without being hassled */ -void +int SSL_copy_session_id(SSL *t, const SSL *f) { CERT *tmp; - /* Do we need to to SSL locking? */ - SSL_set_session(t, SSL_get_session(f)); + /* Do we need to do SSL locking? */ + if (!SSL_set_session(t, SSL_get_session(f))) + return 0; - /* - * What if we are setup as SSLv2 but want to talk SSLv3 or - * vice-versa. - */ + /* What if we are set up for one protocol but want to talk another? */ if (t->method != f->method) { - t->method->internal->ssl_free(t); /* cleanup current */ - t->method = f->method; /* change method */ - t->method->internal->ssl_new(t); /* setup new */ + t->method->internal->ssl_free(t); + t->method = f->method; + if (!t->method->internal->ssl_new(t)) + return 0; } tmp = t->cert; @@ -878,7 +873,11 @@ SSL_copy_session_id(SSL *t, const SSL *f) } else t->cert = NULL; ssl_cert_free(tmp); - SSL_set_session_id_context(t, f->sid_ctx, f->sid_ctx_length); + + if (!SSL_set_session_id_context(t, f->sid_ctx, f->sid_ctx_length)) + return 0; + + return 1; } /* Fix this so it checks all the valid key/cert options */ @@ -964,7 +963,7 @@ SSL_read(SSL *s, void *buf, int num) s->internal->rwstate = SSL_NOTHING; return (0); } - return (s->method->internal->ssl_read(s, buf, num)); + return ssl3_read(s, buf, num); } int @@ -978,7 +977,7 @@ SSL_peek(SSL *s, void *buf, int num) if (s->internal->shutdown & SSL_RECEIVED_SHUTDOWN) { return (0); } - return (s->method->internal->ssl_peek(s, buf, num)); + return ssl3_peek(s, buf, num); } int @@ -994,7 +993,7 @@ SSL_write(SSL *s, const void *buf, int num) SSLerror(s, SSL_R_PROTOCOL_IS_SHUTDOWN); return (-1); } - return (s->method->internal->ssl_write(s, buf, num)); + return ssl3_write(s, buf, num); } int @@ -1012,10 +1011,10 @@ SSL_shutdown(SSL *s) return (-1); } - if ((s != NULL) && !SSL_in_init(s)) - return (s->method->internal->ssl_shutdown(s)); - else - return (1); + if (s != NULL && !SSL_in_init(s)) + return (ssl3_shutdown(s)); + + return (1); } int @@ -1976,8 +1975,7 @@ SSL_CTX_free(SSL_CTX *ctx) #endif #ifndef OPENSSL_NO_ENGINE - if (ctx->internal->client_cert_engine) - ENGINE_finish(ctx->internal->client_cert_engine); + ENGINE_finish(ctx->internal->client_cert_engine); #endif free(ctx->internal->tlsext_ecpointformatlist); @@ -2429,10 +2427,7 @@ SSL_set_accept_state(SSL *s) s->internal->shutdown = 0; S3I(s)->hs.state = SSL_ST_ACCEPT|SSL_ST_BEFORE; s->internal->handshake_func = s->method->internal->ssl_accept; - /* clear the current cipher */ - ssl_clear_cipher_ctx(s); - ssl_clear_hash_ctx(&s->read_hash); - ssl_clear_hash_ctx(&s->internal->write_hash); + ssl_clear_cipher_state(s); } void @@ -2442,10 +2437,7 @@ SSL_set_connect_state(SSL *s) s->internal->shutdown = 0; S3I(s)->hs.state = SSL_ST_CONNECT|SSL_ST_BEFORE; s->internal->handshake_func = s->method->internal->ssl_connect; - /* clear the current cipher */ - ssl_clear_cipher_ctx(s); - ssl_clear_hash_ctx(&s->read_hash); - ssl_clear_hash_ctx(&s->internal->write_hash); + ssl_clear_cipher_state(s); } int @@ -2501,15 +2493,15 @@ SSL_dup(SSL *s) int i; if ((ret = SSL_new(SSL_get_SSL_CTX(s))) == NULL) - return (NULL); + goto err; ret->version = s->version; ret->internal->type = s->internal->type; ret->method = s->method; if (s->session != NULL) { - /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */ - SSL_copy_session_id(ret, s); + if (!SSL_copy_session_id(ret, s)) + goto err; } else { /* * No session has been established yet, so we have to expect @@ -2529,8 +2521,9 @@ SSL_dup(SSL *s) goto err; } - SSL_set_session_id_context(ret, - s->sid_ctx, s->sid_ctx_length); + if (!SSL_set_session_id_context(ret, s->sid_ctx, + s->sid_ctx_length)) + goto err; } ret->internal->options = s->internal->options; @@ -2613,34 +2606,47 @@ SSL_dup(SSL *s) } } - if (0) { -err: - if (ret != NULL) - SSL_free(ret); - ret = NULL; - } - return (ret); + return ret; + err: + SSL_free(ret); + return NULL; +} + +void +ssl_clear_cipher_state(SSL *s) +{ + ssl_clear_cipher_read_state(s); + ssl_clear_cipher_write_state(s); } void -ssl_clear_cipher_ctx(SSL *s) +ssl_clear_cipher_read_state(SSL *s) { EVP_CIPHER_CTX_free(s->enc_read_ctx); s->enc_read_ctx = NULL; - EVP_CIPHER_CTX_free(s->internal->enc_write_ctx); - s->internal->enc_write_ctx = NULL; + EVP_MD_CTX_free(s->read_hash); + s->read_hash = NULL; if (s->internal->aead_read_ctx != NULL) { EVP_AEAD_CTX_cleanup(&s->internal->aead_read_ctx->ctx); free(s->internal->aead_read_ctx); s->internal->aead_read_ctx = NULL; } +} + +void +ssl_clear_cipher_write_state(SSL *s) +{ + EVP_CIPHER_CTX_free(s->internal->enc_write_ctx); + s->internal->enc_write_ctx = NULL; + EVP_MD_CTX_free(s->internal->write_hash); + s->internal->write_hash = NULL; + if (s->internal->aead_write_ctx != NULL) { EVP_AEAD_CTX_cleanup(&s->internal->aead_write_ctx->ctx); free(s->internal->aead_write_ctx); s->internal->aead_write_ctx = NULL; } - } /* Fix this function so that it takes an optional type parameter */ @@ -2655,7 +2661,7 @@ SSL_get_certificate(const SSL *s) /* Fix this function so that it takes an optional type parameter */ EVP_PKEY * -SSL_get_privatekey(SSL *s) +SSL_get_privatekey(const SSL *s) { if (s->cert != NULL) return (s->cert->key->privatekey); @@ -3021,14 +3027,6 @@ SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, } void -ssl_clear_hash_ctx(EVP_MD_CTX **hash) -{ - if (*hash) - EVP_MD_CTX_destroy(*hash); - *hash = NULL; -} - -void SSL_set_debug(SSL *s, int debug) { s->internal->debug = debug; diff --git a/lib/libssl/ssl_locl.h b/lib/libssl/ssl_locl.h index d2a99afaa4..d022d21568 100644 --- a/lib/libssl/ssl_locl.h +++ b/lib/libssl/ssl_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_locl.h,v 1.202 2018/01/27 15:30:05 jsing Exp $ */ +/* $OpenBSD: ssl_locl.h,v 1.215 2018/09/08 14:29:52 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -181,15 +181,9 @@ __BEGIN_HIDDEN_DECLS *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) -#define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \ - (((unsigned int)(c[1])) )),c+=2) #define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \ c[1]=(unsigned char)(((s) )&0xff)),c+=2) -#define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \ - c[1]=(unsigned char)(((l)>> 8)&0xff), \ - c[2]=(unsigned char)(((l) )&0xff)),c+=3) - /* LOCAL STUFF */ #define SSL_DECRYPT 0 @@ -270,10 +264,6 @@ __BEGIN_HIDDEN_DECLS #define SSL_HANDSHAKE_MAC_STREEBOG256 0x200 #define SSL_HANDSHAKE_MAC_DEFAULT (SSL_HANDSHAKE_MAC_MD5 | SSL_HANDSHAKE_MAC_SHA) -/* When adding new digest in the ssl_ciph.c and increment SSM_MD_NUM_IDX - * make sure to update this constant too */ -#define SSL_MAX_DIGEST 7 - #define SSL3_CK_ID 0x03000000 #define SSL3_CK_VALUE_MASK 0x0000ffff @@ -288,8 +278,10 @@ __BEGIN_HIDDEN_DECLS #define TLS1_PRF_STREEBOG256 (SSL_HANDSHAKE_MAC_STREEBOG256 << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF (TLS1_PRF_MD5 | TLS1_PRF_SHA1) -/* Stream MAC for GOST ciphersuites from cryptopro draft - * (currently this also goes into algorithm2) */ +/* + * Stream MAC for GOST ciphersuites from cryptopro draft + * (currently this also goes into algorithm2). + */ #define TLS1_STREAM_MAC 0x04 /* @@ -300,14 +292,8 @@ __BEGIN_HIDDEN_DECLS #define SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD (1 << 22) /* - * SSL_CIPHER_ALGORITHM2_AEAD is an algorithm2 flag that indicates the cipher - * is implemented via an EVP_AEAD. - */ -#define SSL_CIPHER_ALGORITHM2_AEAD (1 << 23) - -/* * SSL_CIPHER_AEAD_FIXED_NONCE_LEN returns the number of bytes of fixed nonce - * for an SSL_CIPHER with the SSL_CIPHER_ALGORITHM2_AEAD flag. + * for an SSL_CIPHER with an algorithm_mac of SSL_AEAD. */ #define SSL_CIPHER_AEAD_FIXED_NONCE_LEN(ssl_cipher) \ (((ssl_cipher->algorithm2 >> 24) & 0xf) * 2) @@ -385,10 +371,6 @@ typedef struct ssl_method_internal_st { int (*ssl_accept)(SSL *s); int (*ssl_connect)(SSL *s); - int (*ssl_read)(SSL *s, void *buf, int len); - int (*ssl_peek)(SSL *s, void *buf, int len); - int (*ssl_write)(SSL *s, const void *buf, int len); - int (*ssl_shutdown)(SSL *s); int (*ssl_renegotiate)(SSL *s); int (*ssl_renegotiate_check)(SSL *s); @@ -399,7 +381,6 @@ typedef struct ssl_method_internal_st { int len, int peek); int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); - int (*ssl_pending)(const SSL *s); const struct ssl_method_st *(*get_ssl_method)(int version); long (*get_timeout)(void); @@ -463,7 +444,7 @@ typedef struct ssl_ctx_internal_st { int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess); void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess); SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, - unsigned char *data, int len, int *copy); + const unsigned char *data, int len, int *copy); /* if defined, these override the X509_verify_cert() calls */ int (*app_verify_callback)(X509_STORE_CTX *, void *); @@ -477,7 +458,7 @@ typedef struct ssl_ctx_internal_st { unsigned int *cookie_len); /* verify cookie callback */ - int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, + int (*app_verify_cookie_cb)(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len); void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */ @@ -760,8 +741,6 @@ typedef struct ssl_internal_st { } SSL_INTERNAL; typedef struct ssl3_state_internal_st { - int delay_buf_pop_ret; - unsigned char read_sequence[SSL3_SEQUENCE_SIZE]; int read_mac_secret_size; unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; @@ -1052,7 +1031,9 @@ extern SSL3_ENC_METHOD TLSv1_enc_data; extern SSL3_ENC_METHOD TLSv1_1_enc_data; extern SSL3_ENC_METHOD TLSv1_2_enc_data; -void ssl_clear_cipher_ctx(SSL *s); +void ssl_clear_cipher_state(SSL *s); +void ssl_clear_cipher_read_state(SSL *s); +void ssl_clear_cipher_write_state(SSL *s); int ssl_clear_bad_session(SSL *s); CERT *ssl_cert_new(void); CERT *ssl_cert_dup(CERT *cert); @@ -1061,10 +1042,11 @@ void ssl_cert_free(CERT *c); SESS_CERT *ssl_sess_cert_new(void); void ssl_sess_cert_free(SESS_CERT *sc); int ssl_get_new_session(SSL *s, int session); -int ssl_get_prev_session(SSL *s, unsigned char *session, int len, - const unsigned char *limit); +int ssl_get_prev_session(SSL *s, const unsigned char *session_id, + int session_id_len, CBS *ext_block); int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b); -SSL_CIPHER *OBJ_bsearch_ssl_cipher_id(SSL_CIPHER *key, SSL_CIPHER const *base, int num); +SSL_CIPHER *OBJ_bsearch_ssl_cipher_id(SSL_CIPHER *key, SSL_CIPHER const *base, + int num); int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, const SSL_CIPHER * const *bp); int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *ciphers, CBB *cbb); @@ -1093,6 +1075,8 @@ int ssl_has_ecc_ciphers(SSL *s); int ssl_verify_alarm_type(long type); void ssl_load_ciphers(void); +int SSL_SESSION_ticket(SSL_SESSION *ss, unsigned char **out, size_t *out_len); + const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); int ssl3_send_server_certificate(SSL *s); @@ -1142,11 +1126,9 @@ long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp)(void)); int ssl3_pending(const SSL *s); int ssl3_handshake_msg_hdr_len(SSL *s); -unsigned char *ssl3_handshake_msg_start(SSL *s, uint8_t htype); -void ssl3_handshake_msg_finish(SSL *s, unsigned int len); -int ssl3_handshake_msg_start_cbb(SSL *s, CBB *handshake, CBB *body, +int ssl3_handshake_msg_start(SSL *s, CBB *handshake, CBB *body, uint8_t msg_type); -int ssl3_handshake_msg_finish_cbb(SSL *s, CBB *handshake); +int ssl3_handshake_msg_finish(SSL *s, CBB *handshake); int ssl3_handshake_write(SSL *s); int ssl3_record_write(SSL *s, int type); @@ -1231,7 +1213,6 @@ int dtls1_new(SSL *s); void dtls1_free(SSL *s); void dtls1_clear(SSL *s); long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); -int dtls1_shutdown(SSL *s); long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); int dtls1_get_record(SSL *s); @@ -1285,14 +1266,13 @@ int ssl_check_clienthello_tlsext_late(SSL *s); int ssl_check_serverhello_tlsext(SSL *s); #define tlsext_tick_md EVP_sha256 -int tls1_process_ticket(SSL *s, const unsigned char *session_id, int len, - const unsigned char *limit, SSL_SESSION **ret); -int tls12_get_sigandhash(unsigned char *p, const EVP_PKEY *pk, - const EVP_MD *md); +int tls1_process_ticket(SSL *s, const unsigned char *session_id, + int session_id_len, CBS *ext_block, SSL_SESSION **ret); +int tls12_get_hashid(const EVP_MD *md); int tls12_get_sigid(const EVP_PKEY *pk); +int tls12_get_hashandsig(CBB *cbb, const EVP_PKEY *pk, const EVP_MD *md); const EVP_MD *tls12_get_hash(unsigned char hash_alg); -void ssl_clear_hash_ctx(EVP_MD_CTX **hash); long ssl_get_algorithm2(SSL *s); int tls1_process_sigalgs(SSL *s, CBS *cbs); void tls12_get_req_sig_algs(SSL *s, unsigned char **sigalgs, diff --git a/lib/libssl/ssl_pkt.c b/lib/libssl/ssl_pkt.c index 163b0292af..4e3ac7722a 100644 --- a/lib/libssl/ssl_pkt.c +++ b/lib/libssl/ssl_pkt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_pkt.c,v 1.12 2017/05/07 04:22:24 beck Exp $ */ +/* $OpenBSD: ssl_pkt.c,v 1.13 2018/09/08 14:39:41 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -739,6 +739,7 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, p += 2; /* Explicit IV length. */ + eivlen = 0; if (s->internal->enc_write_ctx && SSL_USE_EXPLICIT_IV(s)) { int mode = EVP_CIPHER_CTX_mode(s->internal->enc_write_ctx); if (mode == EVP_CIPH_CBC_MODE) { @@ -746,16 +747,10 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, if (eivlen <= 1) eivlen = 0; } - /* Need explicit part of IV for GCM mode */ - else if (mode == EVP_CIPH_GCM_MODE) - eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN; - else - eivlen = 0; } else if (s->internal->aead_write_ctx != NULL && s->internal->aead_write_ctx->variable_nonce_in_record) { eivlen = s->internal->aead_write_ctx->variable_nonce_len; - } else - eivlen = 0; + } /* lets setup the record stuff. */ wr->data = p + eivlen; diff --git a/lib/libssl/ssl_rsa.c b/lib/libssl/ssl_rsa.c index e99ce1e3ae..631aaa5077 100644 --- a/lib/libssl/ssl_rsa.c +++ b/lib/libssl/ssl_rsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_rsa.c,v 1.28 2017/02/07 02:08:38 beck Exp $ */ +/* $OpenBSD: ssl_rsa.c,v 1.29 2018/04/25 07:10:39 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -133,7 +133,7 @@ SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len) X509 *x; int ret; - x = d2i_X509(NULL, &d,(long)len); + x = d2i_X509(NULL, &d, (long)len); if (x == NULL) { SSLerror(ssl, ERR_R_ASN1_LIB); return (0); @@ -254,14 +254,12 @@ end: } int -SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len) +SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d, long len) { int ret; - const unsigned char *p; RSA *rsa; - p = d; - if ((rsa = d2i_RSAPrivateKey(NULL, &p,(long)len)) == NULL) { + if ((rsa = d2i_RSAPrivateKey(NULL, &d, (long)len)) == NULL) { SSLerror(ssl, ERR_R_ASN1_LIB); return (0); } @@ -332,11 +330,9 @@ int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, const unsigned char *d, long len) { int ret; - const unsigned char *p; EVP_PKEY *pkey; - p = d; - if ((pkey = d2i_PrivateKey(type, NULL, &p,(long)len)) == NULL) { + if ((pkey = d2i_PrivateKey(type, NULL, &d, (long)len)) == NULL) { SSLerror(ssl, ERR_R_ASN1_LIB); return (0); } @@ -465,7 +461,7 @@ SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d) X509 *x; int ret; - x = d2i_X509(NULL, &d,(long)len); + x = d2i_X509(NULL, &d, (long)len); if (x == NULL) { SSLerrorx(ERR_R_ASN1_LIB); return (0); @@ -547,11 +543,9 @@ int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len) { int ret; - const unsigned char *p; RSA *rsa; - p = d; - if ((rsa = d2i_RSAPrivateKey(NULL, &p,(long)len)) == NULL) { + if ((rsa = d2i_RSAPrivateKey(NULL, &d, (long)len)) == NULL) { SSLerrorx(ERR_R_ASN1_LIB); return (0); } @@ -620,11 +614,9 @@ SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, const unsigned char *d, long len) { int ret; - const unsigned char *p; EVP_PKEY *pkey; - p = d; - if ((pkey = d2i_PrivateKey(type, NULL, &p,(long)len)) == NULL) { + if ((pkey = d2i_PrivateKey(type, NULL, &d, (long)len)) == NULL) { SSLerrorx(ERR_R_ASN1_LIB); return (0); } diff --git a/lib/libssl/ssl_sess.c b/lib/libssl/ssl_sess.c index b3ee7ef430..52a1a0cc47 100644 --- a/lib/libssl/ssl_sess.c +++ b/lib/libssl/ssl_sess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sess.c,v 1.79 2018/03/20 15:28:12 tb Exp $ */ +/* $OpenBSD: ssl_sess.c,v 1.81 2018/08/24 18:10:25 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -420,8 +420,8 @@ sess_id_done: * session_id: points at the session ID in the ClientHello. This code will * read past the end of this in order to parse out the session ticket * extension, if any. - * len: the length of the session ID. - * limit: a pointer to the first byte after the ClientHello. + * session_id_len: the length of the session ID. + * ext_block: a CBS for the ClientHello extensions block. * * Returns: * -1: error @@ -435,8 +435,8 @@ sess_id_done: * to 1 if the server should issue a new session ticket (to 0 otherwise). */ int -ssl_get_prev_session(SSL *s, unsigned char *session_id, int len, - const unsigned char *limit) +ssl_get_prev_session(SSL *s, const unsigned char *session_id, + int session_id_len, CBS *ext_block) { SSL_SESSION *ret = NULL; int fatal = 0; @@ -445,14 +445,14 @@ ssl_get_prev_session(SSL *s, unsigned char *session_id, int len, /* This is used only by servers. */ - if (len > SSL_MAX_SSL_SESSION_ID_LENGTH) + if (session_id_len > SSL_MAX_SSL_SESSION_ID_LENGTH) goto err; - if (len == 0) + if (session_id_len == 0) try_session_cache = 0; /* Sets s->internal->tlsext_ticket_expected. */ - r = tls1_process_ticket(s, session_id, len, limit, &ret); + r = tls1_process_ticket(s, session_id, session_id_len, ext_block, &ret); switch (r) { case -1: /* Error during processing */ fatal = 1; @@ -473,8 +473,8 @@ ssl_get_prev_session(SSL *s, unsigned char *session_id, int len, SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) { SSL_SESSION data; data.ssl_version = s->version; - data.session_id_length = len; - memcpy(data.session_id, session_id, len); + data.session_id_length = session_id_len; + memcpy(data.session_id, session_id, session_id_len); CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); ret = lh_SSL_SESSION_retrieve(s->session_ctx->internal->sessions, &data); @@ -494,7 +494,7 @@ ssl_get_prev_session(SSL *s, unsigned char *session_id, int len, int copy = 1; if ((ret = s->session_ctx->internal->get_session_cb(s, - session_id, len, ©))) { + session_id, session_id_len, ©))) { s->session_ctx->internal->stats.sess_cb_hit++; /* @@ -1092,13 +1092,13 @@ void void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*cb)(struct ssl_st *ssl, - unsigned char *data, int len, int *copy)) + const unsigned char *data, int len, int *copy)) { ctx->internal->get_session_cb = cb; } SSL_SESSION * -(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, +(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(SSL *ssl, const unsigned char *data, int len, int *copy) { return ctx->internal->get_session_cb; @@ -1158,7 +1158,7 @@ SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, - int (*cb)(SSL *ssl, unsigned char *cookie, unsigned int cookie_len)) + int (*cb)(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len)) { ctx->internal->app_verify_cookie_cb = cb; } diff --git a/lib/libssl/ssl_srvr.c b/lib/libssl/ssl_srvr.c index f1a0c9ae03..e046438cc0 100644 --- a/lib/libssl/ssl_srvr.c +++ b/lib/libssl/ssl_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_srvr.c,v 1.28 2018/01/28 09:21:34 inoguchi Exp $ */ +/* $OpenBSD: ssl_srvr.c,v 1.48 2018/08/27 17:04:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -784,10 +784,10 @@ ssl3_send_hello_request(SSL *s) memset(&cbb, 0, sizeof(cbb)); if (S3I(s)->hs.state == SSL3_ST_SW_HELLO_REQ_A) { - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &hello, + if (!ssl3_handshake_msg_start(s, &cbb, &hello, SSL3_MT_HELLO_REQUEST)) goto err; - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_SW_HELLO_REQ_B; @@ -818,7 +818,6 @@ ssl3_get_client_hello(SSL *s) unsigned long alg_k; const SSL_METHOD *method; uint16_t shared_version; - unsigned char *end; /* * We do this so that we will respond with our native type. @@ -842,17 +841,28 @@ ssl3_get_client_hello(SSL *s) if (n < 0) goto err; - end = (unsigned char *)s->internal->init_msg + n; - CBS_init(&cbs, s->internal->init_msg, n); + /* Parse client hello up until the extensions (if any). */ + if (!CBS_get_u16(&cbs, &client_version)) + goto truncated; + if (!CBS_get_bytes(&cbs, &client_random, SSL3_RANDOM_SIZE)) + goto truncated; + if (!CBS_get_u8_length_prefixed(&cbs, &session_id)) + goto truncated; + if (SSL_IS_DTLS(s)) { + if (!CBS_get_u8_length_prefixed(&cbs, &cookie)) + goto truncated; + } + if (!CBS_get_u16_length_prefixed(&cbs, &cipher_suites)) + goto truncated; + if (!CBS_get_u8_length_prefixed(&cbs, &compression_methods)) + goto truncated; + /* * Use version from inside client hello, not from record header. * (may differ: see RFC 2246, Appendix E, second paragraph) */ - if (!CBS_get_u16(&cbs, &client_version)) - goto truncated; - if (ssl_max_shared_version(s, client_version, &shared_version) != 1) { SSLerror(s, SSL_R_WRONG_VERSION_NUMBER); if ((s->client_version >> 8) == SSL3_VERSION_MAJOR && @@ -877,19 +887,12 @@ ssl3_get_client_hello(SSL *s) } s->method = method; - if (!CBS_get_bytes(&cbs, &client_random, SSL3_RANDOM_SIZE)) - goto truncated; - if (!CBS_get_u8_length_prefixed(&cbs, &session_id)) - goto truncated; - /* - * If we require cookies (DTLS) and this ClientHello doesn't - * contain one, just return since we do not want to - * allocate any memory yet. So check cookie length... + * If we require cookies (DTLS) and this ClientHello does not contain + * one, just return since we do not want to allocate any memory yet. + * So check cookie length... */ if (SSL_IS_DTLS(s)) { - if (!CBS_get_u8_length_prefixed(&cbs, &cookie)) - goto truncated; if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { if (CBS_len(&cookie) == 0) return (1); @@ -922,10 +925,12 @@ ssl3_get_client_hello(SSL *s) if (!ssl_get_new_session(s, 1)) goto err; } else { - /* XXX - pass CBS through instead... */ - i = ssl_get_prev_session(s, - (unsigned char *)CBS_data(&session_id), - CBS_len(&session_id), end); + CBS ext_block; + + CBS_dup(&cbs, &ext_block); + + i = ssl_get_prev_session(s, CBS_data(&session_id), + CBS_len(&session_id), &ext_block); if (i == 1) { /* previous session */ s->internal->hit = 1; } else if (i == -1) @@ -979,9 +984,6 @@ ssl3_get_client_hello(SSL *s) } } - if (!CBS_get_u16_length_prefixed(&cbs, &cipher_suites)) - goto truncated; - /* XXX - This logic seems wrong... */ if (CBS_len(&cipher_suites) == 0 && CBS_len(&session_id) != 0) { /* we need a cipher if we are not resuming a session */ @@ -1020,9 +1022,6 @@ ssl3_get_client_hello(SSL *s) } } - if (!CBS_get_u8_length_prefixed(&cbs, &compression_methods)) - goto truncated; - comp_null = 0; while (CBS_len(&compression_methods) > 0) { if (!CBS_get_u8(&compression_methods, &comp_method)) @@ -1175,7 +1174,7 @@ ssl3_send_server_hello(SSL *s) memset(&cbb, 0, sizeof(cbb)); if (S3I(s)->hs.state == SSL3_ST_SW_SRVR_HELLO_A) { - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &server_hello, + if (!ssl3_handshake_msg_start(s, &cbb, &server_hello, SSL3_MT_SERVER_HELLO)) goto err; @@ -1232,7 +1231,7 @@ ssl3_send_server_hello(SSL *s) goto err; } - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; } @@ -1253,10 +1252,10 @@ ssl3_send_server_done(SSL *s) memset(&cbb, 0, sizeof(cbb)); if (S3I(s)->hs.state == SSL3_ST_SW_SRVR_DONE_A) { - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &done, + if (!ssl3_handshake_msg_start(s, &cbb, &done, SSL3_MT_SERVER_DONE)) goto err; - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_SW_SRVR_DONE_B; @@ -1271,7 +1270,7 @@ ssl3_send_server_done(SSL *s) return (-1); } -int +static int ssl3_send_server_kex_dhe(SSL *s, CBB *cbb) { CBB dh_p, dh_g, dh_Ys; @@ -1501,36 +1500,37 @@ ssl3_send_server_kex_ecdhe(SSL *s, CBB *cbb) int ssl3_send_server_key_exchange(SSL *s) { - CBB cbb; + CBB cbb, cbb_params, cbb_signature, server_kex; + unsigned char *signature = NULL; + unsigned int signature_len; unsigned char *params = NULL; size_t params_len; - unsigned char *q; - unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; - unsigned int u; - EVP_PKEY *pkey; const EVP_MD *md = NULL; - unsigned char *p, *d; - int al, i, j, n, kn; unsigned long type; - BUF_MEM *buf; EVP_MD_CTX md_ctx; + EVP_PKEY *pkey; + int al; memset(&cbb, 0, sizeof(cbb)); + memset(&cbb_params, 0, sizeof(cbb_params)); EVP_MD_CTX_init(&md_ctx); + if (S3I(s)->hs.state == SSL3_ST_SW_KEY_EXCH_A) { - type = S3I(s)->hs.new_cipher->algorithm_mkey; - buf = s->internal->init_buf; + if (!ssl3_handshake_msg_start(s, &cbb, &server_kex, + SSL3_MT_SERVER_KEY_EXCHANGE)) + goto err; - if (!CBB_init(&cbb, 0)) + if (!CBB_init(&cbb_params, 0)) goto err; + type = S3I(s)->hs.new_cipher->algorithm_mkey; if (type & SSL_kDHE) { - if (ssl3_send_server_kex_dhe(s, &cbb) != 1) + if (ssl3_send_server_kex_dhe(s, &cbb_params) != 1) goto err; } else if (type & SSL_kECDHE) { - if (ssl3_send_server_kex_ecdhe(s, &cbb) != 1) + if (ssl3_send_server_kex_ecdhe(s, &cbb_params) != 1) goto err; } else { al = SSL_AD_HANDSHAKE_FAILURE; @@ -1538,117 +1538,87 @@ ssl3_send_server_key_exchange(SSL *s) goto f_err; } - if (!CBB_finish(&cbb, ¶ms, ¶ms_len)) + if (!CBB_finish(&cbb_params, ¶ms, ¶ms_len)) + goto err; + + if (!CBB_add_bytes(&server_kex, params, params_len)) goto err; + /* Add signature unless anonymous. */ if (!(S3I(s)->hs.new_cipher->algorithm_auth & SSL_aNULL)) { - if ((pkey = ssl_get_sign_pkey( - s, S3I(s)->hs.new_cipher, &md)) == NULL) { + if ((pkey = ssl_get_sign_pkey(s, S3I(s)->hs.new_cipher, + &md)) == NULL) { al = SSL_AD_DECODE_ERROR; goto f_err; } - kn = EVP_PKEY_size(pkey); - } else { - pkey = NULL; - kn = 0; - } - if (!BUF_MEM_grow_clean(buf, ssl3_handshake_msg_hdr_len(s) + - params_len + kn)) { - SSLerror(s, ERR_LIB_BUF); - goto err; - } - - d = p = ssl3_handshake_msg_start(s, - SSL3_MT_SERVER_KEY_EXCHANGE); - - memcpy(p, params, params_len); - - free(params); - params = NULL; - - n = params_len; - p += params_len; - - /* not anonymous */ - if (pkey != NULL) { - /* - * n is the length of the params, they start at &(d[4]) - * and p points to the space at the end. - */ - if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) { - q = md_buf; - j = 0; - if (!EVP_DigestInit_ex(&md_ctx, EVP_md5_sha1(), - NULL)) - goto err; - EVP_DigestUpdate(&md_ctx, s->s3->client_random, - SSL3_RANDOM_SIZE); - EVP_DigestUpdate(&md_ctx, s->s3->server_random, - SSL3_RANDOM_SIZE); - EVP_DigestUpdate(&md_ctx, d, n); - EVP_DigestFinal_ex(&md_ctx, q, - (unsigned int *)&i); - q += i; - j += i; - if (RSA_sign(NID_md5_sha1, md_buf, j, - &(p[2]), &u, pkey->pkey.rsa) <= 0) { - SSLerror(s, ERR_R_RSA_LIB); - goto err; - } - s2n(u, p); - n += u + 2; - } else if (md) { - /* Send signature algorithm. */ - if (SSL_USE_SIGALGS(s)) { - if (!tls12_get_sigandhash(p, pkey, md)) { - /* Should never happen */ - al = SSL_AD_INTERNAL_ERROR; - SSLerror(s, ERR_R_INTERNAL_ERROR); - goto f_err; - } - p += 2; - } - EVP_SignInit_ex(&md_ctx, md, NULL); - EVP_SignUpdate(&md_ctx, - s->s3->client_random, - SSL3_RANDOM_SIZE); - EVP_SignUpdate(&md_ctx, - s->s3->server_random, - SSL3_RANDOM_SIZE); - EVP_SignUpdate(&md_ctx, d, n); - if (!EVP_SignFinal(&md_ctx, &p[2], - (unsigned int *)&i, pkey)) { - SSLerror(s, ERR_R_EVP_LIB); - goto err; - } - s2n(i, p); - n += i + 2; - if (SSL_USE_SIGALGS(s)) - n += 2; - } else { + if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) + md = EVP_md5_sha1(); + + if (md == NULL) { /* Is this error check actually needed? */ al = SSL_AD_HANDSHAKE_FAILURE; SSLerror(s, SSL_R_UNKNOWN_PKEY_TYPE); goto f_err; } + + /* Send signature algorithm. */ + if (SSL_USE_SIGALGS(s)) { + if (!tls12_get_hashandsig(&server_kex, pkey, md)) { + /* Should never happen */ + al = SSL_AD_INTERNAL_ERROR; + SSLerror(s, ERR_R_INTERNAL_ERROR); + goto f_err; + } + } + + if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL) + goto err; + + if (!EVP_SignInit_ex(&md_ctx, md, NULL)) + goto err; + if (!EVP_SignUpdate(&md_ctx, s->s3->client_random, + SSL3_RANDOM_SIZE)) + goto err; + if (!EVP_SignUpdate(&md_ctx, s->s3->server_random, + SSL3_RANDOM_SIZE)) + goto err; + if (!EVP_SignUpdate(&md_ctx, params, params_len)) + goto err; + if (!EVP_SignFinal(&md_ctx, signature, &signature_len, + pkey)) { + SSLerror(s, ERR_R_EVP_LIB); + goto err; + } + + if (!CBB_add_u16_length_prefixed(&server_kex, + &cbb_signature)) + goto err; + if (!CBB_add_bytes(&cbb_signature, signature, + signature_len)) + goto err; } - ssl3_handshake_msg_finish(s, n); - } + if (!ssl3_handshake_msg_finish(s, &cbb)) + goto err; - S3I(s)->hs.state = SSL3_ST_SW_KEY_EXCH_B; + S3I(s)->hs.state = SSL3_ST_SW_KEY_EXCH_B; + } EVP_MD_CTX_cleanup(&md_ctx); + free(params); + free(signature); return (ssl3_handshake_write(s)); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: - free(params); - EVP_MD_CTX_cleanup(&md_ctx); + CBB_cleanup(&cbb_params); CBB_cleanup(&cbb); + EVP_MD_CTX_cleanup(&md_ctx); + free(params); + free(signature); return (-1); } @@ -1668,7 +1638,7 @@ ssl3_send_certificate_request(SSL *s) memset(&cbb, 0, sizeof(cbb)); if (S3I(s)->hs.state == SSL3_ST_SW_CERT_REQ_A) { - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &cert_request, + if (!ssl3_handshake_msg_start(s, &cbb, &cert_request, SSL3_MT_CERTIFICATE_REQUEST)) goto err; @@ -1708,7 +1678,7 @@ ssl3_send_certificate_request(SSL *s) goto err; } - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_SW_CERT_REQ_B; @@ -1724,15 +1694,17 @@ ssl3_send_certificate_request(SSL *s) } static int -ssl3_get_client_kex_rsa(SSL *s, unsigned char *p, long n) +ssl3_get_client_kex_rsa(SSL *s, CBS *cbs) { unsigned char fakekey[SSL_MAX_MASTER_KEY_LENGTH]; - unsigned char *d; - RSA *rsa = NULL; + unsigned char *pms = NULL; + unsigned char *p; + size_t pms_len = 0; EVP_PKEY *pkey = NULL; - int i, al; - - d = p; + RSA *rsa = NULL; + CBS enc_pms; + int decrypt_len; + int al = -1; arc4random_buf(fakekey, sizeof(fakekey)); fakekey[0] = s->client_version >> 8; @@ -1747,61 +1719,48 @@ ssl3_get_client_kex_rsa(SSL *s, unsigned char *p, long n) } rsa = pkey->pkey.rsa; - if (2 > n) + pms_len = RSA_size(rsa); + if (pms_len < SSL_MAX_MASTER_KEY_LENGTH) + goto err; + if ((pms = malloc(pms_len)) == NULL) + goto err; + p = pms; + + if (!CBS_get_u16_length_prefixed(cbs, &enc_pms)) goto truncated; - n2s(p, i); - if (n != i + 2) { + if (CBS_len(cbs) != 0 || CBS_len(&enc_pms) != RSA_size(rsa)) { SSLerror(s, SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG); goto err; - } else - n = i; + } - i = RSA_private_decrypt((int)n, p, p, rsa, RSA_PKCS1_PADDING); + decrypt_len = RSA_private_decrypt(CBS_len(&enc_pms), CBS_data(&enc_pms), + pms, rsa, RSA_PKCS1_PADDING); ERR_clear_error(); - al = -1; - - if (i != SSL_MAX_MASTER_KEY_LENGTH) { + if (decrypt_len != SSL_MAX_MASTER_KEY_LENGTH) { al = SSL_AD_DECODE_ERROR; /* SSLerror(s, SSL_R_BAD_RSA_DECRYPT); */ } - if (p - d + 2 > n) /* needed in the SSL3 case */ - goto truncated; - if ((al == -1) && !((p[0] == (s->client_version >> 8)) && - (p[1] == (s->client_version & 0xff)))) { + if ((al == -1) && !((pms[0] == (s->client_version >> 8)) && + (pms[1] == (s->client_version & 0xff)))) { /* - * The premaster secret must contain the same version - * number as the ClientHello to detect version rollback - * attacks (strangely, the protocol does not offer such - * protection for DH ciphersuites). - * However, buggy clients exist that send the negotiated - * protocol version instead if the server does not - * support the requested protocol version. - * If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such - * clients. + * The premaster secret must contain the same version number + * as the ClientHello to detect version rollback attacks + * (strangely, the protocol does not offer such protection for + * DH ciphersuites). + * + * The Klima-Pokorny-Rosa extension of Bleichenbacher's attack + * (http://eprint.iacr.org/2003/052/) exploits the version + * number check as a "bad version oracle" -- an alert would + * reveal that the plaintext corresponding to some ciphertext + * made up by the adversary is properly formatted except that + * the version number is wrong. To avoid such attacks, we should + * treat this just like any other decryption error. */ - if (!((s->internal->options & SSL_OP_TLS_ROLLBACK_BUG) && - (p[0] == (s->version >> 8)) && - (p[1] == (s->version & 0xff)))) { - al = SSL_AD_DECODE_ERROR; - /* SSLerror(s, SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */ - - /* - * The Klima-Pokorny-Rosa extension of - * Bleichenbacher's attack - * (http://eprint.iacr.org/2003/052/) exploits - * the version number check as a "bad version - * oracle" -- an alert would reveal that the - * plaintext corresponding to some ciphertext - * made up by the adversary is properly - * formatted except that the version number is - * wrong. - * To avoid such attacks, we should treat this - * just like any other decryption error. - */ - } + al = SSL_AD_DECODE_ERROR; + /* SSLerror(s, SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */ } if (al != -1) { @@ -1811,43 +1770,40 @@ ssl3_get_client_kex_rsa(SSL *s, unsigned char *p, long n) * on PKCS #1 v1.5 RSA padding (see RFC 2246, * section 7.4.7.1). */ - i = SSL_MAX_MASTER_KEY_LENGTH; p = fakekey; } s->session->master_key_length = tls1_generate_master_secret(s, - s->session->master_key, p, i); + s->session->master_key, p, SSL_MAX_MASTER_KEY_LENGTH); - explicit_bzero(p, i); + freezero(pms, pms_len); return (1); -truncated: + + truncated: al = SSL_AD_DECODE_ERROR; SSLerror(s, SSL_R_BAD_PACKET_LENGTH); -f_err: + f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); -err: + err: + freezero(pms, pms_len); + return (-1); } static int -ssl3_get_client_kex_dhe(SSL *s, unsigned char *p, long n) +ssl3_get_client_kex_dhe(SSL *s, CBS *cbs) { + int key_size = 0, key_len, al; + unsigned char *key = NULL; BIGNUM *bn = NULL; - int key_size, al; - CBS cbs, dh_Yc; + CBS dh_Yc; DH *dh; - if (n < 0) - goto err; - - CBS_init(&cbs, p, n); - - if (!CBS_get_u16_length_prefixed(&cbs, &dh_Yc)) + if (!CBS_get_u16_length_prefixed(cbs, &dh_Yc)) goto truncated; - - if (CBS_len(&cbs) != 0) + if (CBS_len(cbs) != 0) goto truncated; if (S3I(s)->tmp.dh == NULL) { @@ -1862,22 +1818,26 @@ ssl3_get_client_kex_dhe(SSL *s, unsigned char *p, long n) goto err; } - key_size = DH_compute_key(p, bn, dh); - if (key_size <= 0) { + if ((key_size = DH_size(dh)) <= 0) { + SSLerror(s, ERR_R_DH_LIB); + goto err; + } + if ((key = malloc(key_size)) == NULL) { + SSLerror(s, ERR_R_MALLOC_FAILURE); + goto err; + } + if ((key_len = DH_compute_key(key, bn, dh)) <= 0) { SSLerror(s, ERR_R_DH_LIB); - BN_clear_free(bn); goto err; } - s->session->master_key_length = - tls1_generate_master_secret( - s, s->session->master_key, p, key_size); - - explicit_bzero(p, key_size); + s->session->master_key_length = tls1_generate_master_secret(s, + s->session->master_key, key, key_len); DH_free(S3I(s)->tmp.dh); S3I(s)->tmp.dh = NULL; + freezero(key, key_size); BN_clear_free(bn); return (1); @@ -1888,160 +1848,99 @@ ssl3_get_client_kex_dhe(SSL *s, unsigned char *p, long n) f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: + freezero(key, key_size); + BN_clear_free(bn); + return (-1); } static int -ssl3_get_client_kex_ecdhe_ecp(SSL *s, unsigned char *p, long n) +ssl3_get_client_kex_ecdhe_ecp(SSL *s, CBS *cbs) { - EC_KEY *srvr_ecdh = NULL; - EVP_PKEY *clnt_pub_pkey = NULL; - EC_POINT *clnt_ecpoint = NULL; + unsigned char *key = NULL; + int key_size = 0, key_len; + EC_POINT *point = NULL; BN_CTX *bn_ctx = NULL; - int i, al; - - int ret = 1; - int key_size; - const EC_KEY *tkey; const EC_GROUP *group; - const BIGNUM *priv_key; + EC_KEY *ecdh; + CBS public; + int ret = -1; - /* Initialize structures for server's ECDH key pair. */ - if ((srvr_ecdh = EC_KEY_new()) == NULL) { - SSLerror(s, ERR_R_MALLOC_FAILURE); + if (!CBS_get_u8_length_prefixed(cbs, &public)) + goto err; + if (CBS_len(cbs) != 0) goto err; - } /* - * Use the ephemeral values we saved when - * generating the ServerKeyExchange message. + * Use the ephemeral values we saved when generating the + * ServerKeyExchange message. */ - tkey = S3I(s)->tmp.ecdh; - - group = EC_KEY_get0_group(tkey); - priv_key = EC_KEY_get0_private_key(tkey); - - if (!EC_KEY_set_group(srvr_ecdh, group) || - !EC_KEY_set_private_key(srvr_ecdh, priv_key)) { - SSLerror(s, ERR_R_EC_LIB); + if ((ecdh = S3I(s)->tmp.ecdh) == NULL) { + SSLerror(s, ERR_R_INTERNAL_ERROR); goto err; } + group = EC_KEY_get0_group(ecdh); - /* Let's get client's public key */ - if ((clnt_ecpoint = EC_POINT_new(group)) == NULL) { + /* + * Get client's public key from encoded point in the ClientKeyExchange + * message. + */ + if ((bn_ctx = BN_CTX_new()) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } - - if (n == 0L) { - /* Client Publickey was in Client Certificate */ - if (((clnt_pub_pkey = X509_get_pubkey( - s->session->peer)) == NULL) || - (clnt_pub_pkey->type != EVP_PKEY_EC)) { - /* - * XXX: For now, we do not support client - * authentication using ECDH certificates - * so this branch (n == 0L) of the code is - * never executed. When that support is - * added, we ought to ensure the key - * received in the certificate is - * authorized for key agreement. - * ECDH_compute_key implicitly checks that - * the two ECDH shares are for the same - * group. - */ - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerror(s, SSL_R_UNABLE_TO_DECODE_ECDH_CERTS); - goto f_err; - } - - if (EC_POINT_copy(clnt_ecpoint, - EC_KEY_get0_public_key(clnt_pub_pkey->pkey.ec)) - == 0) { - SSLerror(s, ERR_R_EC_LIB); - goto err; - } - ret = 2; /* Skip certificate verify processing */ - } else { - /* - * Get client's public key from encoded point - * in the ClientKeyExchange message. - */ - if ((bn_ctx = BN_CTX_new()) == NULL) { - SSLerror(s, ERR_R_MALLOC_FAILURE); - goto err; - } - - /* Get encoded point length */ - i = *p; - - p += 1; - if (n != 1 + i) { - SSLerror(s, ERR_R_EC_LIB); - goto err; - } - if (EC_POINT_oct2point(group, - clnt_ecpoint, p, i, bn_ctx) == 0) { - SSLerror(s, ERR_R_EC_LIB); - goto err; - } - /* - * p is pointing to somewhere in the buffer - * currently, so set it to the start. - */ - p = (unsigned char *)s->internal->init_buf->data; + if ((point = EC_POINT_new(group)) == NULL) { + SSLerror(s, ERR_R_MALLOC_FAILURE); + goto err; + } + if (EC_POINT_oct2point(group, point, CBS_data(&public), + CBS_len(&public), bn_ctx) == 0) { + SSLerror(s, ERR_R_EC_LIB); + goto err; } /* Compute the shared pre-master secret */ - key_size = ECDH_size(srvr_ecdh); - if (key_size <= 0) { + if ((key_size = ECDH_size(ecdh)) <= 0) { SSLerror(s, ERR_R_ECDH_LIB); goto err; } - i = ECDH_compute_key(p, key_size, clnt_ecpoint, srvr_ecdh, - NULL); - if (i <= 0) { + if ((key = malloc(key_size)) == NULL) { + SSLerror(s, ERR_R_MALLOC_FAILURE); + goto err; + } + if ((key_len = ECDH_compute_key(key, key_size, point, ecdh, + NULL)) <= 0) { SSLerror(s, ERR_R_ECDH_LIB); goto err; } - EVP_PKEY_free(clnt_pub_pkey); - EC_POINT_free(clnt_ecpoint); - EC_KEY_free(srvr_ecdh); - BN_CTX_free(bn_ctx); + /* Compute the master secret */ + s->session->master_key_length = tls1_generate_master_secret(s, + s->session->master_key, key, key_len); + EC_KEY_free(S3I(s)->tmp.ecdh); S3I(s)->tmp.ecdh = NULL; - /* Compute the master secret */ - s->session->master_key_length = - tls1_generate_master_secret( - s, s->session->master_key, p, i); - - explicit_bzero(p, i); - return (ret); + ret = 1; - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); err: - EVP_PKEY_free(clnt_pub_pkey); - EC_POINT_free(clnt_ecpoint); - EC_KEY_free(srvr_ecdh); + freezero(key, key_size); + EC_POINT_free(point); BN_CTX_free(bn_ctx); - return (-1); + + return (ret); } static int -ssl3_get_client_kex_ecdhe_ecx(SSL *s, unsigned char *p, long n) +ssl3_get_client_kex_ecdhe_ecx(SSL *s, CBS *cbs) { uint8_t *shared_key = NULL; - CBS cbs, ecpoint; + CBS ecpoint; int ret = -1; - if (n < 0) + if (!CBS_get_u8_length_prefixed(cbs, &ecpoint)) goto err; - - CBS_init(&cbs, p, n); - if (!CBS_get_u8_length_prefixed(&cbs, &ecpoint)) + if (CBS_len(cbs) != 0) goto err; if (CBS_len(&ecpoint) != X25519_KEY_LENGTH) goto err; @@ -2067,25 +1966,23 @@ ssl3_get_client_kex_ecdhe_ecx(SSL *s, unsigned char *p, long n) } static int -ssl3_get_client_kex_ecdhe(SSL *s, unsigned char *p, long n) +ssl3_get_client_kex_ecdhe(SSL *s, CBS *cbs) { if (S3I(s)->tmp.x25519 != NULL) - return ssl3_get_client_kex_ecdhe_ecx(s, p, n); + return ssl3_get_client_kex_ecdhe_ecx(s, cbs); - return ssl3_get_client_kex_ecdhe_ecp(s, p, n); + return ssl3_get_client_kex_ecdhe_ecp(s, cbs); } static int -ssl3_get_client_kex_gost(SSL *s, unsigned char *p, long n) +ssl3_get_client_kex_gost(SSL *s, CBS *cbs) { - EVP_PKEY_CTX *pkey_ctx; EVP_PKEY *client_pub_pkey = NULL, *pk = NULL; - unsigned char premaster_secret[32], *start; - size_t outlen = 32, inlen; + unsigned char premaster_secret[32]; unsigned long alg_a; - int Ttag, Tclass; - long Tlen; + size_t outlen = 32; + CBS gostblob; int al; int ret = 0; @@ -2094,8 +1991,11 @@ ssl3_get_client_kex_gost(SSL *s, unsigned char *p, long n) if (alg_a & SSL_aGOST01) pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; - pkey_ctx = EVP_PKEY_CTX_new(pk, NULL); - EVP_PKEY_decrypt_init(pkey_ctx); + if ((pkey_ctx = EVP_PKEY_CTX_new(pk, NULL)) == NULL) + goto err; + if (EVP_PKEY_decrypt_init(pkey_ctx) <= 0) + goto gerr; + /* * If client certificate is present and is of the same type, * maybe use it for key exchange. @@ -2103,32 +2003,28 @@ ssl3_get_client_kex_gost(SSL *s, unsigned char *p, long n) * it is completely valid to use a client certificate for * authorization only. */ - client_pub_pkey = X509_get_pubkey(s->session->peer); - if (client_pub_pkey) { + if ((client_pub_pkey = X509_get_pubkey(s->session->peer)) != NULL) { if (EVP_PKEY_derive_set_peer(pkey_ctx, client_pub_pkey) <= 0) ERR_clear_error(); } - if (2 > n) - goto truncated; + /* Decrypt session key */ - if (ASN1_get_object((const unsigned char **)&p, &Tlen, &Ttag, - &Tclass, n) != V_ASN1_CONSTRUCTED || - Ttag != V_ASN1_SEQUENCE || Tclass != V_ASN1_UNIVERSAL) { - SSLerror(s, SSL_R_DECRYPTION_FAILED); - goto gerr; - } - start = p; - inlen = Tlen; + if (!CBS_get_asn1(cbs, &gostblob, CBS_ASN1_SEQUENCE)) + goto truncated; + if (CBS_len(cbs) != 0) + goto truncated; if (EVP_PKEY_decrypt(pkey_ctx, premaster_secret, &outlen, - start, inlen) <=0) { + CBS_data(&gostblob), CBS_len(&gostblob)) <= 0) { SSLerror(s, SSL_R_DECRYPTION_FAILED); goto gerr; } + /* Generate master secret */ s->session->master_key_length = tls1_generate_master_secret( s, s->session->master_key, premaster_secret, 32); + /* Check if pubkey from client certificate was used */ if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) @@ -2155,8 +2051,8 @@ int ssl3_get_client_key_exchange(SSL *s) { unsigned long alg_k; - unsigned char *p; int al, ok; + CBS cbs; long n; /* 2048 maxlen is a guess. How long a key does that permit? */ @@ -2165,21 +2061,24 @@ ssl3_get_client_key_exchange(SSL *s) if (!ok) return ((int)n); - p = (unsigned char *)s->internal->init_msg; + if (n < 0) + goto err; + + CBS_init(&cbs, s->internal->init_msg, n); alg_k = S3I(s)->hs.new_cipher->algorithm_mkey; if (alg_k & SSL_kRSA) { - if (ssl3_get_client_kex_rsa(s, p, n) != 1) + if (ssl3_get_client_kex_rsa(s, &cbs) != 1) goto err; } else if (alg_k & SSL_kDHE) { - if (ssl3_get_client_kex_dhe(s, p, n) != 1) + if (ssl3_get_client_kex_dhe(s, &cbs) != 1) goto err; } else if (alg_k & SSL_kECDHE) { - if (ssl3_get_client_kex_ecdhe(s, p, n) != 1) + if (ssl3_get_client_kex_ecdhe(s, &cbs) != 1) goto err; } else if (alg_k & SSL_kGOST) { - if (ssl3_get_client_kex_gost(s, p, n) != 1) + if (ssl3_get_client_kex_gost(s, &cbs) != 1) goto err; } else { al = SSL_AD_HANDSHAKE_FAILURE; @@ -2187,6 +2086,12 @@ ssl3_get_client_key_exchange(SSL *s) goto f_err; } + if (CBS_len(&cbs) != 0) { + al = SSL_AD_DECODE_ERROR; + SSLerror(s, SSL_R_BAD_PACKET_LENGTH); + goto f_err; + } + return (1); f_err: @@ -2198,14 +2103,19 @@ ssl3_get_client_key_exchange(SSL *s) int ssl3_get_cert_verify(SSL *s) { - EVP_PKEY *pkey = NULL; - unsigned char *p; - int al, ok, ret = 0; - long n; - int type = 0, i, j; - X509 *peer; + CBS cbs, signature; const EVP_MD *md = NULL; + EVP_PKEY *pkey = NULL; + X509 *peer = NULL; EVP_MD_CTX mctx; + uint8_t hash_id, sig_id; + int al, ok, sigalg, verify; + int type = 0; + int ret = 0; + long hdatalen; + void *hdata; + long n; + EVP_MD_CTX_init(&mctx); n = s->method->internal->ssl_get_message(s, SSL3_ST_SR_CERT_VRFY_A, @@ -2213,13 +2123,15 @@ ssl3_get_cert_verify(SSL *s) if (!ok) return ((int)n); + if (n < 0) + goto err; + + CBS_init(&cbs, s->internal->init_msg, n); + if (s->session->peer != NULL) { peer = s->session->peer; pkey = X509_get_pubkey(peer); type = X509_certificate_type(peer, pkey); - } else { - peer = NULL; - pkey = NULL; } if (S3I(s)->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY) { @@ -2251,60 +2163,57 @@ ssl3_get_cert_verify(SSL *s) goto f_err; } - /* we now have a signature that we need to verify */ - p = (unsigned char *)s->internal->init_msg; /* * Check for broken implementations of GOST ciphersuites. * * If key is GOST and n is exactly 64, it is a bare * signature without length field. */ - if (n == 64 && (pkey->type == NID_id_GostR3410_94 || - pkey->type == NID_id_GostR3410_2001) ) { - i = 64; + if ((pkey->type == NID_id_GostR3410_94 || + pkey->type == NID_id_GostR3410_2001) && CBS_len(&cbs) == 64) { + CBS_dup(&cbs, &signature); + if (!CBS_skip(&cbs, CBS_len(&cbs))) + goto err; } else { if (SSL_USE_SIGALGS(s)) { - int sigalg = tls12_get_sigid(pkey); - /* Should never happen */ - if (sigalg == -1) { - SSLerror(s, ERR_R_INTERNAL_ERROR); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - if (2 > n) + if (!CBS_get_u8(&cbs, &hash_id)) goto truncated; - /* Check key type is consistent with signature */ - if (sigalg != (int)p[1]) { - SSLerror(s, SSL_R_WRONG_SIGNATURE_TYPE); + if (!CBS_get_u8(&cbs, &sig_id)) + goto truncated; + + if ((md = tls12_get_hash(hash_id)) == NULL) { + SSLerror(s, SSL_R_UNKNOWN_DIGEST); al = SSL_AD_DECODE_ERROR; goto f_err; } - md = tls12_get_hash(p[0]); - if (md == NULL) { - SSLerror(s, SSL_R_UNKNOWN_DIGEST); + + /* Check key type is consistent with signature. */ + if ((sigalg = tls12_get_sigid(pkey)) == -1) { + /* Should never happen */ + SSLerror(s, ERR_R_INTERNAL_ERROR); + goto err; + } + if (sigalg != sig_id) { + SSLerror(s, SSL_R_WRONG_SIGNATURE_TYPE); al = SSL_AD_DECODE_ERROR; goto f_err; } - p += 2; - n -= 2; } - if (2 > n) - goto truncated; - n2s(p, i); - n -= 2; - if (i > n) - goto truncated; + if (!CBS_get_u16_length_prefixed(&cbs, &signature)) + goto err; } - j = EVP_PKEY_size(pkey); - if ((i > j) || (n > j) || (n <= 0)) { + if (CBS_len(&signature) > EVP_PKEY_size(pkey)) { SSLerror(s, SSL_R_WRONG_SIGNATURE_SIZE); al = SSL_AD_DECODE_ERROR; goto f_err; } + if (CBS_len(&cbs) != 0) { + al = SSL_AD_DECODE_ERROR; + SSLerror(s, SSL_R_EXTRA_DATA_IN_MESSAGE); + goto f_err; + } if (SSL_USE_SIGALGS(s)) { - long hdatalen = 0; - void *hdata; hdatalen = BIO_get_mem_data(S3I(s)->handshake_buffer, &hdata); if (hdatalen <= 0) { SSLerror(s, ERR_R_INTERNAL_ERROR); @@ -2317,34 +2226,32 @@ ssl3_get_cert_verify(SSL *s) al = SSL_AD_INTERNAL_ERROR; goto f_err; } - - if (EVP_VerifyFinal(&mctx, p, i, pkey) <= 0) { + if (EVP_VerifyFinal(&mctx, CBS_data(&signature), + CBS_len(&signature), pkey) <= 0) { al = SSL_AD_DECRYPT_ERROR; SSLerror(s, SSL_R_BAD_SIGNATURE); goto f_err; } - } else - if (pkey->type == EVP_PKEY_RSA) { - i = RSA_verify(NID_md5_sha1, S3I(s)->tmp.cert_verify_md, - MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, p, i, - pkey->pkey.rsa); - if (i < 0) { + } else if (pkey->type == EVP_PKEY_RSA) { + verify = RSA_verify(NID_md5_sha1, S3I(s)->tmp.cert_verify_md, + MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, CBS_data(&signature), + CBS_len(&signature), pkey->pkey.rsa); + if (verify < 0) { al = SSL_AD_DECRYPT_ERROR; SSLerror(s, SSL_R_BAD_RSA_DECRYPT); goto f_err; } - if (i == 0) { + if (verify == 0) { al = SSL_AD_DECRYPT_ERROR; SSLerror(s, SSL_R_BAD_RSA_SIGNATURE); goto f_err; } - } else - if (pkey->type == EVP_PKEY_EC) { - j = ECDSA_verify(pkey->save_type, + } else if (pkey->type == EVP_PKEY_EC) { + verify = ECDSA_verify(pkey->save_type, &(S3I(s)->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), - SHA_DIGEST_LENGTH, p, i, pkey->pkey.ec); - if (j <= 0) { - /* bad signature */ + SHA_DIGEST_LENGTH, CBS_data(&signature), + CBS_len(&signature), pkey->pkey.ec); + if (verify <= 0) { al = SSL_AD_DECRYPT_ERROR; SSLerror(s, SSL_R_BAD_ECDSA_SIGNATURE); goto f_err; @@ -2353,12 +2260,10 @@ ssl3_get_cert_verify(SSL *s) #ifndef OPENSSL_NO_GOST if (pkey->type == NID_id_GostR3410_94 || pkey->type == NID_id_GostR3410_2001) { - long hdatalen = 0; - void *hdata; - unsigned char signature[128]; - unsigned int siglen = sizeof(signature); - int nid; + unsigned char sigbuf[128]; + unsigned int siglen = sizeof(sigbuf); EVP_PKEY_CTX *pctx; + int nid; hdatalen = BIO_get_mem_data(S3I(s)->handshake_buffer, &hdata); if (hdatalen <= 0) { @@ -2367,33 +2272,31 @@ ssl3_get_cert_verify(SSL *s) goto f_err; } if (!EVP_PKEY_get_default_digest_nid(pkey, &nid) || - !(md = EVP_get_digestbynid(nid))) { + !(md = EVP_get_digestbynid(nid))) { SSLerror(s, ERR_R_EVP_LIB); al = SSL_AD_INTERNAL_ERROR; goto f_err; } - pctx = EVP_PKEY_CTX_new(pkey, NULL); - if (!pctx) { + if ((pctx = EVP_PKEY_CTX_new(pkey, NULL)) == NULL) { SSLerror(s, ERR_R_EVP_LIB); al = SSL_AD_INTERNAL_ERROR; goto f_err; } if (!EVP_DigestInit_ex(&mctx, md, NULL) || !EVP_DigestUpdate(&mctx, hdata, hdatalen) || - !EVP_DigestFinal(&mctx, signature, &siglen) || + !EVP_DigestFinal(&mctx, sigbuf, &siglen) || (EVP_PKEY_verify_init(pctx) <= 0) || (EVP_PKEY_CTX_set_signature_md(pctx, md) <= 0) || (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_VERIFY, - EVP_PKEY_CTRL_GOST_SIG_FORMAT, - GOST_SIG_FORMAT_RS_LE, - NULL) <= 0)) { + EVP_PKEY_CTRL_GOST_SIG_FORMAT, + GOST_SIG_FORMAT_RS_LE, NULL) <= 0)) { SSLerror(s, ERR_R_EVP_LIB); al = SSL_AD_INTERNAL_ERROR; EVP_PKEY_CTX_free(pctx); goto f_err; } - - if (EVP_PKEY_verify(pctx, p, i, signature, siglen) <= 0) { + if (EVP_PKEY_verify(pctx, CBS_data(&signature), + CBS_len(&signature), sigbuf, siglen) <= 0) { al = SSL_AD_DECRYPT_ERROR; SSLerror(s, SSL_R_BAD_SIGNATURE); EVP_PKEY_CTX_free(pctx); @@ -2409,21 +2312,21 @@ ssl3_get_cert_verify(SSL *s) goto f_err; } - ret = 1; if (0) { -truncated: + truncated: al = SSL_AD_DECODE_ERROR; SSLerror(s, SSL_R_BAD_PACKET_LENGTH); -f_err: + f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); } -end: + end: if (S3I(s)->handshake_buffer) { BIO_free(S3I(s)->handshake_buffer); S3I(s)->handshake_buffer = NULL; s->s3->flags &= ~TLS1_FLAGS_KEEP_HANDSHAKE; } + err: EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_free(pkey); return (ret); @@ -2596,12 +2499,12 @@ ssl3_send_server_certificate(SSL *s) return (0); } - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &server_cert, + if (!ssl3_handshake_msg_start(s, &cbb, &server_cert, SSL3_MT_CERTIFICATE)) goto err; if (!ssl3_output_cert_chain(s, &server_cert, x)) goto err; - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_SW_CERT_B; @@ -2620,78 +2523,44 @@ ssl3_send_server_certificate(SSL *s) int ssl3_send_newsession_ticket(SSL *s) { - unsigned char *d, *p, *macstart; - unsigned char *senc = NULL; - const unsigned char *const_p; - int len, slen_full, slen; - SSL_SESSION *sess; - unsigned int hlen; - EVP_CIPHER_CTX ctx; - HMAC_CTX hctx; + CBB cbb, session_ticket, ticket; SSL_CTX *tctx = s->initial_ctx; + size_t enc_session_len, enc_session_max_len, hmac_len; + size_t session_len = 0; + unsigned char *enc_session = NULL, *session = NULL; unsigned char iv[EVP_MAX_IV_LENGTH]; unsigned char key_name[16]; + unsigned char *hmac; + unsigned int hlen; + EVP_CIPHER_CTX ctx; + HMAC_CTX hctx; + int len; - if (S3I(s)->hs.state == SSL3_ST_SW_SESSION_TICKET_A) { - /* get session encoding length */ - slen_full = i2d_SSL_SESSION(s->session, NULL); - /* - * Some length values are 16 bits, so forget it if session is - * too long - */ - if (slen_full > 0xFF00) - goto err; - senc = malloc(slen_full); - if (!senc) - goto err; - p = senc; - i2d_SSL_SESSION(s->session, &p); + /* + * New Session Ticket - RFC 5077, section 3.3. + */ - /* - * Create a fresh copy (not shared with other threads) to - * clean up - */ - const_p = senc; - sess = d2i_SSL_SESSION(NULL, &const_p, slen_full); - if (sess == NULL) - goto err; + EVP_CIPHER_CTX_init(&ctx); + HMAC_CTX_init(&hctx); - /* ID is irrelevant for the ticket */ - sess->session_id_length = 0; + memset(&cbb, 0, sizeof(cbb)); - slen = i2d_SSL_SESSION(sess, NULL); - if (slen > slen_full) { - /* shouldn't ever happen */ + if (S3I(s)->hs.state == SSL3_ST_SW_SESSION_TICKET_A) { + if (!ssl3_handshake_msg_start(s, &cbb, &session_ticket, + SSL3_MT_NEWSESSION_TICKET)) goto err; - } - p = senc; - i2d_SSL_SESSION(sess, &p); - SSL_SESSION_free(sess); - /* - * Grow buffer if need be: the length calculation is as - * follows 1 (size of message name) + 3 (message length - * bytes) + 4 (ticket lifetime hint) + 2 (ticket length) + - * 16 (key name) + max_iv_len (iv length) + - * session_length + max_enc_block_size (max encrypted session - * length) + max_md_size (HMAC). - */ - if (!BUF_MEM_grow(s->internal->init_buf, ssl3_handshake_msg_hdr_len(s) + - 22 + EVP_MAX_IV_LENGTH + EVP_MAX_BLOCK_LENGTH + - EVP_MAX_MD_SIZE + slen)) + if (!SSL_SESSION_ticket(s->session, &session, &session_len)) + goto err; + if (session_len > 0xffff) goto err; - - d = p = ssl3_handshake_msg_start(s, SSL3_MT_NEWSESSION_TICKET); - - EVP_CIPHER_CTX_init(&ctx); - HMAC_CTX_init(&hctx); /* - * Initialize HMAC and cipher contexts. If callback present - * it does all the work otherwise use generated values - * from parent ctx. + * Initialize HMAC and cipher contexts. If callback is present + * it does all the work, otherwise use generated values from + * parent context. */ - if (tctx->internal->tlsext_ticket_key_cb) { + if (tctx->internal->tlsext_ticket_key_cb != NULL) { if (tctx->internal->tlsext_ticket_key_cb(s, key_name, iv, &ctx, &hctx, 1) < 0) { EVP_CIPHER_CTX_cleanup(&ctx); @@ -2706,55 +2575,80 @@ ssl3_send_newsession_ticket(SSL *s) memcpy(key_name, tctx->internal->tlsext_tick_key_name, 16); } + /* Encrypt the session state. */ + enc_session_max_len = session_len + EVP_MAX_BLOCK_LENGTH; + if ((enc_session = calloc(1, enc_session_max_len)) == NULL) + goto err; + enc_session_len = 0; + if (!EVP_EncryptUpdate(&ctx, enc_session, &len, session, + session_len)) + goto err; + enc_session_len += len; + if (!EVP_EncryptFinal_ex(&ctx, enc_session + enc_session_len, + &len)) + goto err; + enc_session_len += len; + + if (enc_session_len > enc_session_max_len) + goto err; + + /* Generate the HMAC. */ + if (!HMAC_Update(&hctx, key_name, sizeof(key_name))) + goto err; + if (!HMAC_Update(&hctx, iv, EVP_CIPHER_CTX_iv_length(&ctx))) + goto err; + if (!HMAC_Update(&hctx, enc_session, enc_session_len)) + goto err; + + if ((hmac_len = HMAC_size(&hctx)) <= 0) + goto err; + /* * Ticket lifetime hint (advisory only): * We leave this unspecified for resumed session * (for simplicity), and guess that tickets for new * sessions will live as long as their sessions. */ - l2n(s->internal->hit ? 0 : s->session->timeout, p); - - /* Skip ticket length for now */ - p += 2; - /* Output key name */ - macstart = p; - memcpy(p, key_name, 16); - p += 16; - /* output IV */ - memcpy(p, iv, EVP_CIPHER_CTX_iv_length(&ctx)); - p += EVP_CIPHER_CTX_iv_length(&ctx); - /* Encrypt session data */ - EVP_EncryptUpdate(&ctx, p, &len, senc, slen); - p += len; - EVP_EncryptFinal_ex(&ctx, p, &len); - p += len; - EVP_CIPHER_CTX_cleanup(&ctx); - - HMAC_Update(&hctx, macstart, p - macstart); - HMAC_Final(&hctx, p, &hlen); - HMAC_CTX_cleanup(&hctx); - p += hlen; - - /* Now write out lengths: p points to end of data written */ - /* Total length */ - len = p - d; - - /* Skip ticket lifetime hint. */ - p = d + 4; - s2n(len - 6, p); /* Message length */ - - ssl3_handshake_msg_finish(s, len); + if (!CBB_add_u32(&session_ticket, + s->internal->hit ? 0 : s->session->timeout)) + goto err; - S3I(s)->hs.state = SSL3_ST_SW_SESSION_TICKET_B; + if (!CBB_add_u16_length_prefixed(&session_ticket, &ticket)) + goto err; + if (!CBB_add_bytes(&ticket, key_name, sizeof(key_name))) + goto err; + if (!CBB_add_bytes(&ticket, iv, EVP_CIPHER_CTX_iv_length(&ctx))) + goto err; + if (!CBB_add_bytes(&ticket, enc_session, enc_session_len)) + goto err; + if (!CBB_add_space(&ticket, &hmac, hmac_len)) + goto err; - freezero(senc, slen_full); + if (!HMAC_Final(&hctx, hmac, &hlen)) + goto err; + if (hlen != hmac_len) + goto err; + + if (!ssl3_handshake_msg_finish(s, &cbb)) + goto err; + + S3I(s)->hs.state = SSL3_ST_SW_SESSION_TICKET_B; } + EVP_CIPHER_CTX_cleanup(&ctx); + HMAC_CTX_cleanup(&hctx); + freezero(session, session_len); + free(enc_session); + /* SSL3_ST_SW_SESSION_TICKET_B */ return (ssl3_handshake_write(s)); err: - freezero(senc, slen_full); + CBB_cleanup(&cbb); + EVP_CIPHER_CTX_cleanup(&ctx); + HMAC_CTX_cleanup(&hctx); + freezero(session, session_len); + free(enc_session); return (-1); } @@ -2767,7 +2661,7 @@ ssl3_send_cert_status(SSL *s) memset(&cbb, 0, sizeof(cbb)); if (S3I(s)->hs.state == SSL3_ST_SW_CERT_STATUS_A) { - if (!ssl3_handshake_msg_start_cbb(s, &cbb, &certstatus, + if (!ssl3_handshake_msg_start(s, &cbb, &certstatus, SSL3_MT_CERTIFICATE_STATUS)) goto err; if (!CBB_add_u8(&certstatus, s->tlsext_status_type)) @@ -2777,7 +2671,7 @@ ssl3_send_cert_status(SSL *s) if (!CBB_add_bytes(&ocspresp, s->internal->tlsext_ocsp_resp, s->internal->tlsext_ocsp_resplen)) goto err; - if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; S3I(s)->hs.state = SSL3_ST_SW_CERT_STATUS_B; diff --git a/lib/libssl/ssl_tlsext.c b/lib/libssl/ssl_tlsext.c index 3735b719db..b70be87f3a 100644 --- a/lib/libssl/ssl_tlsext.c +++ b/lib/libssl/ssl_tlsext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_tlsext.c,v 1.21 2018/02/08 11:30:30 jsing Exp $ */ +/* $OpenBSD: ssl_tlsext.c,v 1.22 2018/05/12 17:27:22 jsing Exp $ */ /* * Copyright (c) 2016, 2017 Joel Sing * Copyright (c) 2017 Doug Hogan @@ -333,14 +333,16 @@ tlsext_ecpf_parse(SSL *s, CBS *cbs, int *alert) if (!s->internal->hit) { if (!CBS_stow(&ecpf, &(SSI(s)->tlsext_ecpointformatlist), - &(SSI(s)->tlsext_ecpointformatlist_length))) - goto err; + &(SSI(s)->tlsext_ecpointformatlist_length))) { + *alert = TLS1_AD_INTERNAL_ERROR; + return 0; + } } return 1; err: - *alert = TLS1_AD_INTERNAL_ERROR; + *alert = SSL_AD_DECODE_ERROR; return 0; } diff --git a/lib/libssl/t1_clnt.c b/lib/libssl/t1_clnt.c index 92b5efb11a..4e3b208743 100644 --- a/lib/libssl/t1_clnt.c +++ b/lib/libssl/t1_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_clnt.c,v 1.24 2017/01/26 05:31:25 jsing Exp $ */ +/* $OpenBSD: t1_clnt.c,v 1.26 2018/08/30 16:56:16 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,11 +73,6 @@ static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_client_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -107,11 +102,6 @@ static const SSL_METHOD_INTERNAL TLSv1_client_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_client_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -141,11 +131,6 @@ static const SSL_METHOD_INTERNAL TLSv1_1_client_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_client_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -175,11 +160,6 @@ static const SSL_METHOD_INTERNAL TLSv1_2_client_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_client_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, diff --git a/lib/libssl/t1_enc.c b/lib/libssl/t1_enc.c index 9598613516..b8ebf52417 100644 --- a/lib/libssl/t1_enc.c +++ b/lib/libssl/t1_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_enc.c,v 1.109 2017/05/06 22:24:58 beck Exp $ */ +/* $OpenBSD: t1_enc.c,v 1.114 2018/09/08 14:39:41 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -397,10 +397,13 @@ tls1_change_cipher_state_aead(SSL *s, char is_read, const unsigned char *key, SSL_AEAD_CTX *aead_ctx; if (is_read) { + ssl_clear_cipher_read_state(s); if (!tls1_aead_ctx_init(&s->internal->aead_read_ctx)) return 0; aead_ctx = s->internal->aead_read_ctx; } else { + /* XXX - Need to correctly handle DTLS. */ + ssl_clear_cipher_write_state(s); if (!tls1_aead_ctx_init(&s->internal->aead_write_ctx)) return 0; aead_ctx = s->internal->aead_write_ctx; @@ -444,11 +447,10 @@ tls1_change_cipher_state_aead(SSL *s, char is_read, const unsigned char *key, * tls1_change_cipher_state_cipher performs the work needed to switch cipher * states when using EVP_CIPHER. The argument is_read is true iff this function * is being called due to reading, as opposed to writing, a ChangeCipherSpec - * message. In order to support export ciphersuites, use_client_keys indicates - * whether the key material provided is in the "client write" direction. + * message. */ static int -tls1_change_cipher_state_cipher(SSL *s, char is_read, char use_client_keys, +tls1_change_cipher_state_cipher(SSL *s, char is_read, const unsigned char *mac_secret, unsigned int mac_secret_size, const unsigned char *key, unsigned int key_len, const unsigned char *iv, unsigned int iv_len) @@ -456,6 +458,7 @@ tls1_change_cipher_state_cipher(SSL *s, char is_read, char use_client_keys, EVP_CIPHER_CTX *cipher_ctx; const EVP_CIPHER *cipher; EVP_MD_CTX *mac_ctx; + EVP_PKEY *mac_key; const EVP_MD *mac; int mac_type; @@ -469,15 +472,12 @@ tls1_change_cipher_state_cipher(SSL *s, char is_read, char use_client_keys, else s->internal->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM; - EVP_CIPHER_CTX_free(s->enc_read_ctx); - s->enc_read_ctx = NULL; - EVP_MD_CTX_destroy(s->read_hash); - s->read_hash = NULL; + ssl_clear_cipher_read_state(s); if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->enc_read_ctx = cipher_ctx; - if ((mac_ctx = EVP_MD_CTX_create()) == NULL) + if ((mac_ctx = EVP_MD_CTX_new()) == NULL) goto err; s->read_hash = mac_ctx; } else { @@ -493,40 +493,24 @@ tls1_change_cipher_state_cipher(SSL *s, char is_read, char use_client_keys, * contexts that are used for DTLS - these are instead freed * by DTLS when its frees a ChangeCipherSpec fragment. */ - if (!SSL_IS_DTLS(s)) { - EVP_CIPHER_CTX_free(s->internal->enc_write_ctx); - s->internal->enc_write_ctx = NULL; - EVP_MD_CTX_destroy(s->internal->write_hash); - s->internal->write_hash = NULL; - } + if (!SSL_IS_DTLS(s)) + ssl_clear_cipher_write_state(s); + if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->internal->enc_write_ctx = cipher_ctx; - if ((mac_ctx = EVP_MD_CTX_create()) == NULL) + if ((mac_ctx = EVP_MD_CTX_new()) == NULL) goto err; s->internal->write_hash = mac_ctx; } - if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) { - EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, NULL, - !is_read); - EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_GCM_SET_IV_FIXED, - iv_len, (unsigned char *)iv); - } else - EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, iv, !is_read); - - if (!(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER)) { - EVP_PKEY *mac_key = EVP_PKEY_new_mac_key(mac_type, NULL, - mac_secret, mac_secret_size); - if (mac_key == NULL) - goto err; - EVP_DigestSignInit(mac_ctx, NULL, mac, NULL, mac_key); - EVP_PKEY_free(mac_key); - } else if (mac_secret_size > 0) { - /* Needed for "composite" AEADs, such as RC4-HMAC-MD5 */ - EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY, - mac_secret_size, (unsigned char *)mac_secret); - } + EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, iv, !is_read); + + if ((mac_key = EVP_PKEY_new_mac_key(mac_type, NULL, mac_secret, + mac_secret_size)) == NULL) + goto err; + EVP_DigestSignInit(mac_ctx, NULL, mac, NULL, mac_key); + EVP_PKEY_free(mac_key); if (S3I(s)->hs.new_cipher->algorithm_enc == SSL_eGOST2814789CNT) { int nid; @@ -560,7 +544,6 @@ tls1_change_cipher_state(SSL *s, int which) const EVP_AEAD *aead; char is_read, use_client_keys; - cipher = S3I(s)->tmp.new_sym_enc; aead = S3I(s)->tmp.new_aead; @@ -579,7 +562,6 @@ tls1_change_cipher_state(SSL *s, int which) use_client_keys = ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) || (which == SSL3_CHANGE_CIPHER_SERVER_READ)); - /* * Reset sequence number to zero - for DTLS this is handled in * dtls1_reset_seq_numbers(). @@ -595,10 +577,6 @@ tls1_change_cipher_state(SSL *s, int which) } else { key_len = EVP_CIPHER_key_length(cipher); iv_len = EVP_CIPHER_iv_length(cipher); - - /* If GCM mode only part of IV comes from PRF. */ - if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) - iv_len = EVP_GCM_TLS_FIXED_IV_LEN; } mac_secret_size = s->s3->tmp.new_mac_secret_size; @@ -645,7 +623,7 @@ tls1_change_cipher_state(SSL *s, int which) iv, iv_len); } - return tls1_change_cipher_state_cipher(s, is_read, use_client_keys, + return tls1_change_cipher_state_cipher(s, is_read, mac_secret, mac_secret_size, key, key_len, iv, iv_len); err2: @@ -667,7 +645,7 @@ tls1_setup_key_block(SSL *s) return (1); if (s->session->cipher && - (s->session->cipher->algorithm2 & SSL_CIPHER_ALGORITHM2_AEAD)) { + (s->session->cipher->algorithm_mac & SSL_AEAD)) { if (!ssl_cipher_get_evp_aead(s->session, &aead)) { SSLerror(s, SSL_R_CIPHER_OR_HASH_UNAVAILABLE); return (0); @@ -682,10 +660,6 @@ tls1_setup_key_block(SSL *s) } key_len = EVP_CIPHER_key_length(cipher); iv_len = EVP_CIPHER_iv_length(cipher); - - /* If GCM mode only part of IV comes from PRF. */ - if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) - iv_len = EVP_GCM_TLS_FIXED_IV_LEN; } S3I(s)->tmp.new_aead = aead; @@ -957,28 +931,7 @@ tls1_enc(SSL *s, int send) l = rec->length; bs = EVP_CIPHER_block_size(ds->cipher); - if (EVP_CIPHER_flags(ds->cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) { - unsigned char buf[13]; - - if (SSL_IS_DTLS(s)) { - dtls1_build_sequence_number(buf, seq, - send ? D1I(s)->w_epoch : D1I(s)->r_epoch); - } else { - memcpy(buf, seq, SSL3_SEQUENCE_SIZE); - tls1_record_sequence_increment(seq); - } - - buf[8] = rec->type; - buf[9] = (unsigned char)(s->version >> 8); - buf[10] = (unsigned char)(s->version); - buf[11] = rec->length >> 8; - buf[12] = rec->length & 0xff; - pad = EVP_CIPHER_CTX_ctrl(ds, EVP_CTRL_AEAD_TLS1_AAD, 13, buf); - if (send) { - l += pad; - rec->length += pad; - } - } else if ((bs != 1) && send) { + if (bs != 1 && send) { i = bs - ((int)l % bs); /* Add weird padding of upto 256 bytes */ @@ -1000,11 +953,6 @@ tls1_enc(SSL *s, int send) if ((EVP_CIPHER_flags(ds->cipher) & EVP_CIPH_FLAG_CUSTOM_CIPHER) ? (i < 0) : (i == 0)) return -1; /* AEAD can fail to verify MAC */ - if (EVP_CIPHER_mode(enc) == EVP_CIPH_GCM_MODE && !send) { - rec->data += EVP_GCM_TLS_EXPLICIT_IV_LEN; - rec->input += EVP_GCM_TLS_EXPLICIT_IV_LEN; - rec->length -= EVP_GCM_TLS_EXPLICIT_IV_LEN; - } ret = 1; if (EVP_MD_CTX_md(s->read_hash) != NULL) diff --git a/lib/libssl/t1_hash.c b/lib/libssl/t1_hash.c index aef6e65729..a7e46601e8 100644 --- a/lib/libssl/t1_hash.c +++ b/lib/libssl/t1_hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_hash.c,v 1.2 2017/05/06 16:18:36 jsing Exp $ */ +/* $OpenBSD: t1_hash.c,v 1.3 2018/09/05 16:58:59 jsing Exp $ */ /* * Copyright (c) 2017 Joel Sing * @@ -33,7 +33,7 @@ tls1_handshake_hash_init(SSL *s) goto err; } - if ((S3I(s)->handshake_hash = EVP_MD_CTX_create()) == NULL) { + if ((S3I(s)->handshake_hash = EVP_MD_CTX_new()) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } @@ -80,7 +80,7 @@ tls1_handshake_hash_value(SSL *s, const unsigned char *out, size_t len, if (EVP_MD_CTX_size(S3I(s)->handshake_hash) > len) goto err; - if ((mdctx = EVP_MD_CTX_create()) == NULL) { + if ((mdctx = EVP_MD_CTX_new()) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } @@ -98,7 +98,7 @@ tls1_handshake_hash_value(SSL *s, const unsigned char *out, size_t len, ret = 1; err: - EVP_MD_CTX_destroy(mdctx); + EVP_MD_CTX_free(mdctx); return (ret); } @@ -106,6 +106,6 @@ tls1_handshake_hash_value(SSL *s, const unsigned char *out, size_t len, void tls1_handshake_hash_free(SSL *s) { - EVP_MD_CTX_destroy(S3I(s)->handshake_hash); + EVP_MD_CTX_free(S3I(s)->handshake_hash); S3I(s)->handshake_hash = NULL; } diff --git a/lib/libssl/t1_lib.c b/lib/libssl/t1_lib.c index d92fd70f5b..0a00e4da7f 100644 --- a/lib/libssl/t1_lib.c +++ b/lib/libssl/t1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_lib.c,v 1.141 2018/02/08 11:30:30 jsing Exp $ */ +/* $OpenBSD: t1_lib.c,v 1.144 2018/08/24 18:10:25 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -815,11 +815,9 @@ ssl_check_serverhello_tlsext(SSL *s) * ClientHello, and other operations depend on the result, we need to handle * any TLS session ticket extension at the same time. * - * session_id: points at the session ID in the ClientHello. This code will - * read past the end of this in order to parse out the session ticket - * extension, if any. - * len: the length of the session ID. - * limit: a pointer to the first byte after the ClientHello. + * session_id: points at the session ID in the ClientHello. + * session_id_len: the length of the session ID. + * ext_block: a CBS for the ClientHello extensions block. * ret: (output) on return, if a ticket was decrypted, then this is set to * point to the resulting session. * @@ -845,55 +843,34 @@ ssl_check_serverhello_tlsext(SSL *s) * Otherwise, s->internal->tlsext_ticket_expected is set to 0. */ int -tls1_process_ticket(SSL *s, const unsigned char *session, int session_len, - const unsigned char *limit, SSL_SESSION **ret) +tls1_process_ticket(SSL *s, const unsigned char *session_id, int session_id_len, + CBS *ext_block, SSL_SESSION **ret) { - /* Point after session ID in client hello */ - CBS session_id, cookie, cipher_list, compress_algo, extensions; + CBS extensions; - *ret = NULL; s->internal->tlsext_ticket_expected = 0; + *ret = NULL; - /* If tickets disabled behave as if no ticket present - * to permit stateful resumption. + /* + * If tickets disabled behave as if no ticket present to permit stateful + * resumption. */ if (SSL_get_options(s) & SSL_OP_NO_TICKET) return 0; - if (!limit) - return 0; - - if (limit < session) - return -1; - CBS_init(&session_id, session, limit - session); - - /* Skip past the session id */ - if (!CBS_skip(&session_id, session_len)) - return -1; - - /* Skip past DTLS cookie */ - if (SSL_IS_DTLS(s)) { - if (!CBS_get_u8_length_prefixed(&session_id, &cookie)) - return -1; - } - - /* Skip past cipher list */ - if (!CBS_get_u16_length_prefixed(&session_id, &cipher_list)) - return -1; - - /* Skip past compression algorithm list */ - if (!CBS_get_u8_length_prefixed(&session_id, &compress_algo)) - return -1; - - /* Now at start of extensions */ - if (CBS_len(&session_id) == 0) + /* + * An empty extensions block is valid, but obviously does not contain + * a session ticket. + */ + if (CBS_len(ext_block) == 0) return 0; - if (!CBS_get_u16_length_prefixed(&session_id, &extensions)) + + if (!CBS_get_u16_length_prefixed(ext_block, &extensions)) return -1; while (CBS_len(&extensions) > 0) { - CBS ext_data; uint16_t ext_type; + CBS ext_data; if (!CBS_get_u16(&extensions, &ext_type) || !CBS_get_u16_length_prefixed(&extensions, &ext_data)) @@ -907,7 +884,7 @@ tls1_process_ticket(SSL *s, const unsigned char *session, int session_len, s->internal->tlsext_ticket_expected = 1; return 1; } - if (s->internal->tls_session_secret_cb) { + if (s->internal->tls_session_secret_cb != NULL) { /* Indicate that the ticket couldn't be * decrypted rather than generating the session * from ticket now, trigger abbreviated @@ -917,7 +894,7 @@ tls1_process_ticket(SSL *s, const unsigned char *session, int session_len, } r = tls_decrypt_ticket(s, CBS_data(&ext_data), - CBS_len(&ext_data), session, session_len, ret); + CBS_len(&ext_data), session_id, session_id_len, ret); switch (r) { case 2: /* ticket couldn't be decrypted */ @@ -1116,30 +1093,43 @@ tls12_find_id(int nid, tls12_lookup *table, size_t tlen) } int -tls12_get_sigandhash(unsigned char *p, const EVP_PKEY *pk, const EVP_MD *md) +tls12_get_hashid(const EVP_MD *md) { - int sig_id, md_id; - if (!md) - return 0; - md_id = tls12_find_id(EVP_MD_type(md), tls12_md, + if (md == NULL) + return -1; + + return tls12_find_id(EVP_MD_type(md), tls12_md, sizeof(tls12_md) / sizeof(tls12_lookup)); - if (md_id == -1) - return 0; - sig_id = tls12_get_sigid(pk); - if (sig_id == -1) - return 0; - p[0] = (unsigned char)md_id; - p[1] = (unsigned char)sig_id; - return 1; } int tls12_get_sigid(const EVP_PKEY *pk) { + if (pk == NULL) + return -1; + return tls12_find_id(pk->type, tls12_sig, sizeof(tls12_sig) / sizeof(tls12_lookup)); } +int +tls12_get_hashandsig(CBB *cbb, const EVP_PKEY *pk, const EVP_MD *md) +{ + int hash_id, sig_id; + + if ((hash_id = tls12_get_hashid(md)) == -1) + return 0; + if ((sig_id = tls12_get_sigid(pk)) == -1) + return 0; + + if (!CBB_add_u8(cbb, hash_id)) + return 0; + if (!CBB_add_u8(cbb, sig_id)) + return 0; + + return 1; +} + const EVP_MD * tls12_get_hash(unsigned char hash_alg) { diff --git a/lib/libssl/t1_meth.c b/lib/libssl/t1_meth.c index 6a4a243b9d..5ce8c9135b 100644 --- a/lib/libssl/t1_meth.c +++ b/lib/libssl/t1_meth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_meth.c,v 1.23 2017/01/26 05:31:25 jsing Exp $ */ +/* $OpenBSD: t1_meth.c,v 1.25 2018/08/30 16:56:16 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,11 +73,6 @@ static const SSL_METHOD_INTERNAL TLS_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -107,11 +102,6 @@ static const SSL_METHOD_INTERNAL TLSv1_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -141,11 +131,6 @@ static const SSL_METHOD_INTERNAL TLSv1_1_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -175,11 +160,6 @@ static const SSL_METHOD_INTERNAL TLSv1_2_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, diff --git a/lib/libssl/t1_srvr.c b/lib/libssl/t1_srvr.c index 1fc0ebe6f7..02c5cf46ae 100644 --- a/lib/libssl/t1_srvr.c +++ b/lib/libssl/t1_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_srvr.c,v 1.25 2017/01/26 05:31:25 jsing Exp $ */ +/* $OpenBSD: t1_srvr.c,v 1.27 2018/08/30 16:56:16 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -74,11 +74,6 @@ static const SSL_METHOD_INTERNAL TLS_server_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_server_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -108,11 +103,6 @@ static const SSL_METHOD_INTERNAL TLSv1_server_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_server_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -142,11 +132,6 @@ static const SSL_METHOD_INTERNAL TLSv1_1_server_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_server_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, @@ -176,11 +161,6 @@ static const SSL_METHOD_INTERNAL TLSv1_2_server_method_internal_data = { .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, - .ssl_read = ssl3_read, - .ssl_peek = ssl3_peek, - .ssl_write = ssl3_write, - .ssl_shutdown = ssl3_shutdown, - .ssl_pending = ssl3_pending, .get_ssl_method = tls1_get_server_method, .get_timeout = tls1_default_timeout, .ssl_version = ssl_undefined_void_function, diff --git a/lib/libtls/man/tls_accept_socket.3 b/lib/libtls/man/tls_accept_socket.3 index 95022603d6..931b9346ec 100644 --- a/lib/libtls/man/tls_accept_socket.3 +++ b/lib/libtls/man/tls_accept_socket.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tls_accept_socket.3,v 1.3 2017/01/28 00:59:36 schwarze Exp $ +.\" $OpenBSD: tls_accept_socket.3,v 1.4 2018/05/26 12:35:26 schwarze Exp $ .\" .\" Copyright (c) 2015 Ted Unangst .\" Copyright (c) 2015 Joel Sing @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 28 2017 $ +.Dd $Mdocdate: May 26 2018 $ .Dt TLS_ACCEPT_SOCKET 3 .Os .Sh NAME @@ -74,7 +74,7 @@ and can contain a pointer to any caller-specified data. .Pp All these functions create a new context suitable for reading and writing and return it in -.Fa *cctx . +.Pf * Fa cctx . .Sh RETURN VALUES These functions return 0 on success or -1 on error. .Sh SEE ALSO diff --git a/lib/libtls/man/tls_conn_version.3 b/lib/libtls/man/tls_conn_version.3 index d9ee4ac4b6..22f1057add 100644 --- a/lib/libtls/man/tls_conn_version.3 +++ b/lib/libtls/man/tls_conn_version.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tls_conn_version.3,v 1.7 2018/02/10 04:43:16 jsing Exp $ +.\" $OpenBSD: tls_conn_version.3,v 1.8 2018/05/26 12:32:59 schwarze Exp $ .\" .\" Copyright (c) 2015 Bob Beck .\" Copyright (c) 2016, 2018 Joel Sing @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 10 2018 $ +.Dd $Mdocdate: May 26 2018 $ .Dt TLS_CONN_VERSION 3 .Os .Sh NAME @@ -54,8 +54,8 @@ .Fc .Ft const uint8_t * .Fo tls_peer_cert_chain_pem -.Fa struct tls *ctx -.Fa size_t *size +.Fa "struct tls *ctx" +.Fa "size_t *size" .Fc .Ft const char * .Fn tls_peer_cert_issuer "struct tls *ctx" diff --git a/lib/libtls/man/tls_connect.3 b/lib/libtls/man/tls_connect.3 index 161e0d644d..4c4f01c256 100644 --- a/lib/libtls/man/tls_connect.3 +++ b/lib/libtls/man/tls_connect.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tls_connect.3,v 1.3 2017/01/28 00:59:36 schwarze Exp $ +.\" $OpenBSD: tls_connect.3,v 1.4 2018/07/09 19:51:18 tb Exp $ .\" .\" Copyright (c) 2014 Ted Unangst .\" Copyright (c) 2014, 2015 Joel Sing @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 28 2017 $ +.Dd $Mdocdate: July 9 2018 $ .Dt TLS_CONNECT 3 .Os .Sh NAME @@ -84,13 +84,15 @@ If it is then a .Fa host of the format "hostname:port" is permitted. +The name to use for verification is inferred from the +.Ar host +value. .Pp The .Fn tls_connect_servername function has the same behaviour, however the name to use for verification is -explicitly provided, rather than being inferred from the -.Ar host -value. +explicitly provided, for the case where the TLS server name differs from the +DNS name. .Pp An already existing socket can be upgraded to a secure connection by calling .Fn tls_connect_socket . diff --git a/lib/libtls/man/tls_init.3 b/lib/libtls/man/tls_init.3 index f5f63fa326..557998107c 100644 --- a/lib/libtls/man/tls_init.3 +++ b/lib/libtls/man/tls_init.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tls_init.3,v 1.11 2018/03/19 16:34:47 jsing Exp $ +.\" $OpenBSD: tls_init.3,v 1.13 2018/07/09 19:47:20 tb Exp $ .\" .\" Copyright (c) 2014 Ted Unangst .\" Copyright (c) 2016 Joel Sing @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 19 2018 $ +.Dd $Mdocdate: July 9 2018 $ .Dt TLS_INIT 3 .Os .Sh NAME @@ -45,8 +45,8 @@ Both clients and servers are supported. The .Fn tls_init function initializes global data structures. -It may be called once before any other functions, however this is no -longer necessary since it will be handled internally on demand. +It is no longer necessary to call this function directly, +since it is invoked internally when needed. It may be called more than once, and may be called concurrently. .Pp Before a connection is created, a configuration must be created. diff --git a/lib/libtls/man/tls_load_file.3 b/lib/libtls/man/tls_load_file.3 index d487009756..9f738460d6 100644 --- a/lib/libtls/man/tls_load_file.3 +++ b/lib/libtls/man/tls_load_file.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tls_load_file.3,v 1.9 2017/10/08 06:56:36 jmc Exp $ +.\" $OpenBSD: tls_load_file.3,v 1.10 2018/08/21 00:35:55 schwarze Exp $ .\" .\" Copyright (c) 2014 Ted Unangst .\" Copyright (c) 2015 Reyk Floeter @@ -17,7 +17,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 8 2017 $ +.Dd $Mdocdate: August 21 2018 $ .Dt TLS_LOAD_FILE 3 .Os .Sh NAME @@ -118,7 +118,7 @@ .Ft int .Fo tls_config_set_ocsp_staple_file .Fa "struct tls_config *config" -.Fa "const uint8_t *staple_file" +.Fa "const char *staple_file" .Fc .Ft int .Fo tls_config_set_keypair_file diff --git a/lib/libtls/man/tls_ocsp_process_response.3 b/lib/libtls/man/tls_ocsp_process_response.3 index cb979e8088..6e3aa4aecc 100644 --- a/lib/libtls/man/tls_ocsp_process_response.3 +++ b/lib/libtls/man/tls_ocsp_process_response.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tls_ocsp_process_response.3,v 1.4 2017/01/29 18:00:21 beck Exp $ +.\" $OpenBSD: tls_ocsp_process_response.3,v 1.6 2018/07/24 02:01:34 tb Exp $ .\" .\" Copyright (c) 2016 Bob Beck .\" @@ -14,19 +14,19 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 29 2017 $ +.Dd $Mdocdate: July 24 2018 $ .Dt TLS_OCSP_PROCESS_RESPONSE 3 .Os .Sh NAME .Nm tls_ocsp_process_response , +.Nm tls_peer_ocsp_url , +.Nm tls_peer_ocsp_response_status , .Nm tls_peer_ocsp_cert_status , .Nm tls_peer_ocsp_crl_reason , -.Nm tls_peer_ocsp_next_update , -.Nm tls_peer_ocsp_response_status , -.Nm tls_peer_ocsp_result_msg , +.Nm tls_peer_ocsp_result , .Nm tls_peer_ocsp_revocation_time , .Nm tls_peer_ocsp_this_update , -.Nm tls_peer_ocsp_url +.Nm tls_peer_ocsp_next_update .Nd inspect an OCSP response .Sh SYNOPSIS .In tls.h @@ -36,22 +36,22 @@ .Fa "const unsigned char *response" .Fa "size_t size" .Fc +.Ft const char * +.Fn tls_peer_ocsp_url "struct tls *ctx" +.Ft int +.Fn tls_peer_ocsp_response_status "struct tls *ctx" .Ft int .Fn tls_peer_ocsp_cert_status "struct tls *ctx" .Ft int .Fn tls_peer_ocsp_crl_reason "struct tls *ctx" -.Ft time_t -.Fn tls_peer_ocsp_next_update "struct tls *ctx" -.Ft int -.Fn tls_peer_ocsp_response_status "struct tls *ctx" .Ft const char * -.Fn tls_peer_ocsp_result_msg "struct tls *ctx" +.Fn tls_peer_ocsp_result "struct tls *ctx" .Ft time_t .Fn tls_peer_ocsp_revocation_time "struct tls *ctx" .Ft time_t .Fn tls_peer_ocsp_this_update "struct tls *ctx" -.Ft const char * -.Fn tls_peer_ocsp_url "struct tls *ctx" +.Ft time_t +.Fn tls_peer_ocsp_next_update "struct tls *ctx" .Sh DESCRIPTION .Fn tls_ocsp_process_response processes a raw OCSP response in @@ -73,6 +73,9 @@ that was obtained by validating a stapled OCSP response during the handshake, or via a previous call to .Fn tls_ocsp_process_response . .Pp +.Fn tls_peer_ocsp_response_status +returns the OCSP response status as per RFC 6960 section 2.3. +.Pp .Fn tls_peer_ocsp_cert_status returns the OCSP certificate status code as per RFC 6960 section 2.2. .Pp @@ -80,22 +83,33 @@ returns the OCSP certificate status code as per RFC 6960 section 2.2. returns the OCSP certificate revocation reason status code as per RFC 5280 section 5.3.1. .Pp -.Fn tls_peer_ocsp_next_update -returns the OCSP next update time. +.Fn tls_peer_ocsp_result +returns a textual representation of the OCSP status code +returned by one of the previous three functions. +If the OCSP response was valid and the certificate was not +revoked, the string indicates the OCSP certificate status. +Otherwise, the string indicates +the OCSP certificate revocation reason or the OCSP error. .Pp -.Fn tls_peer_ocsp_response_status -returns the OCSP response status as per RFC 6960 section 2.3. -.Pp -.\" XXX Fn tls_peer_ocsp_result_msg does what? .Fn tls_peer_ocsp_revocation_time returns the OCSP revocation time. .Pp .Fn tls_peer_ocsp_this_update returns the OCSP this update time. +.Pp +.Fn tls_peer_ocsp_next_update +returns the OCSP next update time. .Sh RETURN VALUES .Fn tls_ocsp_process_response returns 0 on success or -1 on error. .Pp +.Fn tls_peer_ocsp_url +and +.Fn tls_peer_ocsp_result +return +.Dv NULL +on error or an out of memory condition. +.Pp The .Fn tls_peer_ocsp_response_status function returns one of @@ -133,18 +147,11 @@ or .Dv TLS_CRL_REASON_AA_COMPROMISE on success or -1 on error. .Pp -.Fn tls_peer_ocsp_next_update , .Fn tls_peer_ocsp_revocation_time , +.Fn tls_peer_ocsp_this_update , and -.Fn tls_peer_ocsp_this_update +.Fn tls_peer_ocsp_next_update return a time in epoch-seconds on success or -1 on error. -.Pp -.Fn tls_peer_ocsp_result_msg -and -.Fn tls_peer_ocsp_url -return -.Dv NULL -on error or an out of memory condition. .Sh SEE ALSO .Xr tls_client 3 , .Xr tls_config_ocsp_require_stapling 3 , diff --git a/lib/libtls/shlib_version b/lib/libtls/shlib_version index 730231c38d..7c92aff489 100644 --- a/lib/libtls/shlib_version +++ b/lib/libtls/shlib_version @@ -1,2 +1,2 @@ -major=17 +major=18 minor=1 diff --git a/lib/libtls/tls.c b/lib/libtls/tls.c index 467db164d5..6033e846ba 100644 --- a/lib/libtls/tls.c +++ b/lib/libtls/tls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls.c,v 1.79 2018/03/19 16:34:47 jsing Exp $ */ +/* $OpenBSD: tls.c,v 1.80 2018/04/07 16:30:59 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -41,8 +41,7 @@ static int tls_init_rv = -1; static void tls_do_init(void) { - SSL_load_error_strings(); - SSL_library_init(); + OPENSSL_init_ssl(OPENSSL_INIT_NO_LOAD_CONFIG, NULL); if (BIO_sock_init() != 1) return; diff --git a/lib/libtls/tls_config.c b/lib/libtls/tls_config.c index 6094c74265..07019252a7 100644 --- a/lib/libtls/tls_config.c +++ b/lib/libtls/tls_config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_config.c,v 1.51.2.1 2018/04/18 16:29:11 jsing Exp $ */ +/* $OpenBSD: tls_config.c,v 1.52 2018/04/07 16:35:34 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * diff --git a/lib/libtls/tls_internal.h b/lib/libtls/tls_internal.h index 1746a1aabc..b236204e81 100644 --- a/lib/libtls/tls_internal.h +++ b/lib/libtls/tls_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_internal.h,v 1.71.2.1 2018/04/18 16:29:11 jsing Exp $ */ +/* $OpenBSD: tls_internal.h,v 1.72 2018/04/07 16:35:34 jsing Exp $ */ /* * Copyright (c) 2014 Jeremie Courreges-Anglas * Copyright (c) 2014 Joel Sing @@ -200,7 +200,6 @@ int tls_set_string(const char **_dest, const char *_src); struct tls_keypair *tls_keypair_new(void); void tls_keypair_clear_key(struct tls_keypair *_keypair); -void tls_keypair_clear(struct tls_keypair *_keypair); void tls_keypair_free(struct tls_keypair *_keypair); int tls_keypair_set_cert_file(struct tls_keypair *_keypair, struct tls_error *_error, const char *_cert_file); diff --git a/lib/libtls/tls_keypair.c b/lib/libtls/tls_keypair.c index 64048cf6a2..a98e5c2e7e 100644 --- a/lib/libtls/tls_keypair.c +++ b/lib/libtls/tls_keypair.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_keypair.c,v 1.5.2.1 2018/04/18 16:29:11 jsing Exp $ */ +/* $OpenBSD: tls_keypair.c,v 1.6 2018/04/07 16:35:34 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -29,14 +29,6 @@ tls_keypair_new(void) return calloc(1, sizeof(struct tls_keypair)); } -void -tls_keypair_clear_key(struct tls_keypair *keypair) -{ - freezero(keypair->key_mem, keypair->key_len); - keypair->key_mem = NULL; - keypair->key_len = 0; -} - static int tls_keypair_pubkey_hash(struct tls_keypair *keypair, struct tls_error *error) { @@ -64,6 +56,14 @@ tls_keypair_pubkey_hash(struct tls_keypair *keypair, struct tls_error *error) return (rv); } +void +tls_keypair_clear_key(struct tls_keypair *keypair) +{ + freezero(keypair->key_mem, keypair->key_len); + keypair->key_mem = NULL; + keypair->key_len = 0; +} + int tls_keypair_set_cert_file(struct tls_keypair *keypair, struct tls_error *error, const char *cert_file) @@ -117,25 +117,16 @@ tls_keypair_set_ocsp_staple_mem(struct tls_keypair *keypair, } void -tls_keypair_clear(struct tls_keypair *keypair) -{ - struct tls_error error; - - tls_keypair_set_cert_mem(keypair, &error, NULL, 0); - tls_keypair_set_key_mem(keypair, &error, NULL, 0); - tls_keypair_set_ocsp_staple_mem(keypair, &error, NULL, 0); - - free(keypair->pubkey_hash); - keypair->pubkey_hash = NULL; -} - -void tls_keypair_free(struct tls_keypair *keypair) { if (keypair == NULL) return; - tls_keypair_clear(keypair); + tls_keypair_clear_key(keypair); + + free(keypair->cert_mem); + free(keypair->ocsp_staple); + free(keypair->pubkey_hash); free(keypair); } diff --git a/usr/src/pkg/manifests/library-libressl.inc b/usr/src/pkg/manifests/library-libressl.inc index 96ac283e57..8092b462fb 100644 --- a/usr/src/pkg/manifests/library-libressl.inc +++ b/usr/src/pkg/manifests/library-libressl.inc @@ -102,18 +102,19 @@ file path=usr/include/openssl/x509.h file path=usr/include/openssl/x509_vfy.h file path=usr/include/openssl/x509v3.h file path=usr/include/tls.h -file path=usr/lib/amd64/libcrypto.so.43.1 mode=0555 -file path=usr/lib/amd64/libssl.so.45.1 mode=0555 -file path=usr/lib/amd64/libtls.so.17.1 mode=0555 -file path=usr/lib/libcrypto.so.43.1 mode=0555 -file path=usr/lib/libssl.so.45.1 mode=0555 -file path=usr/lib/libtls.so.17.1 mode=0555 +file path=usr/lib/amd64/libcrypto.so.44.1 mode=0555 +file path=usr/lib/amd64/libssl.so.46.1 mode=0555 +file path=usr/lib/amd64/libtls.so.18.1 mode=0555 +file path=usr/lib/libcrypto.so.44.1 mode=0555 +file path=usr/lib/libssl.so.46.1 mode=0555 +file path=usr/lib/libtls.so.18.1 mode=0555 file path=usr/lib/pkgconfig/libcrypto.pc mode=0444 file path=usr/lib/pkgconfig/libssl.pc mode=0444 file path=usr/lib/pkgconfig/openssl.pc mode=0444 file path=usr/share/man/man1/nc.1 file path=usr/share/man/man1/openssl.1 file path=usr/share/man/man3/ACCESS_DESCRIPTION_new.3 +file path=usr/share/man/man3/ASN1_INTEGER_get.3 file path=usr/share/man/man3/ASN1_OBJECT_new.3 file path=usr/share/man/man3/ASN1_STRING_TABLE_add.3 file path=usr/share/man/man3/ASN1_STRING_length.3 @@ -209,6 +210,17 @@ file path=usr/share/man/man3/EC_GROUP_new.3 file path=usr/share/man/man3/EC_KEY_new.3 file path=usr/share/man/man3/EC_POINT_add.3 file path=usr/share/man/man3/EC_POINT_new.3 +file path=usr/share/man/man3/ENGINE_add.3 +file path=usr/share/man/man3/ENGINE_ctrl.3 +file path=usr/share/man/man3/ENGINE_get_default_RSA.3 +file path=usr/share/man/man3/ENGINE_init.3 +file path=usr/share/man/man3/ENGINE_new.3 +file path=usr/share/man/man3/ENGINE_register_RSA.3 +file path=usr/share/man/man3/ENGINE_register_all_RSA.3 +file path=usr/share/man/man3/ENGINE_set_RSA.3 +file path=usr/share/man/man3/ENGINE_set_default.3 +file path=usr/share/man/man3/ENGINE_set_flags.3 +file path=usr/share/man/man3/ENGINE_unregister_RSA.3 file path=usr/share/man/man3/ERR.3 file path=usr/share/man/man3/ERR_GET_LIB.3 file path=usr/share/man/man3/ERR_asprintf_error_data.3 @@ -514,7 +526,6 @@ file path=usr/share/man/man3/d2i_X509_NAME.3 file path=usr/share/man/man3/d2i_X509_REQ.3 file path=usr/share/man/man3/d2i_X509_SIG.3 file path=usr/share/man/man3/des_read_pw.3 -file path=usr/share/man/man3/engine.3 file path=usr/share/man/man3/evp.3 file path=usr/share/man/man3/get_rfc3526_prime_8192.3 file path=usr/share/man/man3/i2d_PKCS7_bio_stream.3 @@ -535,15 +546,15 @@ file path=usr/share/man/man3/tls_ocsp_process_response.3 file path=usr/share/man/man3/tls_read.3 file path=usr/share/man/man5/openssl.cnf.5 file path=usr/share/man/man5/x509v3.cnf.5 -link path=usr/lib/amd64/libcrypto.so target=libcrypto.so.43.1 -link path=usr/lib/amd64/libcrypto.so.43 target=libcrypto.so.43.1 -link path=usr/lib/amd64/libssl.so target=libssl.so.45.1 -link path=usr/lib/amd64/libssl.so.45 target=libssl.so.45.1 -link path=usr/lib/amd64/libtls.so target=libtls.so.17.1 -link path=usr/lib/amd64/libtls.so.17 target=libtls.so.17.1 -link path=usr/lib/libcrypto.so target=libcrypto.so.43.1 -link path=usr/lib/libcrypto.so.43 target=libcrypto.so.43.1 -link path=usr/lib/libssl.so target=libssl.so.45.1 -link path=usr/lib/libssl.so.45 target=libssl.so.45.1 -link path=usr/lib/libtls.so target=libtls.so.17.1 -link path=usr/lib/libtls.so.17 target=libtls.so.17.1 +link path=usr/lib/amd64/libcrypto.so target=libcrypto.so.44.1 +link path=usr/lib/amd64/libcrypto.so.44 target=libcrypto.so.44.1 +link path=usr/lib/amd64/libssl.so target=libssl.so.46.1 +link path=usr/lib/amd64/libssl.so.46 target=libssl.so.46.1 +link path=usr/lib/amd64/libtls.so target=libtls.so.18.1 +link path=usr/lib/amd64/libtls.so.18 target=libtls.so.18.1 +link path=usr/lib/libcrypto.so target=libcrypto.so.44.1 +link path=usr/lib/libcrypto.so.44 target=libcrypto.so.44.1 +link path=usr/lib/libssl.so target=libssl.so.46.1 +link path=usr/lib/libssl.so.46 target=libssl.so.46.1 +link path=usr/lib/libtls.so target=libtls.so.18.1 +link path=usr/lib/libtls.so.18 target=libtls.so.18.1 -- 2.11.4.GIT